Print

Print


Hi, has anyone tried using spm_write_vol in spm5b? I am trying to use the
suggestions from previous replies for writing my matlab matrix (128x128x64,
imported as dicom and manipulated in matlab) to *.img format and I keep
recieving error messages. However if I change this code:

spm_defaults
Volume = zeros(30,30,30);
[x, y, z] = size(Volume);
Info.mat = [2 0 0 0; 0 2 0 0; 0 0 2 0; 0 0 0 1]
Info.fname    = 'myimage.img';
Info.dim = [x,y,z,2];
Info.type = 2; % http://www.fil.ion.ucl.ac.uk/spm/software/spm99/#AzeFmt
spm_write_vol(Info,Volume)

to this code:

spm_defaults
Volume = zeros(30,30,30);
[x, y, z] = size(Volume);
Info.mat=[2 0 0 0; 0 2 0 0; 0 0 2 0; 0 0 0 1]
Info.fname    = 'myimage2.img';
Info.dim = [x, y, z];               %remove the 2 from above
Info.dt = [2, 0];                   %add this 
spm_write_vol(Info,Volume)

it works. My questions:

1) how do I calculate Info.mat for my data, or is what is written above okay
for everyone?
2) does Info.dt(1) = data type and Info.dt(2) = big or little endian? 
3) The image that is written out shows the head rotated by 90 degrees, the
anterior-posterior of the head is shown in the left-right direction. How can
I rotate it back to "normal".

Thanks,

Anita