nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats
http://nipy.org/nibabel/
Other
655 stars 258 forks source link

nicom MultiframeWrapper fails to return image_shape attribute with multi-volume mri data #1388

Open AlanKuurstra opened 4 days ago

AlanKuurstra commented 4 days ago

Does the nibabel.nicom dicom wrapper support multi-frame dicoms with multiple volumes?

I have a dicom with frame index ordering: "Temporal Position Index", "Stack ID", "In Stack Position Number". Loading the dicom and attempting to access the image_shape attribute

mw = dw.wrapper_from_file(filepath, force=True, stop_before_pixels=True)
mw.image_shape

fails with error:

Traceback (most recent call last):
  File "/home/akuurstr/.config/JetBrains/PyCharm2024.2/scratches/heudiconv_bruker_dicom_conversion.py", line 65, in <module>
    mw.image_shape
  File "/usr/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/virtualization/python_virtualenvs/heudiconv/lib/python3.10/site-packages/nibabel/nicom/dicomwrappers.py", line 770, in image_shape
    raise WrapperError('Non-singular index precedes the slice index')
nibabel.nicom.dicomwrappers.WrapperError: Non-singular index precedes the slice index

It seems MultiframeWrapper wants the stack position number to be the slowest changing index.

moloney commented 4 days ago

The code currently assumes we don't need to reorder the DimensionIndexValues, mostly out of expediency and lack of a clear need. Your dataset appears to show that we do need to check for and allow this. Can you share the dataset?

AlanKuurstra commented 10 hours ago

Here is a link to one of bruker's enhanced dicoms:

https://uwoca-my.sharepoint.com/:u:/g/personal/akuurstr_uwo_ca/ERV-zm-DPOhHqv1pSUWVj1oBQMV8FbAb7CT-9SjNC019Mg?e=nk4Lyo

@isolovey, do you have a dataset to add from your converter?