Print

Print


Dear John,

Works like a treat, thanks a lot!

The y-image I already had generated in the DARTEL template creation
procedure, so I could skip that step, and the final transformation
getting V from the individual's brain and transforming it to voxel
coordinates ( subjvox = [mm 1] / V.mat'; ) was also very simple.

Thanks again!
Martin






2012/2/29 Will Moore <[log in to unmask]>:
> Thanks very much for the explanation and code!
>
> I've been working on reverse mapping coordinates from the literature into
> subjects' native space, and this was a huge help.
>
> In the second to last bit of code:
>
> % I'll assume that you have a Template_6_2mni.mat, which you should have
> % if you used the normalise to MNI space option of a recent update of SPM8.
>
> tmp = load('Template_6_2mni.mat');
> M1 = tmp.mni.affine; % Mapping from voxels in Template to MNI space
> vox = M1\[tal'; 1];  % returns for me the error: Undefined function or
> variable 'tal'.
>
>
> I think tal is here in place of mni (the variable coordinates were stored
> in), but if you change it to:
>
> vox = M1\[mni'; 1];  % it works like a charm!
>
>
> Please forgive me if I am mistaken about 'tal' or if this is
> nit-picky/pedantic, but it took me longer than I'd like to admit to realize
> how to fix it, and I'd hate to see anyone else deprived of this handy code's
> utility.
>
>
> William E. Moore III, M.S.
> Developmental Social Neuroscience Laboratory
> 470 Straub Hall
> 1227 University of Oregon
> Eugene, OR 97401
> (919) 619-2309
>
> On , 2012Feb28, at 8:30 am, John Ashburner wrote:
>
> I'm using DARTEL to normalize my functional images. For that purpose,
>
> I transform the results to MNI space.
>
>
> Now I have a peak activation in my group results and would like to
>
> know approximately where the coordinate lies in individual functional
>
> space. This was quite simple in unified segmentation, but it seems to
>
> involve too many transformations to carry this out in a good way using
>
> DARTEL.
>
>
> Projecting MNI-space results back on to the original subject's scan
> seems to be getting popular.  I'll try to make this much easier to do
> in the next SPM release.
>
>
>
> I used affine transformation to transform the coordinate from MNI to
>
> template space, then I was planning to continue to create an image
>
> with that one point and transform that back, but now I realize how
>
> many transformations it would be:
>
> MNI -> Template -> individual anatomical (size like template) ->
>
> individual anatomical -> functional.
>
>
> It should be a bit simpler than this.  The way that deformation fields
> are stored (as y_*.nii files) involves a mapping from voxels in one
> image (eg the template) to mm coordinates (eg in the subject).  To get
> from mm to voxels in some image, you just need to multiply these
> coordinates by the inverse of the voxel-to-world mapping in the header
> of that image.  This mapping should work for all (accurately)
> coregistered images from a particular subject.  This eliminates the
> "individual anatomical -> functional" part of the chain.
>
> The "individual anatomical (size like template) -> individual
> anatomical" part should automatically be dealt with by the software.
> This can be achieved because the "imported" data (size like template)
> also encodes how to map to individual space.
>
> This just leaves "MNI -> Template -> functional".
>
> Obtaining a mapping from "Template -> functional" may be achieved by
> generating a deformation field from the Dartel flow field.  This can
> be done via the Deformations Utility:
>
> Composition
> . DARTEL flow
> . . Flow Field      select the u_*.nii file
> . . Forward/Backward    Backward
> . . Time Steps     64
> Save as      whatever you'd like to call it.
> Apply to      nothing needed
> etc
>
>
> The rest will need a bit of MATLAB code....
>
>
> mni = [x y z]; % Your MNI coordinate
>
> P = ['y_blah.nii,1,1'; 'y_blah.nii,1,2'; 'y_blah.nii,1,3']; % The
> deformation
> V = spm_vol(P);
>
> % I'll assume that you have a Template_6_2mni.mat, which you should have
> % if you used the normalise to MNI space option of a recent update of SPM8.
>
> tmp = load('Template_6_2mni.mat');
> M1 = tmp.mni.affine; % Mapping from voxels in Template to MNI space
> vox = M1\[tal'; 1];
>
> mm = [...
>        spm_sample_vol(V(1),vox(1),vox(2),vox(3),1)...
>        spm_sample_vol(V(2),vox(1),vox(2),vox(3),1)...
>        spm_sample_vol(V(3),vox(1),vox(2),vox(3),1)]
>
>
>
> You can use Display, and move the cursor to this mm coordinate to
> figure out the appropriate location.
>
>
>
> Is there any good way to do this transformation more directly, without
>
> using the step of creating an image in between? Maybe some code
>
> snippets I could use or a hint which lines of code carry out the
>
> inverse warping?
>
>
> I hope the stuff above works OK for you.  As I haven't thoroughly
> tested it, I'd suggest checking it with a few coordinates to make sure
> its OK.  The entire risk as
> to the quality and performance of the code snippets is with you
> (trying to cover my back in case anyone intends to use the snippet for
> pre-surgical planning etc).
>
> Best regards,
> -John
>
>