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

nifti rotations and gradient table

UserPost

5:33 pm
March 19, 2010


pmmacey

UCLA

Member

posts 5

Hi

Great, software, and 0.6 looks like a very useful update.

I'm wondering how best to manage the gradient table for nifti files that include a rotation. As far as I can tell (at least in 0.5), the nifti rotations are ignored, which means that the vectors in the gradient table have to be "unrotated" to match the imported DTI images. So I guess a request would be to support nifti rotations, but in the meantime, is there a way I can use the patient orientation parameter flag (or some other means) to correct the gradient table, and/or adjust the DTI images?

 

I've got some details here using SPM code that show what's going on:

% Read nifti header information (in SPM format)

V = spm_vol( niftiFilename );

% Read translations/rotations/scaling/shears in nifti header; the rotations are the 4th, 5th and 6th elements of prm

prm = spm_imatrix(V.mat);

If prm (4:6) are 0, there is no problem. However, if prm(4:6) are not 0, that means the nifti header indicates rotations, but these appear not to be accounted for when the data are read by dti_recon. That means the DTI images might be at a funy angle, which is not the end of the world, but the vectors in the gradient table have to have these rotations "removed" otherwise they will be wrong. FYI, here's how I do it in SPM:

% Create -ve rotation matrix

Mrot = spm_matrix([0 0 0 -prm(4:6) 1 1 1]);

% Given vectors in variable "bvecs" for each image

for i = 1:size(bvecs,1)

bvecs_norot(i,:) = (Mrot(1:3,1:3)*bvecs(i,:)')';

end

 

Best wishes,

Paul

 

 

12:45 pm
March 21, 2010


Ruopeng

Admin

posts 406

Hi Paul,

I'm not sure I completely understand what the "uncorrect" process you mean here. As far as I know, except Siemens, all other manufacturers correct their gradient vectors on the fly. For example, if you apply (1,0,0) gradient, and your image space has a rotation angle, the scanner will adjust the gradient so that it will be (1,0,0) in the local image space, so the in the magnet space, the real gradient applied could be something like (0.9, 0.1, 0). But when you calculate diffusion tensor, you still need to use (1,0,0) because it is the effective vector in the image space. Are you saying you want to go from (0.9, 0,1, 0) back to (1, 0, 0) based on the rotation information in the nifti file? Why don't you just provide the original table? Is it because it is not available?

Best,

Ruopeng

7:09 pm
March 24, 2010


pmmacey

UCLA

Member

posts 5

Post edited 11:26 pm – March 24, 2010 by pmmacey


Hi Ruopeng

Sorry I was unclear.

The gradient tables are read from the scanner without problem. The issue is one of reading in the nifti files, and accounting for the rotations in the affine transformation matrix in the nifti header.

Let's say I rotate my DTI images to better match the template space, or because the subject was slightly tilted. I can perform this rotation by changing the parameters in the nifti header. In other programs (SPM, MRIcron), the image will then be displayed rotated , but it appears that DT does not read/apply those rotations.

The issue with the gradient tables is that we need to account for the rotations not being read in, so it is a secondary problem.

I hope that makes sense!

Best wishes,

Paul

 

 

12:39 pm
March 26, 2010


Ruopeng

Admin

posts 406

Hi Paul,

Are you dealing with Siemens data? Have you checked "Oblique angle correction" if it is Siemens DTI data? Sorry I think I maybe still don't quite get it. I don't know much about SPM but doesn't MRIcon display images locallly? i.e., it doesn't reslice image. I understand you might have a rotation angle in the nifti header, we have such kind of data all the time. But Diffusion Toolkit and TrackVis process DTI data in its local space and the gradients are also applied locally (except Siemens DTI), why do we need to correct them? If you want to align the data on to other space. That's a different story. You will need to register DTI to your target space.

Ruopeng

9:14 pm
March 29, 2010


pmmacey

UCLA

Member

posts 5

Post edited 1:17 am – March 30, 2010 by pmmacey


Hi Ruopeng

I take it that by "local space" you mean that DT reads in the

slice-by-slice data, and accounts for voxel sizes and origin shifts as

read from the nifti header. If so, that makes sense to me, and I can work with that.

I think there are times when we want to align our data to another space. Once scenario is motion correcting two series from the same subject. If there is movement between the series, then we can rotate/shift the second series to the spaced of the first, and combine the data from both series when reading into DT. The problem arises if the motion correction is done by changing the nifti header parameters to do the shift/rotations (as with SPM), as opposed to reslicing. We could reslice the data, but it would be nice to avoid reslicing because of partial volume effects and so on.

MRIcron can display without or without reorienting (it's an option under Preferences – the option takes effect after restarting the software).

I think the question of reorienting gradients is secondary and probably not worth bothering about – we read them in from Siemens without problem, and can use them with DT as long as we make sure they are in local space (i.e., not reoriented). As long as I have the correct understanding of how DT reads the data in local space, then I can figure a way to register the DTI data to different spaces when needed.

Thanks,

Paul

 

 

12:34 pm
March 30, 2010


Ruopeng

Admin

posts 406

Hi Paul,

You're correct. DTK reads in data slice by slice without reslicing it, regardless what rotation information in the header. I now understand a little better on how you process the data. But I'm still a little puzzled at how you can combine two series without reslicing one of them. Eventually your output from DTK will be one volume. At some point you will have to reslice the data, no?

BTW, just to clarify, DTK as well as TrackVis (.trk file) do not account origin shifts in the raw data. Their coordinates always originate from (0,0,0), so as we call it "local coordinates". The coordinate is basically (Column, Row, Slice) scaled by voxel sizes.

Best,

Ruopeng

2:00 pm
April 6, 2010


pmmacey

UCLA

Member

posts 5

Hi again

Thats very helpful. And yes you're right, I will need to reslice if I want to combine series. And the "local coordinates" is also clear to me now.

Time to get back to analyzing data!

Best wishes,

Paul