You must be logged in to post Login Register


Lost Your Password?

Search Forums:


 






Wildcard Usage:
*    matches any number of characters
%    matches exactly one character

DTK / TrackVis do not read NIFTI correctly (flip both L-R and A-P directions)

UserPost

1:25 pm
January 11, 2011


Bryce

Member

posts 9

Hi,

 

I really like TrackVis for visualization of tractography, but I have found an orientation problem.  When loading DWI DICOM images from a GE scanner and processing them using DTK, the resulting tracks and background image (say dti_b0.nii) display correctly in TrackVis (Left is patients Left, Anterior is patients Anterior, etc.).

However, if I convert the DICOM images to NIfTI format first, using AFNI or DCM2NII, I find that the tractography is identical, but TrackVis has the subjects Left-Right flipped, and also Anteroir-Posterior is flipped.  I have included a screenshot from TrackVis, with orientation of the person looking "forward" (towards the viewer) below.

TrackVis: L-R and A-P flip

As can be seen above, the front of the subject is labelled "Posterior" and the side of the head closest to the viewer is labelled "Left", which are both wrong.  The b0 slice overlay in the bottom left window also shows A-P backwards.

Iit seems that TrackVis and/or DTK do not read Left-Right and Anterior-Posterior directions correctly from NIfTI files.  The problem I am experiencing seems very similar to that reported here in which it is suggested that the NIfTI files do not contain orientation information.  I have used AFNI to generate .nii files, and I trust that it does so correctly — AFNI is developed at NIH, and the same people developed the NIfTI format. 

Any hope to investigate this problem?  I can upload the DICOM and NIfTI versions of this data if it helps.  Thanks!

Bryce

3:47 pm
January 12, 2011


Ruopeng

Admin

posts 406

Hi,

Thanks for the feedback. I will need to play a little bit with AFNI or DCM2NII to see if I can replicate the same problem. I'm not familiar with those tools. What I found strange is the dti_b0.nii processed by DTK is also a standard nfiti file. If trackvis can display it correctly, it should also display other standard nifti files correctly (if they don't mess up the header). I tried conversion tools in Freesurfer and FSL. They're consistent with TrackVis/DTK.

Best,

Ruopeng

9:25 pm
January 12, 2011


Bryce

Member

posts 9

Hi Ruopeng,

Thanks for your reply.  Perhaps it would be best to validate with NIFTI datasets created by tools developed by the same people who developed the NIFTI standard, such as AFNI.  AFNI writes both the q-form and s-form to the NIFTI header.

AFNI runs on Linux systems best (and Mac), but not Windows.  You can download AFNI from the NIH here. Generally you only need to un-tar the archive, and put the files in a directory on your path.  If it does not run, you may need to install additional packages (installation instructions here).

I can upload a DTI dataset in AFNI format if you wish.  Converting it to NIfTI is a simple: 3dAFNItoNIFTI command. 

Bryce

 

 

10:41 pm
January 13, 2011


Bryce

Member

posts 9

Post edited 6:10 pm – February 18, 2011 by Bryce


A little follow up: using the MATLAB NIfTI Toolbox by Jimmy Shen to read/write .nii files in MATLAB sets the sform and qform codes to 0 once orientation transformations in the NIFTI header are applied to the image data and stored as a 3D matrix in MATLAB.  The result is that voxel (i,j,k) is aligned to physical space (x,y,z) with RAS (neurological) convention. 

 

EDIT: In the paragraph below I originally stated that Jimmy's MATLAB NIfTI toolbox saved NIfTI datasets with qform_code = sform_code = 0.  This is INCORRECT.  Jimmy's program saves NIfTI datasets with sform_code = 1, and valid corresponding sform matrix.  I have corrected the paragraph below, and added an additional post to this thread.  Apologies to Jimmy and other for any confusion caused.

 

Many programs (e.g. FSL), and TrackVis/DTK I believe, maintain backwards compatibility with Analyze 7.5 orientation (LAS) data by assuming "all Analyze files and any NIfTI file which did not specify either qform or sform, had a reversed left-right orientation" (see here in relation to FSL).

 

The troubles I experienced loading .nii files written by Jimmy's toolbox into TrackVis may be due to TrackVis reading only the qform_code and seeing that it is zero.  I am continuing this question in a new post to this thread below.

 

12:14 pm
January 20, 2011


Ruopeng

Admin

posts 406

Thanks for the info, Bryce! That explains it. In any case, I think header information should not be crippled during data processing.

Ruopeng

12:48 pm
February 18, 2011


Jimmy

New Member

posts 1

Post edited 5:52 pm – February 18, 2011 by Jimmy


Hi Bryce:

First of all, my MATLAB tools never save any file with sform = qform = 0. When you see that sform = qform = 0 in the structure that is loaded by load_nii.m, it only means that the affine matrix has been properly interpreted. As a matter of fact, the file written by save_nii.m is always a NIfTI file with sform = 1 and qform = 0, and you can always check the real header information stored in any NIfTI (ANALYZE) file by using load_untouch_nii.m. In other words, you can never save your data to a NIfTI file with sform = qform = 0. If you want to save your data to an ANALYZE format, you can do so by using save_untouch_nii.m. In that case, there is neither sform nor qform in the ANALYZE header.

Second, the link that you mentioned is for FSL only. FSL assumes that all ANALYZE files are in radiological convention (LAS). On the other hand, many other software assume that ANALYZE files are in neurological convention (RAS). Because there is really no orientation information stored in ANALYZE header, the laterality of an ANALYZE file is all based on the assumption. Please see more detail in the following link:

http://www.rotman-baycrest.on

1:20 pm
February 18, 2011


Bryce

Member

posts 9

Dear Jimmy: my apologies for communicating misinformation about your program, that was, of course, completely unintended.  Thank-you for sharing more information about how your MATLAB toolbox works.  I have corrected my post above and am continuing this threads original topic below.

1:32 pm
February 18, 2011


Bryce

Member

posts 9

Hi Ruopeng: With regards to this threads original topic of Left-Right flipping occuring when some NIfTI datasets are loaded, I'm hoping you can answer a few questions related to TrackVis/DTK operation concerning NIfTI files. 

Which transformation (sform_code or qform_code) is used by default?

If the default transform doesn't exist, is the alternative transform checked?

In the case that neither transformation exists (sform_code = qform_code = 0), what assumption does DTK/TrackVis make regarding Left-Right orientation?  Is the data assumed LAS?  Is any flipping performed?

 

Thanks!  If I can understand a little more about TrackVis/DTK, hopefully I can resolve the original Left-Right flipping problem I experienced.

10:05 pm
February 18, 2011


javaduke

Member

posts 10

I had the same problem,

but you could load the ROI data from scene file,

It would be ok.

 

The problem is strange, i also want to fix it.

3:23 pm
February 22, 2011


Ruopeng

Admin

posts 406

Hi Bryce,

TrackVis/DTK use the nifti lib released by nih (http://niftilib.sourceforge.net/) to read/write nifti file, with my own wrapper. It should handle s/q-form automatically. If no sform or qform provided, it will assume data is saved in LPS order (which is the Simense standard, I believe).

It appears this issue is not just a single case. I'm going to look into it closely as soon as I have a chance.

Best,

Ruopeng

6:19 am
June 17, 2011


romain

New Member

posts 2

Hello,

 

I thing I have the same probleme with some nifti file that are baddly read in trackvis.

I used to convert my dicom files with spm and it was ok.

I now test nifti comming from mrtrix conversion and there is a problem

The header is different but it is correct in the different viewer I test except in trackvis

where LR et AP are inverted.

 

Did you had time to look at the nifti read ?

 

Thanks for your help (and for this nice software)

 

Romain

 

7:25 am
June 17, 2011


romain

New Member

posts 2

Just to precise

When I load the dwi data in nifti in the dtk interface

I get the message "can not automaticaly retrive image orientation info. Please set it manually

11:40 am
June 17, 2011


Ruopeng

Admin

posts 406

Romain,

I think the message says it all. It could not find sufficeint coordiinate information from the image header. Meaning the information is missing.  Then the program just assumes it is LPS which could be wrong.

Ruopeng

1:23 pm
July 30, 2011


Francie

New Member

posts 2

I am having the same problem here.  It seems the files are inverted where left and right are correct but anterior posterior are reversed.

The Trackvis images  load with the posterior of the DTI track image to the front of the screen and the label A for anterior.  Left is on the right of the screen. 

 

does anyone have a method to fix this?

 

Francie

11:42 am
August 1, 2011


Ruopeng

Admin

posts 406

What is format of the data you feed into DTK? Dicom? Nifti?

Ruopeng

1:01 pm
August 1, 2011


Francie

New Member

posts 2

Just found out we are using an in house soft ware to transpose camino to trackvis.

Will let you know if we make progress.  Will try your data processing stream on the data we collected and see if that fixes things.

Francie