Incorrect dimensions using Bio-Formats to open .nii and nii.gz NIfTI files

I’ve used dicom2nifti to convert a dicom MRI stack (256x512x36 in xyz respectively) into nifti. I’m trying to use the Bio-Formats plugin in FIJI to view the output nii.gz file (or .nii if I extract first) to verify that it has properly converted my image stack. I’m able to view the input dicoms just fine using the File > Import > Image Sequence tool.

My problem is that when I try to view the output nifti, either with the built-in import options or with Bio-Formats, the image is either a corrupted mess of static or the dimensions are swapped to 36x256x512 (rather than 256x512x36).

I have tried changing the bitness, signed/unsigned, and endianness using the standard import tool, and with Bio-Formats I have tried the different stack viewers and the “Swap dimensions” option (and most other checkboxes), but nothing seems to work. I am particularly confused by the “Swap dimensions” option, because it only allows me to change Z, C, and T rather than X, Y, and Z, and it only lets me choose between 1, 1, and 512, rather than my actual pixel dimensions. I’m fairly certain that I used the dicom2nifti conversion tool correctly and that the issue is with me using FIJI correctly to view the result.

Thanks in advance.

Hi @caligos, are you able to share the file to a public location so that we can test it? (If you dont have a suitable upload location we would recommend Zenodo)

Hi @dgault, sure I will try to upload to Google Drive or maybe Zenodo, but I need to verify that all patient info/metadata has been removed first. I’ll reply again here when I’m done.

Hi @dgault, apologies for the delayed response. I’ve uploaded the file to Zenodo here

Thank you very much for providing the upload. I was able to start debugging through the file, until now all the NIfTI files we have seen have had dimensions in the same hardcoded order but for some reason this appears to be different. It may be that this is a different version of the format, I will continue looking into this to see if I can find the dimension order stored in the file header, if I can locate it then I can use that to update the Bio-Formats reader in future.

Thank you for your help.

Am I understanding correctly that the only fix would be for me to wait for a potential update to Bio-Formats at some point in the future?

Looking through the spec from https://nifti.nimh.nih.gov/ it does seem that the dimensions should always be in XYZ order which suggests that the NIfTI file generated in the conversion is incorrect. If the original DICOM looks correct then I suspect the issue may lie in the conversion process somewhere.

1 Like

@dgault Damn, I was really hoping that wasn’t the case. Thanks a lot for helping me out with this, I appreciate it.

1 Like