-
Notifications
You must be signed in to change notification settings - Fork 82
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
Inconsistent cropped image size for ADNI FLAIR #1425
Comments
Hi @manonheff Thanks for reporting. I think there are two things: First, it is not normal that the code is not raising an error when using a bounding box that goes outside of the images's limits. That will not solve the problem but at least it wouldn't silently process the images, leading to subtle bugs later on like you mentioned. Second, I'm a bit surprised that we have two MNI templates of different shapes, one for T1 and one for Flair, but only one bounding box: >>> import nibabel as nib
>>> from clinica.utils.image import get_mni_template, get_mni_cropped_template
>>> nib.load(get_mni_template("t1")).shape
(193, 229, 193)
>>> nib.load(get_mni_template("flair")).shape
(182, 218, 182)
>>> nib.load(get_mni_cropped_template()).shape
(169, 208, 179) The bounding box is indeed of the dimensions of the expected cropped template (which seem to be the same for t1 and flair), but I believe the issue is that we would need a second bounding box, specific to flair. Does this make sense ? |
Hello, Having a bounding box specific for the flair template makes sense, indeed. I'm surprised however that previous flair datasets processed with flair linear did not have the same issue. I have an old version of MSSEG (unfortunately I do not have the version of clinica used to process), where the uncropped image has the dimension of the flair template you mentioned, but the cropped version of the image matches the dimensions of the mni_cropped_template. |
It is due to the fact that we "recently" changed the cropping step of the pipelines t1-linear, flair-linear, and pet-linear. Previously these pipelines were not really cropping the images, but were resampling them to the reference template. Since this was considered a waste of resources (performing resampling when cropping is immediate), it was decided to change this step to perform pure cropping instead. You can check the details in issue #1214 and PR #1215 Back then, we computed the bounding box using the MNI template of T1 before and after cropping. We had access to both and it was just a matter of finding the coordinates of the bounding box, that, when applied on the original template, will give the cropped one. I need to take a closer look to see how we can find the bounding box for Flair, or if we go back to resampling in this case. |
After investigation, it seems like the cropped template is assumed to be the same for T1 and flair although it shouldn't be. The files Because of that, I cannot infer the bounding box for Flair (at least in the same way we did for T1). I think, one possible way forward would be to try cropping the images and, if the bounding box is not coherent with the image size, then default to resampling the image to the template. This would at least produce something with expected dimensions while still using pure cropping when possible. |
Hello,
I ran flair-linear on ADNI and the output images have a shape of (169, 205, 179), different than that of the usual template size (169, 208, 179) from the documentation.
After investigation it appears that this comes from the size of input_image (line 433 in utils/image.py : input_image.get_fdata() ) which is 3 pixel short on the y-axis compared to the coordinates of MNI_CROP_BBOX : input_image is of size (182, 218, 182), and MNI_CROP_BBOX has coordinates (12, 181, 13, 221, 0, 179).
This can be problematic when using these images as inputs for neural networks, especially when working with multiple datasets with some for which the final cropped image dimensions do match the template.
Perhaps the size of the images could be checked earlier on in the pipeline and corrected if necessary to ensure a consistent final cropped size while not altering the registration to the MNI space ?
Best,
The text was updated successfully, but these errors were encountered: