-
Notifications
You must be signed in to change notification settings - Fork 240
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
crop and pad around mask center #104
Comments
Hi Romain, In case we wanted to implement it, I guess it could be something like: What if the label image has more than one connected component? Only the largest should be used? What should be used, the centroid of the component or the middle of its bounding box? Once there is a center, I think the best would be creating a new image with the desired bounds (being careful about computing the origin) and resampling the intensity images with an identity transform using the computed image as reference. Would you like to work on this? |
Hi In my case I will apply it with brain mask so only one connected component, and then If I understand correctly the centroid is the same a the middle of the bounding box, no ? The way I imagine is to find min max index of nozero voxel of the mask. this gives me a mask field of view and I take the center to then compute crop and pad I do not understand your last point, once I have the center, why do I need to reslice ? I want to compute crop or pad in each side of the center separatly I can try to make a proposition and let you choose to incorporate it or not. Should I make a new class ? |
You're right that reslicing/resampling is not needed. I just thought of it as the fastest way of implementing, but I'm probably wrong/lazy. Note, though, that no interpolation would be needed so the operation would be lossless and very fast. What I meant with preprocessing is cropping all images before training. But I guess you're planning to apply e.g. rotations on the fly and then you want to crop the image around the brain, wherever it ends up. And that's why you want a transform. Is this correct? Maybe a general About the centroid vs bounding box. Consider this image:
The bounding box center is (1, 1). The centroid/center of mass of the connected component is (0.6, 0.6). |
yes exactly having it as a transform will make it easy to check different order (first motion then crop) I'll see what we can achieve and let you know |
Great, thanks! I think the code would be quite similar to |
but better to do a new class, or add an option ? |
I feel like if an option is added to class CenterCropOrPad(CropOrPad):
def __init__(self, bla):
super().__init__(bla, mode='center') and be deprecated in favor of the new class. |
Resolved in #110. |
Hello
what do you things of the possibility to do the same as CenterCropOrPad, but instead of take the center of the image I would like to take the centre of a label mask (center of non zero element)
Could be very useful to get the same field of view center on the brain, if you have a brain mask.
It could either be an option in CenerCropOrPad, or a new class ... ?
this may be a little bit tricky since there could be a crop for the lower part and a pad for the upper part ...
++
The text was updated successfully, but these errors were encountered: