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
[feature] Add RescaleIntensity & ZNormalization & ClampIntensity transforms #2241
base: dev-1.x
Are you sure you want to change the base?
Conversation
|
|
||
def transform(self, results: dict) -> dict: | ||
img = results['img'] | ||
img = self.clamp(img) |
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.
img = self.clamp(img) | |
img = np.clip(img, self.t_min, self.t_max) |
def clamp(self, img): | ||
return np.clip(img, self.t_min, self.t_max) |
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.
Perhaps we can delete L1411-1412 since np.clip()
could be directly used in def transform()
?
self.channel_wise = channel_wise | ||
|
||
def _normalize(self, img: np.ndarray, mean=None, std=None): | ||
slices = np.ones_like(img, dtype=bool) |
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.
What does slices = np.ones_like(img, dtype=bool)
for?
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.
I find that the "slices" is designed for the case that we only want to normalize the non-zero intensity of the image in MONAI. But I haven't added this function. In this version, the "slices" is not necessary. I will remove it. Thanks!
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.
I find that the "slices" is designed for the case that we only want to normalize the non-zero intensity of the image in MONAI. But I haven't added this function. In this version, the "slices" is not necessary. I will remove it. Thanks!
OK, got it! Thanks. Shall we add this normalize the non-zero intensity of the image
function in the future? Do you think this function is important in medical image segmentation?
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.
From my experiences so far, the difference of using it is slight most of the time but it's meaningful.
Adding it would be a better idea. Thanks!
mean (float, optional): the mean to subtract by | ||
Defaults to None. | ||
std (float, optional): the standard deviation to divide by | ||
Defaults to None. |
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.
Please add docstring about channel_wise
.
Codecov ReportBase: 83.55% // Head: 83.45% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## dev-1.x #2241 +/- ##
===========================================
- Coverage 83.55% 83.45% -0.10%
===========================================
Files 140 141 +1
Lines 7958 8062 +104
Branches 1191 1208 +17
===========================================
+ Hits 6649 6728 +79
- Misses 1119 1139 +20
- Partials 190 195 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Hi, @kellyiss thanks for your nice PR. Please fix the unit test problem. We would review it ASAP. |
4c28e1e
to
115552d
Compare
Needed to convert `timesteps` to `float32` a bit sooner. Fixes open-mmlab#1537
Hi @kellyiss !We are grateful for your efforts in helping improve this open-source project during your personal time. |
Motivation
Support rescale intensity, znormalization and clamp intensity for medical data.