Hello,
I am trying to write a program in Matlab that processes a series of images
in Analyze format, and writes the output as Analyze images. While I could
create the .img files without any problems, I was having a harder time
creating the .hdr files. I decided to use SPM functions to help me for this
step.
I do have SPM installed, and am trying to use its functions to help me
create the header file. I was able to run the following example:
% The volume that I wish to output
Volume = zeros(30,30,30);
Info.mat=[2 0 0 0; 0 2 0 0; 0 0 2 0; 0 0 0 1]
Info.fname = 'foobar.img';
Info.dim = [30,30,30,2];
spm_write_vol(Info,Volume)
However, I think I am doing something incorrectly, as I encounter the
following warnings multiple times. Is there something I should be doing
differently?
Warning: Cant get default Analyze orientation - assuming flipped
> In spm_flip_analyze_images at 9
In spm_create_vol>create_vol at 32
In spm_create_vol at 14
In spm_write_vol at 76
Warning: Divide by zero.
> In spm_write_plane>write_analyze_plane at 45
In spm_write_plane at 20
In spm_write_vol at 78
Moreover, I'm confused by how to set up the affine transformation matrix.
I'm trying to set up spacing to be 2mm x 2mm x 2mm. However, the resulting
x spacing is -2. Why would this be occurring?
Also, could someone please explain the meaning of the of Info.dim? What is
the meaning of dim[3]? I managed to get this to work by trial error, but
would prefer to understand what is happening here.
Thank you,
Julian Tam
|