-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add abstract and concrete classes for negative controls and regions #81
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 abstract and concrete classes for negative controls and regions #81
Conversation
Caution Review failedThe pull request is closed. WalkthroughThis pull request introduces several changes, primarily focusing on the addition of a new path in the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (10)
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #81 +/- ##
===========================================
- Coverage 60.92% 44.51% -16.41%
===========================================
Files 10 16 +6
Lines 540 739 +199
===========================================
Hits 329 329
- Misses 211 410 +199 ☔ View full report in Codecov by Sentry. |
…dability in main module
addressing this comment
this is a good catch, when I initially defined the base classes I didnt know how the transformations were done and then I didnt know what other regions might be implemented in the future so I left the if we arent looking to implement new regions we can remove the parameter. some ideas I had for regions that would use the original class ThresholdRegion(RegionStrategy):
"""
Region strategy to include only pixels in the image where intensity exceeds a threshold.
Unlike ROI-based strategies, this strategy does not consider the mask_array.
"""
region_name: str = "threshold"
def __init__(self, threshold: float):
"""
Initialize the region strategy with a given intensity threshold.
Parameters
----------
threshold : float
The intensity threshold for including pixels in the region.
"""
self.threshold = threshold
def __call__(self, image_array: np.ndarray, _: np.ndarray) -> np.ndarray:
"""
Apply the threshold-based region mask to the image.
Parameters
----------
image_array : np.ndarray
The full image array to evaluate pixel intensities.
_ : np.ndarray
Ignored in this implementation.
Returns
-------
np.ndarray
A binary mask including only pixels in the image that exceed the threshold.
"""
# Apply the threshold directly to the image array
region_mask = np.where(image_array > self.threshold, 1, 0)
# Validate that the resulting mask is not empty
if not region_mask.any():
raise ValueError("No pixels in the image exceed the specified intensity threshold.")
return region_mask |
…docstrings and type hints
… with detailed parameter description and reference link
… in abstract classes and manager
4D-Lung
Order of operations
negative_control_strategy(image, mask=mask, region=region_strategy)
__call__
on thenegative_control_strategy
__call__
ofregion(image_array, mask_array)
transform
method of theNegativeControlStrategy
concrete classes toimage_array[mask_indices] = transformed_values
Resource on Strategy Pattern: https://refactoring.guru/design-patterns/strategy/python/example
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores