Dear Ning Ma,
------------------------
SPM[96] HELP says that 'a scaling coefficient' is applied during
memorymapping [SCALE]. What exactly does 'memory mapping' do? And how is
thescale factor applied? I'd like to know if 'scale factor' is related to
the value of each voxel.Since after relignment in SPM96, I'd like to
process images by using myown C-programs. I can use 'fread' in C to get
data from '*.img', but I amnot sure if the value got directly from
'fread' is real, or, the realvalue of each voxel equals to 'scale factor'
by the value got from'fread'??
---------------------------
Sorry to be a little opaque. Analyze images consist of a (rather complex)
.hdr file, with lots of information in it, and a very simple
.img file, which simply contains all the voxel values for the image, in
x, y, and then z order (at least for SPM). This means that, for
an 8 bit image, all the voxel values have to be between 0 and 255. SPM
extends this a bit, by using one of the spare fields in the .hdr file to
'scale' the image (the scale factor). Thus, to get actual voxel values,
you read in the numbers from the .img file (0-255 in an 8 bit image),
then multiply these values by the value from the scale factor, from the
header.
To do this in c, you could read the file header into a header struct as
defined by Analyze (contained in dbh.h in the spm distribution - this
is the file quoted in the earlier message).
>From this you can get the scale factor, image dimensions etc. Then you
read in the .img file (maybe using fread) and multiply by the scale
factor.
An example of how to do this is contained in the mex file read_image.c,
in the archive at:
ftp://ftp.physiol.ox.ac.uk/pub/matthew.brett/Read_image
Memory mapping refers to the process whereby the operating system
takes a file on disc and makes this disc information appear as if
it were at a chosen location in memory (i.e. writes to memory at
these locations result in disc writes, and reads, disc reads).
As far as accessing the data is concerned the same logical result would
occur if you allocate an image-sized chunk of memory and fread() the
file into the memory, but with memory mapping you avoid using
physical memory which is quickly used up by image files.
Hope that helps (more than the earlier message anyway).
Regards,
Matthew Brett
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|