Error opening Nifti files

Hi,

I downloaded the most recent version of Paraview, and I’m unable to open nifti files (.nii.gz) that I can open with FSLeyes and ITKsnap. First, I open the folder and select “All files(*)” because otherwise I can’t even see them. Then, when I click on the files, I try to open them with “Nifti Volume Reader”. Afterwards, I get the following error:

** ERROR (nifti_image_read): failed to find header file for ‘/path/to/file.nii.gz’
( 21.219s) [paraview ] vtkNIfTIReader.cxx:203 ERR| vtkNIfTIReader (0x5dabd40): Read failed

Is there any way I can solve this? Thank you very much.

Hi @mdk82jd

Please share your data

Best,

Hi,

I had problems with any .nii.gz. For example, https://github.com/richardbeare/nifti_paraview/blob/master/MNI152_T1_0.5mm.nii.gz

You need to extract it first

gunzip MNI152_T1_0.5mm.nii.gz

Hi,

You’re right. Unzipped nifti files can be open by paraview.

Is there any way to open .nii.gz files directly? I need to open files that, compressed, are 12GB.

Thanks!

I’m afraid not, see this discussion though:

1 Like

sorry to dig this thread up…
I wanted to open some .nii files too (I gunzip’ed them already), but I cannot find that reader in paraview 6.1 RC1?
The .nii extension is not automatically recognized by paraview and I cannot find any hint for a plugin with that name?

Tools → Manage Plugins. Select AnalyzeNifTIReaderWriter and then hit “Load Selected”.

1 Like

Thanks! Silly me… I started search from N onwards and was not expecting that it is the 2nd plugin in the list :smiley:

Unfortunately, it seems not to work with my file:

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
error: exception occurred: Subprocess aborted

The file is a 2.6GB image with int16 data inside.

I can help you test the nifti if you can share the file.

Unfortunately, I cannot share the specific file, however, I created an empty file like this which gives the same error message:

import SimpleITK as sitk
sitk.WriteImage(sitk.Image(1450, 1450, 667, sitk.sitkInt16), "foobaz.nii.gz")

foobaz.nii.gz (2.6 MB)

My paraview also crashes with the same error. I tried reducing the dimensions of the image and then it was able to load just fine. Please try that. So I think this is a problem of lack of memory thrown from the nifti reader. Solution would be to either to shrink your data dimensions or get more of those expensive golden memory sticks. :slight_smile:

okay, thanks for testing!
The server where I wanted to open the file has 1TB of RAM - if RAM is really the problem here, then the Nifty reader is really wasteful with resources… :joy:

I simply converted the file to something else, like MHD, which works just fine, also with that size.

Interesting! I just tried lowering the dimensions and it worked fine…that is what made me suspect memory in the first place. Glad switching formats did the trick. If you end up figuring out what caused the crash, definitely share it here :slightly_smiling_face:

1 Like