-
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
[PET] Improve how to 4D images with 1 volume are handled #871
Comments
Thanks for looking into this @alexandreroutier ! def _check_img_3d(img):
"""Load a 3D nifti image, raise if not 3D..."""
img = nib.load(img)
dim = len(img.shape)
if dim != 3:
if dim == 4 and img.shape[3] == 1:
data = img.get_fdata()
klass = img.__class__
header = copy.deepcopy(img.header)
return klass(data[:, :, :, 0], img.affine, header=header)
error_msg = (
f"Clinica does not handle {dim}D volumes for {image_id.replace('_', ' | ')}"
)
cprint(error_msg, lvl="error")
raise NotImplementedError(error_msg)
return img |
In that case, I'd suggest to rename this function to something more explicit.
From the old For the On a side note, since the PET volumes likely came from preprocessed ADNI files, maybe it's also the job of our converters to ensure volumes are squeezed and (re)written to 3D. There was also a similar point raised in #622 about normalizing the data type used for writing. |
Yes, I agree the name is misleading, I'll change that in #872 |
I didn't think about it yesterday but you are raising the fact that we don't known how third party apps are handling this particular case 🤔 Generating an 'adequate' 3D image would be the simplest solution. (For info, this |
Hi!
Following Discussion #870, it turns out that 4D images with 1 volume are not taken into account in PET pipelines:
pet-surface*
:clinica/clinica/pipelines/pet_surface/pet_surface_utils.py
Lines 949 to 952 in 4e5f5d9
pet-volume*
:clinica/clinica/pipelines/pet_volume/pet_volume_utils.py
Lines 13 to 16 in 4e5f5d9
A solution would be:
(I have a doubt but a oneliner
if len(img.shape) == 4 and img.shape[3] > 1:
could also work)Best,
Alex
The text was updated successfully, but these errors were encountered: