Duke-UNC Brain Imaging and Analysis Center
BIAC Forums | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password   Forgot your Password?
 All Forums
 Support Forums
 Analysis Software Support
 Resample DTI to NIFTI
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

davis
Starting Member

USA
6 Posts

Posted - Apr 20 2007 :  12:19:19 PM  Show Profile  Visit davis's Homepage  Reply with Quote


My problem:

- DTI is collected in 128x128, exported from the scanner in 256x256.
- We use a script to create analyze files that resample back to 128.
- I want to start using FSL, which requires Nifti format. I know how to go from DICOM to Nifti (without resampling), but not analyze to Nifti.

Possible solutions:
- create Nifti files from DICOM that resample back to 128.
- convert from Nifti to Analyze.


Does anyone know how to do this?

syam.gadde
BIAC Staff

USA
421 Posts

Posted - Apr 20 2007 :  12:34:00 PM  Show Profile  Reply with Quote
As far as I know, FSL can use Analyze format, however if the data is not in the exact orientation FSL assumes, there may be unfortunate flips due to the lack of orientation information in the Analyze header.

I would definitely go from DICOM to NIFTI to retain the orientation information. There are several tools to do this, including our tools (you can use dicom2bxh followed by bxh2analyze with the "--nii -s -b" options) or you can use mri_convert from Freesurfer, etc.

Please also read:

http://www.fmrib.ox.ac.uk/fslfaq/#general_radiologicaldef

If you want to use "neurologically" ordered data, there are ways to fool FSL into doing the right thing, which we can go into in further detail if you desire.
Go to Top of Page

syam.gadde
BIAC Staff

USA
421 Posts

Posted - Apr 20 2007 :  12:38:19 PM  Show Profile  Reply with Quote
Sorry I neglected your need to resample.

Can your script be modified to create NIFTI headers?
NIFTI is an "extension" of Analyze, and most of the
header information should remain the same.
Go to Top of Page

davis
Starting Member

USA
6 Posts

Posted - Apr 20 2007 :  2:07:15 PM  Show Profile  Visit davis's Homepage  Reply with Quote

I've been trying to use this script to resample:

http://www.duke.edu/~swd4/resampledti.m

and i've tried (and failed) to modify it to create Nifti. I'm not sure what the corresponding command to <spm_hwrite> would be for the format i want.

Go to Top of Page

josh.bizzell
BIAC Staff

USA
118 Posts

Posted - Apr 20 2007 :  2:23:01 PM  Show Profile  Reply with Quote
There are two ways I can think of to write NIFTI headers for the data in that code, which I believe I wrote :)

1. There is a writemr command, so a BXH header must be written. You can use bxh2analyze with the flags Syam described above to create the NIFTI headers. Delete the "spm_hwrite" line. If you choose this method, you'll want to do more than just "createmrstruct" to create your image structure. You'll want to add as much information as you have to the .info field; more importantly the "dimensions" fields (spacing, direction, etc...), before you do "writemr".

2. If you have SPM5 installed, figure out how to use the "create" function, which creates NIFTI headers for SPM5 (like "spm_hwrite" created Analyze headers). I haven't worked with this function, so I'm not sure how easy or hard that would be.

-Josh
Go to Top of Page

smhayes
New Member

21 Posts

Posted - Jul 13 2007 :  11:00:46 AM  Show Profile  Reply with Quote
I have diffusion data collected off the 3T, which comes with a bxh file, e.g., (series006.bxh). I run
>bxh2analyze --niftihdr -s -v series006.bxh dif
and dif.bxh, dif.hdr, dif.img are output. When I attempt to open in fslview, I receive the following message:

** ERROR: nifti_image_read(/mnt/c/EmoBindY.01/Anat/33264/series006/dif): bad data file
** ERROR: nifti_image_open(/mnt/c/EmoBindY.01/Anat/33264/series006/dif): bad header info
Error: failed to open file /mnt/c/EmoBindY.01/Anat/33264/series006/dif
Failed to open file /mnt/c/EmoBindY.01/Anat/33264/series006/dif

I thought I wouldn't need to run dicom2bxh since I already have a .bxh file, and also that I don't need to run the resample scripts referred to in this thread because the scan parameters were 128X128 and the associated .bxh file reports the matrix to be 128X128. I'd prefer to use the biac tools for conversion to nifti since I'm using them for my functional and SPGRs. Any suggestions would be appreciated.

Thanks,
Scott
Go to Top of Page

syam.gadde
BIAC Staff

USA
421 Posts

Posted - Jul 13 2007 :  11:24:52 AM  Show Profile  Reply with Quote
Apparently bxh2analyze doesn't write out 4-D data, where the fourth dimension is the diffusion direction, correctly. Is it OK for now to get them as individual volumes until that is fixed? i.e. don't use the -v option:

bxh2analyze --niftihdr -s series006.bxh dif

If you want to concatenate them after the fact, you could use avwmerge from FSL:

avwmerge -t mergeddif dif*.hdr
Go to Top of Page

smhayes
New Member

21 Posts

Posted - Jul 13 2007 :  12:09:59 PM  Show Profile  Reply with Quote
>bxh2analyze --niftihdr -s series006.bxh dif
outputs 16 volumes, although I only collect in 15 directions. What's the first image? It looks like a low-res T-2 weighted image... Images 2-16 are the diffusion maps collected in various directions...
Go to Top of Page

josh.bizzell
BIAC Staff

USA
118 Posts

Posted - Jul 13 2007 :  12:12:55 PM  Show Profile  Reply with Quote
The first image is the B0 image. Basically, as you observed, it's a T2 image with no gradients turned on.
Go to Top of Page

smhayes
New Member

21 Posts

Posted - Jul 13 2007 :  2:28:06 PM  Show Profile  Reply with Quote
OK, so conversion to NIFTI
Go to Top of Page

smhayes
New Member

21 Posts

Posted - Jul 13 2007 :  2:32:33 PM  Show Profile  Reply with Quote
Conversion to NIFTI as you suggested worked. How do I find the encoding direction for each volume (bvecs) and bvals? I see a matrix in the hdr., which may be the encoding directions, but I wanted to confirm that and also see where to find the bvals.
Go to Top of Page

josh.bizzell
BIAC Staff

USA
118 Posts

Posted - Jul 13 2007 :  2:35:54 PM  Show Profile  Reply with Quote
If this is the typical BIAC 15 direction DTI, the b-value is usually 800. To be sure, you'd need to ask the MR technologist. For the gradient directions, the following work:

DWMRI_gradient_0000:=0 0 0
DWMRI_gradient_0001:=-0.216001983700 0.898615365314 0.381881615504
DWMRI_gradient_0002:=0.444561363553 0.418726663881 0.791854263732
DWMRI_gradient_0003:=0.635186145240 0.770065881729 -0.059473512527
DWMRI_gradient_0004:=-0.500548727571 0.192538217024 0.844026069688
DWMRI_gradient_0005:=0.221229771469 -0.531169628316 -0.817872981685
DWMRI_gradient_0006:=0.891941312897 -0.079142510044 -0.445170930601
DWMRI_gradient_0007:=0.169315707509 -0.513429353508 0.841262438331
DWMRI_gradient_0008:=0.263965919566 0.440254059158 -0.858194824444
DWMRI_gradient_0009:=-0.598524035730 -0.006919955250 -0.801074960833
DWMRI_gradient_0010:=0.899631198936 -0.223429384229 0.375157321885
DWMRI_gradient_0011:=-0.985305483557 0.166404497880 0.038505157549
DWMRI_gradient_0012:=-0.627905121857 -0.627079786181 0.460983838881
DWMRI_gradient_0013:=0.350119335865 -0.936470382954 0.020968369105
DWMRI_gradient_0014:=-0.527048413266 -0.773124394001 -0.352843650184
DWMRI_gradient_0015:=-0.420616988873 0.804160710609 -0.420008214424
Go to Top of Page

smhayes
New Member

21 Posts

Posted - Jul 13 2007 :  2:43:34 PM  Show Profile  Reply with Quote
OK, those values are similar to the ones in my hdr file (below), although the signs are different in several locations. So I should leave the Bo map in w/ the rest of the images? When I concatenated, I excluded the Bo map.
<value>0 0 0</value>
<value>0.2160019837 -0.898615365314 0.381881615504</value>
<value>-0.444561363553 -0.418726663881 0.791854263732</value>
<value>-0.63518614524 -0.770065881729 -0.059473512527</value>
<value>0.500548727571 -0.192538217024 0.844026069688</value>
<value>-0.221229771469 0.531169628316 -0.817872981685</value>
<value>-0.891941312897 0.079142510044 -0.445170930601</value>
<value>-0.169315707509 0.513429353508 0.841262438331</value>
<value>-0.263965919566 -0.440254059158 -0.858194824444</value>
<value>0.59852403573 0.00691995525 -0.801074960833</value>
<value>-0.899631198936 0.223429384229 0.375157321885</value>
<value>0.985305483557 -0.16640449788 0.038505157549</value>
<value>0.627905121857 0.627079786181 0.460983838881</value>
<value>-0.350119335865 0.936470382954 0.020968369105</value>
<value>0.527048413266 0.773124394001 -0.352843650184</value>
<value>0.420616988873 -0.804160710609 -0.420008214424</value>
Go to Top of Page

josh.bizzell
BIAC Staff

USA
118 Posts

Posted - Jul 13 2007 :  2:52:32 PM  Show Profile  Reply with Quote
It depends on the DTI analysis program you're using. The signs could be different because when I convert the data, I don't use direction information; I just use the raw data. Since NIFTI includes directionality information, your DTI analysis tool may be smart enough to figure out the correct gradient direction relative to the image orientation based on the header and this matrix.

As far as including or excluding the B0 image, again, it depends on the DTI software you're using. Most of the tools I've used require the B0 map. Hopefully, there is some type of documentation available for your software that will let you know if you need it or not.

-Josh
Go to Top of Page

syam.gadde
BIAC Staff

USA
421 Posts

Posted - Jul 13 2007 :  3:26:33 PM  Show Profile  Reply with Quote
This has always been confusing to me, but after long discussions with people in the know and as suggested by developers at other sites, we decided to place the hard-coded diffusion directions as listed by GE (as-is) in the .bxh header (in the <value> elements you showed), but with an additional <measurementframe> element that can be used to map these direction vectors into scanner coordinate space (RAS). The measurement frame is in the form:
<measurementframe>
<vector>Rx Ax Sx</vector>
<vector>Ry Ay Sy</vector>
<vector>Rz Az Sz</vector>
</measurementframe>
And you can transform each diffusion direction vector (Dx,Dy,Dz) into an RAS vector through matrix multiplication:
[Rx Ry Rz] [Dx]   [Dr]
[Ax Ay Az] [Dy] = [Da]
[Sx Sy Sz] [Dz]   [Ds]
At least that's the idea. You can look at Gordon Kindlmann's explanations http://wiki.na-mic.org/Wiki/index.php/NAMIC_Wiki:DTI:Nrrd_format for the rationale and inspiration.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
BIAC Forums © 2000-2010 Brain Imaging and Analysis Center Go To Top Of Page
This page was generated in 0.41 seconds. Snitz Forums 2000