Here's how to script this:
1. Load an image of the dimensions you want
2. Set all voxels to NaN or zero, except the ones you want
2. Save the image with a new name
The code will look something like:
% Load example volume
V = spm_vol('sample_volume.img');
Y = spm_read_vols(V);
% Set all of mask to be NaN except VOXELS greater than 30 (not mm)
Y = nan(size(Y));
Y(:,:,30:end) = 1;
% Save with new name
V.fname = 'newname.img';
spm_write_vol(V,Y);
Note: Not tested in Matlab, could be typos!
Best,
Peter.
> -----Original Message-----
> From: SPM (Statistical Parametric Mapping) [mailto:[log in to unmask]]
> On Behalf Of Dennis van der Meer
> Sent: 25 September 2013 08:54
> To: [log in to unmask]
> Subject: [SPM] Masks for bottom and top half of the brain
>
> Hi all,
> I need to find a way to make masks for parts of the brain in the Z-
> direction. For instance, with image dimensions of 121 x 145 x 121, I
> need to be able to make a mask where I zero out everything above 121 x
> 145 x 30. Is this possible?
> I've tried finding a way with ImCalc, as well as loading the whole-
> brain image into matlab and then use subsetting to zero out the right
> parts, but I can't get it to work. Any suggestions (or better yet
> detailed instructions :)) would be greatly appreciated.
> Kind regards, Dennis
|