Dear John,
I am trying to run the two matlab functions that you posted previously to
write the deformation fields to an image. However in the Function
dets_from_sn3d it keeps crashing at the line below with the subsequent
error message. I know others have used this function ,but I'm not sure what
I'm doing wrong.
Many thanks in advance,
Xavier
load(deblank(matname))
???? Input argument "matname" is undefined
Error in ===> /home/sphadpt/matlab/dets_from.m
On line 8 ===> load(deblank(matname))
At 10:16 06/01/00 +0000, you wrote:
>| and a happy new year. I hope everyone feels Y2K-compliant. We would like
to ask
>| for guidance about some aspects of affine (linear) normalization.
>| We are in the middle of analyzing a sizable number of structural MRIs
which we
>| have segmented (using a combination of spm-based and other routines) and
>| normalized using spm99b. During the normalization they have been
resampled from
>| 0.975x0.975x1.5mm voxel size to 1mm isotropic. Normalization was by
12-parameter
>| affine and the default (7x6x7 basis functions etc.) nonlinear procedure.
What we
>| want to do now is to apply masks in Talairach space to the normalized
data, do
>| some kind of voxel-counting inside those masks, and then calculate the
volume in
>| original space corresponding to the number of voxels counted in the
normalized
>| data.
>
>It may also be worth your while taking a look at:
> http://www.mailbase.ac.uk/lists/spm/1999-10/0099.html
>
>The routines attached in the email are for writing out images of volume
changes due
>to the affine and nonlinear spatial normalisation. There are actually two
attachments
>here. The first one begins with the line that says:
> function dets_from_sn3d(matname, vox,bb)
>whereas the second starts with the line:
> function write_dets(V)
>
>
>| Our reasoning has been as follows:
>| 1) Since the nonlinear part of the normalization cannot be easily (or at
all?)
>| inverted, we want to redo the normalization using just the affine part,
using
>| the _sn3d.mat files generated before (i.e. with the nonlinear part
switched on)
>| Question: From my understanding of the algorithm, the affine
transformation
>| contained in these files should be the same as the one that would have
been
>| generated if the nonlinear part of the normalization had been switched
off.
>| Correct?
>
>This is correct.
>
>| Question: If that is correct, we'd like to save computational overhead
by using
>| the affine
>| matrix that we already have. Is there a way to modify the _sn3d.mat
files so
>| that only the linear normalization is applied?
>
>This is possible by something like:
>
> P = spm_get(1,'*_sn3d.mat');
> load(P);
> Transform = [];
> Dims(2,:) = [0 0 0];
> save(P,'mgc','Affine','Dims','MG','MF','Transform','-v4');
>
>
>| 2) From affine geometry, we would expect that the (absolute of the)
determinant
>| of the affine transformation matrix gives the volume change under the
transform.
>| Correct?
>
>This is correct. The sign of the determinant changes if the image is
flipped
>- hence the use of the absolute determinant.
>
>
>| So we should be able to divide the total volume of the voxels
counted
>| in normalized space by this number to get the corresponding volume in the
>| original space.
>
>Multiply or divide, depending on how you define the affine transformation.
The
>Affine matrix maps from normalised image space to original space, so you
>would multiply (and the units would relate to volume changes in voxels).
>The matrix displayed in the PostScript printout maps from original space to
>normalised image space, so you would divide (units in relative mm^3).
>
>| In trying to verify this, we have run into the following problem: The
affine
>| transformation matrix that is printed by the normalization routine looks
nothing
>| like the matrix contained in the variable 'Affine' in _sn3d.mat. For
example:
>|
>| I. In the Spatial Normalization display and print out:
>|
>| Linear (Affine) Component - no flipping
>|
>| X1 = 1.201*X - 0.137*Y - 0.073*Z + 1.270
>| Y1 = 0.165*X + 1.051*Y + 0.444*Z + 1.284
>| Z1 = 0.004*X - 0.514*Y + 1.113*Z - 2.366
>|
>| II. By loading the masked_T1_sn3d.mat file:
>| The Affine matrix is:
>|
>| [ 1.0896 0.1478 0.0120 4.1977
>| -0.2264 1.6664 -0.6800 65.1923
>| -0.1106 0.7691 1.6016 8.0781
>| 0 0 0 1.0000 ]
>|
>| Apparently they are stored in different formats. Could you explain what
these
>| are and which we should use for the intended purpose?
>
>The matrix "Affine" maps from voxels in the template image to those in the
original,
>whereas the matrix that is displayed is a mapping from a mm space in the
original
>image to mm in the space of the template (taking into account the .mat
files or the
>voxel sizes and origins of the images). If the displayed matrix is Q,
then:
> Affine = inv(MG\Q*MF);
>
>I hope this has helped,
>-John
>
>
Xavier Chitnis
Section of Cognitive Psychopharmacology
Dept. of Psychological Medicine
Institute of Psychiatry
De Crespigny Park
London, SE5 8AF.
Tel: 0171 919 3977
Pager: 07669 028 121
|