Flipped NIFTI image compared to original Nrrd File

Operating system:
Slicer version:
Expected behavior:
Actual behavior:

Hello Slicer Experts,

I had done some initial processing of my DTI data in Slicer.

Now, I have converted the files to nifti via DWIConvert so that I can use some FSL tools.

When I load the nifti versus the .nrrd in Slicer, I notice the nifti file is flipped compared to the nrrd.

Indeed, when I look at the headers of both files, one says left-posterior-superior and the other says right-superior-anterior. How can I rectify this?

Thank you for your help!

Emily

Hi Emily -

Is there any chance you can share a dataset that exhibits this issue along with the specific tools and steps that lead to the problem? Maybe you could reproduce the issue using the DWI dataset that is available in Slicer’s SampleData module? Or maybe a scan of a phantom?

There are lots of ways to flip the image data, but correctly transforming the gradients can be tricky and maybe there’s an issue with the converter.

Best,
Steve

Hi Steve,

Thanks for the reply. I am attaching my .nrrd file that I have been using in Slicer.

Than I used the following command via Slicer to convert the .nrrd file to nifti. Looks like I cannot upload these types of files. Could I perhaps email them to you?

The command:

DWIConvert --allowLossyConversion --conversionMode NrrdToFSL --inputVolume X.nrrd --outputVolume X.nii --output BVectors x.bvec --output BValues X.bval

I appreciate any thoughts you have. I am not 100% sure if I have a problem or not.

Thanks,

Emily

To share images, upload to your cloud storage account (Dropbox, OneDrive, Google drive) and copy-paste the link here.

Hi Steve,

Here is the link to the data.

Thank you so much!

Emily

[https://drive.google.com/open?id=0BxJP5A6fFyuULVRjR19JSl9CZDA]

Thank you very much!

Hi Emily -

Thanks for sharing the data - I was able to load it and work with it but wasn’t able to replicate the flipping issue you reported.

The command line I tested (below) was pretty much the same as yours. I tried converting the nrrd you sent and when I loaded the resulting nii file there was no flipping. Then I also downloaded the nii file you provided and again I didn’t see any flipping compared to the nrrd.

Can you doublecheck that when you load the nii and nrrd you uploaded into Slicer they don’t match?

I was using the nightly build from May 29 2017 on a mac. If you were using the 4.6.2 version you might try a more recent nightly although I don’t think this code has changed much.

If you loaded and re-saved the nii file in other software then perhaps other things happened (nifti can be a tricky format which is why we try to avoid using it).

-Steve

./Contents/lib/Slicer-4.7/cli-modules/DWIConvert --conversionMode NrrdToFSL --inputVolume /tmp/ELS_002_dwi-xc_QCed_permute_Ed_epi.nrrd --outputVolume /tmp/ELS_002_dwi-xc_QCed_permute_Ed_epi-cli.nii --outputBValues /tmp/b.vals --outputBVectors /tmp/b.vecs

Best,
Steve

Hi Steve,

Thanks so much!!!

I am noticing that the nrrd file and the nifti file look the same on Slicer. However, when I load the nifti file in the fsl viewer, things look a bit different. It may just be a matter of differences in how Slicer and FSL present the data.

I had initially (not the files I sent you) converted the nrrd file from a type unsigned short to just a short and then converted the file to nifti. In that process, the nifti file was flipped compared to the nrrd file in Slicer. When I left out the conversion to short from unsigned short, I did not see the flipping issue (the files I sent you).

Thanks,

Emily

Thanks for doublechecking Emily - there are a lot of issue with coordinates
that can pop up when going between packages and formats. This wiki page
might help but also check the display options for other software (some use
"neurological" convention while Slicer strictly uses "radiological"
convention for display).

https://www.slicer.org/wiki/Coordinate_systems

Hi Steve and Andras,

I have the same problem discussed in this conversation. Yet, all the the steps I’m taking are done via slicer 5.6.1 (creating lesion map, exporting lesion map into nifti format and viewing the lesion map .nii separately).

Here is the link to my data:

The problem:

  1. When I open the scene / .nrrd file, the lesion appears in the correct location.
  2. Note the lesion is more to the right superiorly and then moves to the middle of the brain in more inferior slices.
  3. I then export the lesion map in a .nii format
  4. when I open the .nii file (in slicer) the lesion is to the left in the more superior slices and moves to the middle in more inferior slices.

Why is this happening and how can I fix it?

Thank you in advance,

Ettie

@ReNeu - You’ll need to change the permissions on the google drive so that others can access it.

Also, please try the latest versions of Slicer to confirm there is still an issue. If it is, please describe exactly what steps you take (add screenshots to clarify as needed).

Hi Steve,

Thanks for your prompt input. I’ve now installed 3D Slicer 5.6.2.

My steps:

  1. Open the saved scene in slicer
  2. Inspect the lesion map + confirm it’s accurate to the lesion (1st image)
  3. Save the lesion as .nii file in a different folder (2nd image)
  4. Close the scene
  5. Open the newly saved lesion map
  6. The lesion map is now a mirror vision of the original lesion map

Here is the link for the data for testing (permission granted): CT subj38 testing - Google Drive


Thanks for sharing - can you do one more test to see if you see this issue when saving to nrrd?

If you’ve looked you probably saw that the nifti format is not very popular among Slicer developers due to a long history of issues (the standard itself defines multiple, possibly contradictory, ways of encoding geometry information and many other software packages have inconsistent or buggy ways of interpreting this data, etc).

So, while we’ll probably be able to explain why this data doesn’t work, it’s likely something intrinsic to nifti. Or it could be a regression in the Slicer/ITK nifti pipeline which has been edited in the last few years to try to better handle issues with the format. Knowing if nrrd works will help whoever does the next level investigation.