Skip to content
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

Mask values outside of a LabelMap #521

Closed
Svdvoort opened this issue May 7, 2021 · 6 comments · Fixed by #527
Closed

Mask values outside of a LabelMap #521

Svdvoort opened this issue May 7, 2021 · 6 comments · Fixed by #527
Labels
enhancement New feature or request

Comments

@Svdvoort
Copy link
Contributor

Svdvoort commented May 7, 2021

🚀 Feature

Have an IntensityTransform that sets values outside of a certain LabelMap to a specific value.

Motivation

This can be handy for example for skull-stripping (as also discussed in #428 ) when a brain mask is already available or in general when a foreground mask is available and you want to mask out the 'background'

Pitch

Easily use a transform to mask out certain parts of the image.

Alternatives

It is possible to do intensity normalization with a mask using the current IntensityTransforms, and these only take into account the values within the mask, but it doesn't seem to be actually possible to set the values outside of the mask.

Additional context

I can implement this feature but wanted to open a request first according to the contributing guidelines and to check whether there's not something that I missed.

@Svdvoort Svdvoort added the enhancement New feature or request label May 7, 2021
@fepegar
Copy link
Owner

fepegar commented May 7, 2021

Hi, @Svdvoort. Thanks for your proposal. I think this would be helpful.

I can implement this feature but wanted to open a request first according to the contributing guidelines and to check whether there's not something that I missed.

That's great! And yes, this is the preferred workflow, thanks. I agree it shouldn't be complicated.

Have you thought of how this would work? Maybe an interface similar to the normalization transforms, using masking_method?

@Svdvoort
Copy link
Contributor Author

Svdvoort commented May 7, 2021

Great!

Yes, I would just make it a subclass of NormalizationTransform, with masking_method being a non-optional argument, unless you would prefer a different approach.

@fepegar
Copy link
Owner

fepegar commented May 7, 2021

I'm not sure this counts as normalization. The masking logic is now in Transform, so I'd just make this new transform (Mask?) directly inherit from IntensityTransform. What do you think?

@Svdvoort
Copy link
Contributor Author

Svdvoort commented May 7, 2021

Indeed you're right, IntensityTransform is a better start point. I was doubting between Mask and MaskIntensity as options. The first might be confusing with the actual LabelMask as a property rather than a function.

@fepegar
Copy link
Owner

fepegar commented May 7, 2021

The first might be confusing with the actual LabelMask as a property rather than a function.

I'm not sure I understand.

I was doubting between Mask and MaskIntensity

I'd say Mask is good enough because it already implies intensity. I added it to RescaleIntensity, originally called Rescale, I believe, because it might be misinterpreted as resampling.

@Svdvoort Svdvoort mentioned this issue May 10, 2021
9 tasks
@Svdvoort
Copy link
Contributor Author

See above for the propose pull request.

I'm not sure I understand.

At first instance I thought there could be some confusion as Mask is often used (at least in our institute), to mean with what in torchio is basically a LabelMap. For example, a brain mask or a defacing mask. Hence, there could be some confusion about whether it is an 'object' (like the LabelMap) or a function/verb, like intended in this case. However, since SimpleITK also just uses Mask as the function, I think I agree with you that it is better to just stay with Mask as the function name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants