-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add option to combine channels using sum and max #1159
Conversation
🧙 Sourcery has finished reviewing your pull request! Tips
|
WalkthroughThe changes introduce a new Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (8)
- package/PartSeg/_roi_analysis/partseg_settings.py (1 hunks)
- package/PartSeg/common_gui/image_adjustment.py (1 hunks)
- package/PartSegCore/image_transforming/init.py (1 hunks)
- package/PartSegCore/image_transforming/combine_channels.py (1 hunks)
- package/PartSegCore/image_transforming/image_projection.py (2 hunks)
- package/PartSegCore/image_transforming/interpolate_image.py (1 hunks)
- package/PartSegCore/image_transforming/swap_time_stack.py (1 hunks)
- package/PartSegCore/image_transforming/transform_base.py (1 hunks)
Additional comments not posted (13)
package/PartSegCore/image_transforming/__init__.py (3)
2-2
: LGTM! Import statement forCombineChannels
.The import statement for
CombineChannels
is correctly added.
8-8
: LGTM! Update toimage_transform_dict
.The
CombineChannels
class is correctly added to theimage_transform_dict
.
10-10
: LGTM! Update to__all__
.The
__all__
list is correctly updated to includeCombineChannels
.package/PartSegCore/image_transforming/transform_base.py (1)
21-21
: LGTM! Update to method signature forget_fields_per_dimension
.The method signature change to accept an
Image
object is consistent with the new functionality.However, ensure that all calls to
get_fields_per_dimension
are updated to match the new signature.Verification successful
LGTM! Update to method signature for
get_fields_per_dimension
.The method signature change to accept an
Image
object is consistent with the new functionality. All calls toget_fields_per_dimension
have been updated to match the new signature.
Definitions:
package/PartSegCore/image_transforming/combine_channels.py
package/PartSegCore/image_transforming/swap_time_stack.py
package/PartSegCore/image_transforming/image_projection.py
package/PartSegCore/image_transforming/interpolate_image.py
package/PartSegCore/image_transforming/transform_base.py
Usage:
package/PartSeg/common_gui/image_adjustment.py
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `get_fields_per_dimension` match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type python -A 5 'get_fields_per_dimension'Length of output: 79
Script:
#!/bin/bash # Description: Verify all calls to `get_fields_per_dimension` match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type py -A 5 'get_fields_per_dimension'Length of output: 3601
package/PartSegCore/image_transforming/swap_time_stack.py (1)
21-21
: LGTM! Update to method signature forget_fields_per_dimension
.The method signature change to accept an
Image
object is consistent with the new functionality.However, ensure that all calls to
get_fields_per_dimension
are updated to match the new signature.Verification successful
All calls to
get_fields_per_dimension
have been updated to match the new signature.The method signature change to accept an
Image
object is consistently applied across the codebase.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `get_fields_per_dimension` match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type python -A 5 'get_fields_per_dimension'Length of output: 79
Script:
#!/bin/bash # Description: Verify all calls to `get_fields_per_dimension` match the new signature. # Test: Search for the method usage. Expect: Only occurrences of the new signature. rg --type py -A 5 'get_fields_per_dimension'Length of output: 3601
package/PartSeg/common_gui/image_adjustment.py (1)
25-25
: LGTM! Update toFormWidget
instantiation.The change simplifies the code by passing the
image
object directly.However, ensure that the
FormWidget
class can handle theimage
object correctly.package/PartSegCore/image_transforming/interpolate_image.py (1)
17-18
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
get_fields_per_dimension
match the new signature.Verification successful
Verify the function calls to
get_fields_per_dimension
match the new signature.The function
get_fields_per_dimension
is used in multiple files. Ensure that all calls to this function pass anImage
object as an argument.
package/PartSeg/common_gui/image_adjustment.py
- Line:
form_widget = FormWidget(val.get_fields_per_dimension(image), initial_values)
package/PartSegCore/image_transforming/swap_time_stack.py
- Line:
def get_fields_per_dimension(cls, image: Image):
package/PartSegCore/image_transforming/interpolate_image.py
- Line:
def get_fields_per_dimension(cls, image: Image) -> List[Union[str, AlgorithmProperty]]:
package/PartSegCore/image_transforming/image_projection.py
- Line:
def get_fields_per_dimension(cls, image: Image):
package/PartSegCore/image_transforming/transform_base.py
- Line:
def get_fields_per_dimension(cls, image: Image) -> List[Union[str, AlgorithmProperty]]:
package/PartSegCore/image_transforming/combine_channels.py
- Line:
def get_fields_per_dimension(cls, image: Image) -> List[Union[str, AlgorithmProperty]]:
All instances appear to follow the new signature, passing an
Image
object as an argument.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `get_fields_per_dimension` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type python -A 5 $'get_fields_per_dimension'Length of output: 79
Script:
#!/bin/bash # Description: Verify all function calls to `get_fields_per_dimension` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type py -A 5 $'get_fields_per_dimension'Length of output: 3601
package/PartSegCore/image_transforming/combine_channels.py (4)
19-20
: LGTM!The method correctly returns a list of algorithm properties with a default combine mode.
23-27
: LGTM!The method correctly returns a list of algorithm properties for each channel in the image.
34-53
: LGTM!The method correctly combines channels in the image based on the specified combine mode and updates the image accordingly.
56-60
: LGTM!The method correctly calculates initial values for the algorithm properties based on the image spacing.
package/PartSegCore/image_transforming/image_projection.py (1)
70-70
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
get_fields_per_dimension
match the new signature.Verification successful
Let's correct the
rg
command to use the appropriate file type for Python files and re-run the script to verify the function usage in the codebase.
Verified: All function calls to
get_fields_per_dimension
match the new signature.The code changes are consistent across the codebase, and the function usage has been updated appropriately.
package/PartSeg/common_gui/image_adjustment.py
package/PartSegCore/image_transforming/transform_base.py
package/PartSegCore/image_transforming/swap_time_stack.py
package/PartSegCore/image_transforming/interpolate_image.py
package/PartSegCore/image_transforming/image_projection.py
package/PartSegCore/image_transforming/combine_channels.py
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `get_fields_per_dimension` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type python -A 5 $'get_fields_per_dimension'Length of output: 79
Script:
#!/bin/bash # Description: Verify all function calls to `get_fields_per_dimension` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type py -A 5 $'get_fields_per_dimension'Length of output: 3601
package/PartSeg/_roi_analysis/partseg_settings.py (1)
109-113
: LGTM!The method now correctly includes a check for the equality of
image.channels
to ensure consistency.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #1159 +/- ##
===========================================
+ Coverage 93.05% 93.06% +0.01%
===========================================
Files 208 209 +1
Lines 32763 32830 +67
===========================================
+ Hits 30486 30553 +67
Misses 2277 2277 ☔ View full report in Codecov by Sentry. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- package/PartSegCore/image_transforming/init.py (1 hunks)
- package/PartSegCore/image_transforming/combine_channels.py (1 hunks)
- package/tests/test_PartSegCore/test_image_adjustment.py (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- package/PartSegCore/image_transforming/init.py
- package/PartSegCore/image_transforming/combine_channels.py
Additional comments not posted (6)
package/tests/test_PartSegCore/test_image_adjustment.py (6)
5-5
: Imports look good.The imported classes
CombineChannels
,CombineMode
, andInterpolateImage
are necessary for the new tests.
23-27
: Functionget_cube_image_2ch
looks good.The function correctly creates a 2-channel cube image and returns an
Image
object.
118-125
: Test methodtest_simple
looks good.The test correctly sets up the image, applies the
CombineChannels
transformation with theMax
mode, and verifies the results.
126-130
: Test methodtest_no_channels
looks good.The test correctly sets up the image, applies the
CombineChannels
transformation with no specific channel settings, and verifies the results.
131-138
: Test methodtest_sum
looks good.The test correctly sets up the image, applies the
CombineChannels
transformation with theSum
mode, and verifies the results.
139-145
: Test methodtest_max
looks good.The test correctly sets up the image, applies the
CombineChannels
transformation with theMax
mode, and verifies the results.
Summary by CodeRabbit
New Features
CombineChannels
class, allowing users to combine image channels using modes like Max or Sum.Bug Fixes
ImageProjection
to improve image handling.Tests