Error loading nifti file

Hi,

I’m trying to load a nifti file in the Slicer 5.1.0-2022-05-24 version as a segmentation, and the following error occurs:

image

The nifti file is uploaded here

Thank you!

Deepa

Hi Deepa -

Yes, this has been happening with the latest Slicer due to tightening of the ITK file loader in terms of what it considers valid nifti format. (See here and here for some discussions).

What software generated this file? Arguably the file is ambiguous (non-conforming to the standard) and the software that generated it needs to be fixed.

As a workaround you could use the older 4.11 version to convert to nrrd if you don’t have any other options. Or perhaps you can use a different file format from the beginning.

-Steve

Hi Steve,

Thanks for your response! I’ll take a look at those discussions.

The nifti file was generated by the package TotalSegmenter (GitHub - wasserth/TotalSegmentator: Tool for robust segmentation of 104 important anatomical structures in CT images). Converting to nrrd would be fine for my case I think.

Thanks!

Deepa

Hi Deepa -

I guessed that was the case! I have been testing out TotalSegmentator too and ran into exactly the same issue.

I’m applying the tool to a directory full of CT scans and oddly the error only shows up in a few of them. And for the cases where the output of TotalSegmentator fails to load the original data set loads fine, so somehow the header is not being preserved correctly. There must be something about the geometry of some cases that leads to this issue, possibly when the images are resized to fit the network…

From what I can tell TotalSegmentator uses nnUNET code to write the files and that uses SimpleITK. So it’s ironic that ITK now can’t read a file written by SimpleITK.

So the workaround of using the old Slicer is still valid, but this gives another argument for investigating if the current version of ITK is being overly strict. Or if the files are really wrong we help them fix TotalSegmentator/nnUNET/SimpleITK.

BTW, TotalSegmentator itself is quite nice and seems robust. I ran it on the CTACardio scan from the Slicer SampleData and the results are impressive to my eye. (The segmentation below took 8 minutes on a K80 GPU).

I can open the file with current ITK master, the error message is the same, but it is (or was) another issue, highly likely fixed with the https://github.com/InsightSoftwareConsortium/ITK/pull/3339

1 Like

ITK PR 3339 fixes it for me. It should come with Slicer PR 6454. The problem was most likely introduced by ITK PR 1868.

I was reading posts about nifti issues, but I somehow managed to miss @issakomi’s post.

@Sam_Horvath and @jamesobutler can we merge 6454 now?

Also CC: @hjmjohnson @pieper @lassoan.

1 Like