| I am trying to use realigned images for some outside-SPM analysis.
| When spm realigns the images, coregister only, (step 1) it writes
| the corresponding *.mat files. If then the reslicing step is applied
| (step2), new r*.img are written and other .mat files. I thought that
| reslicing would incorporate the spatial transformation encoded in the
| .mat file into the resliced r*.img, but then what is the use of having
| a new *.mat file associated with the image?
You are right. It does incorporate the transformation, so the resliced
images should be in the same orientation as the one that everything was
realigned to. However, if the origin in a .hdr file is set to zero,
then the spm_get_space function assumes that it is referring to the
centre of the volume. If any of the dimensions are even, then the
centre will be at a position that is a fractional number of voxels.
When images are written to disk, they are written with .mat files only
when their position in space can not be represented by the voxel sizes
and an an origin field that is an integer number of voxels. If the origin
is non-integer, then .mat files are written.
| I also thought that maybe
| the new .mat file is a copy of the old one, but the two files differ.
The new .mat file is what you get if you do
spm_get_space(P)
where P is the name of the first image in the series.
| It seems that the new .mat file contains just the information for the
| voxel size and the location of the origin (updated by the realignement),
| so I guess the other information concerning the traslations and rotation
| has been incorporated in the resliced img. Is the information in the new
| .mat files redundant, in the sense that if I delete them nothing changes?
The information in the new .mat file is not quite redundant. When images
are written, the origin field in the .hdr files is set to be the closest
integer. The exact origin will be stored in the .mat file. So deleting
them would result in a half voxel discrepancy in the positions of the
images.
If you did want to delete these .mat files, you would need to set the
origins in the resliced images to [0 0 0] so that it would again default
back to being the centre of the volume.
Alternatively, you could fill in the origin fields of the .hdr files
before you do the do the realignment. In this case, the .mat files
would not be written for the resliced images.
|
| I am asking this because of the following situation. I have a routine
| for reading into a matlab variable all the (*.img + *.hdr) files of an
| acquisition session, but not the associated *.mat file. Is there a way
| to rewrite a (*.img + *.hdr + *.mat) into just a (*.img + *.hdr)?
There are lots of ways of doing this. However, there is no room in the
.hdr files for the contents of the .mat file - without making it bigger.
I would love to have changed the default image format for SPM99, but
suspect that there would have been many objections to this as there are
loads of people already using Analyze format. If ever there is a general
consensus of what is the most appropriate file format for images, then
I would be happy to have a go at making the next version of SPM fully
compatible with this format.
As it is, I tried to write the image I/O part of SPM99 so that it
should be relatively easy to change the default file format. All images
are read using spm_vol, spm_slice_vol and spm_sample_vol (and position
matrices via spm_get_space). All data is written via spm_create_image
and spm_write_plane.
Best regards,
-John
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|