Hi Stuart,
although you said that you don't want a manual process, you might want to try SPMs built-in ROI tool. It is accessible from CheckReg image context menu. Just display an image, start the ROI tool from the context menu and load your bilateral ROI. To keep just one of two ROI blobs, set the "Edit tool" to "Connected Cluster", place the crosshair cursor within the blob to keep and select it by pressing the middle mouse button/wheel. Then, you can save the modified ROI into the same or a different file. This procedure involves some mouse activity, but it should be quite safe to repeat for a limited number of subjects.
Alternatively, you could try something along the lines of this code snippet, which creates a binary mask based on mm coordinates of your original image. You may need to adapt the mask expression (esp. if your ROIs are not exactly in MNI space). The resulting image can then be used in e.g. ImageCalculator to mask your ROI image:
% read volume
V=spm_vol('/tmp/med_scale_FLAIR.nii');
[X XYZ]=spm_read_vols(V);
% create mask
X1=zeros(size(X));
% mask includes all voxels with x coordinates >= 0mm
X1(XYZ(1,:)>=0)=1;
% create output volume - data type uint8 to save space
V1=rmfield(V,'private');
V1.pinfo(1:2)=Inf;
V1.dt(1)=spm_type('uint8');
[p n e v] = spm_fileparts(V.fname);
V1.fname=fullfile(p, ['msk_' n e]);
spm_write_vol(V1,X1)
Best,
Volkmar
|