Here are some selected highlights of the documentation for ImCalc:
The ImCalc functionality is for performing user-specified
algebraic manipulations on a set of images, with the result being
written out as an image. The user is prompted to supply images to
work on, a filename for the output image, and the expression to
evaluate. The expression should be a standard matlab expression,
within which the images should be referred to as i1, i2, i3,... etc.
Computation is plane by plane, so in data-matrix mode, X is a NxK
matrix, where N is the number of input images [prod(size(Vi))], and K
is the number of voxels per plane [prod(Vi(1).dim(1:2))].
With images of different sizes and orientations, the size and
orientation of the first is used for the output image. A warning is
given in this situation. Images are sampled into this orientation
using the interpolation specified by the hold parameter. [default -
nearest neighbour]
The image is written to current working directory unless a valid
full pathname is given.
Example expressions:
i) Mean of six images (select six images)
f = '(i1+i2+i3+i4+i5+i6)/6'
ii) Make a binary mask image at threshold of 100
f = 'i1>100'
iii) Make a mask from one image and apply to another
f = 'i2.*(i1>100)'
- here the first image is used to make the mask, which is
applied to the second image
iv) Sum of n images
f = 'i1 + i2 + i3 + i4 + i5 + ...'
So, for computing MTR= (Mo-Ms)/Mo x 100%, you would select the Mo and Ms images,
and evaluate an expression similar to the following:
(i1-i2)./i1*100
In practice, this would give you very noisy results in regions where Mo is
close to zero. To get around this, you may wish to stabilise the results by
using an expression such as:
(i1-i2)./(i1+1)*100
or maybe:
(i1-i2+1)./(i1+1)*100
You could also mask the results, setting values where Mo is less than (e.g. 3)
to zero:
(i1-i2)./(i1+eps)*100.*(i1>3)
However, to create a simple subtraction image, you would use the following
expression:
i1-i2
You may find other possibly useful stuff at:
http://www.jiscmail.ac.uk/cgi-bin/wa.exe?A2=ind0110&L=spm&P=R2741
http://www.jiscmail.ac.uk/cgi-bin/wa.exe?A2=ind0201&L=spm&P=R25873
If you want to integrate all the values in an image, you would need to write
some kind of a script to do it. A possible example that you could copy and
paste into Matlab would be:
%____________________________________________________________
V = spm_vol(spm_get(1,'*.img'));
sm = 0;
for i=1:V.dim(3),
M = spm_matrix([0 0 i]);
img = spm_slice_vol(V,M,V.dim(1:2),0);
sm = sm + sum(img(:));
end;
sm
fprintf('%g litres\n', sm*det(V.mat(1:3,1:3))/100^3)
%____________________________________________________________
The value of sm is the integral of intensity throughout the image. If this
is an integral over a grey matter image, then you will need to scale by the
volume of each voxel ( det(V.mat(1:3,1:3)) )in order to get an answer in
units of cubic millimetres.
Best regards,
-John
> Is it possible to subtract two images preprocessed with SPM ?
> I intended to estimate Magnetization Transfer Ratio by creating MTR map
> with two gray-matter files preprocessed and segmented with SPM. (MTR map is
> obtained by a digital subtraction of two sets of images with and without
> saturation pulse. MTR values were derived pixel-by-pixel according to the
> following equitation: MTR= (Mo-Ms)/Mo x 100% , in which Mo is the signal
> intensity for a given pixel without saturation and Ms is the signal
> intensity for the same pixel when the saturation pulse is applied.) One
> more question : how can I use the image calculation in SPM ? I wish to
> measure the white and gray-matter volume it is what ImCalc in SPM is for, I
> suppose. I have no idea how to use it. There hardly anything about
> morphometry in the SPM Manual.
--
Dr John Ashburner.
Functional Imaging Lab., 12 Queen Square, London WC1N 3BG, UK.
tel: +44 (0)20 78337491 or +44 (0)20 78373611 x4381
fax: +44 (0)20 78131420 http://www.fil.ion.ucl.ac.uk/~john
|