> I have a basic question. I am trying to create a binary mask for each of
> our individual subject brains. I want to specify particular coordinates and
> make them 0 and the rest 1s, assuming if I have a 2x3x5 matrix, I want to
> make say 1x1:2x1:4 all 1s and the rest zeros. I am not sure if this is even
> possible.
It's not possible via the user interface, but if you are using SPM5, then it
should involve a little bit of simple coding.
P = spm_select(1,'nifti'); % Select an image
Ni = nifti(P); % NIfTI handle for input image
No = Ni; % Copy header to output image
No.dat.fname = 'mask.img'; % Output filename
No.dat.dtype = 'UINT8'; % Only a binary image, so 8-bit shoud be fine
No.dat.scl_slope = 1/255; % Scalefactor so that a value of 1 is saved as 255
No.dat.scl_inter = 0; % Make sure the intercept is 0
No.descrip = 'Binary Mask'; % Some info about the file
% The data to be written
mask = ones(size(No.dat));
mask(1,1:2,1:4) = 0;
create(No); % Write the header
No.dat(:,:,:,:,:,:) = mask; % Write the data
Best regards,
-John
|