I would suggest using the nifti class in SPM. There is an example of
how to use it available by typing the following in MATLAB:
help nifti/contents
The following should do what you want (although it hasn't been tested):
Ni = nifti(fname); % Get handle for existing file
No = Ni; % Base new handle on this
No.dat.fname = 'meanbone.nii'; % File name
No.dat.dtype = 'float32'; % Datatype
No.dat.scl_slope = 1; % Scale factor
No.dat.scl_inter = 0; % Intersect
create(No); % Write new header
No.dat(:,:,:) = Ni.dat(:,:,:); % Copy data
Best regards,
-John
I have another question, about the DARTEL TPMs. I'm attempting
to create my own from scratch of non-brain data. So I've
realigned and segmented 25 cardiac CT images and now I'm trying
to create TPMs for use in DARTEL. My understanding is that the
WM, GM, CSF maps need to be floating point with values of 0 to 1
(but not actually 0 or 1) at each voxel indicating the
probability of a tissue class being at a particular voxel. I'm
creating 3 classes for blood/bone/muscle, but they'll be labeled
WM,GM,CSF later on.
How can I write out the maps using SPM? I have the following
code which creates the maps, but they keep getting written as
INT16, not float32:
thevol = spm_vol(fname);
voldata = double(spm_read_vols(thevol));
thevol.fname = 'meanbone.nii';
thevol.private.dat.dtype = 'FLOAT32'; % i've also tried ...
= spm_type('float32');
spm_write_vol(thevol, bonevoldata);
-Greg
--
John Ashburner <[log in to unmask]>
|