Dear Aser,
This is an example of a voxel-to-world transform defining the space of
your output mask image. You can ignore this part of the code and just
provide an example of an image that has the size and resolution you want
your ROI image to have:
% image space definition
imgref = 'beta_0001.nii';
V = spm_vol(imgref);
DIM = V.dim;
M = V.mat;
% ROI definition
xY.def = 'sphere';
xY.xyz = [-33 -19 55]';
xY.spec = 8;
% Create ROI mask image
V = struct(...
'fname', 'ROI_sphere.nii',...
'dim', DIM,...
'dt', [spm_type('uint8') spm_platform('bigend')],...
'mat', M,...
'pinfo', [1 0 0]',...
'descrip', 'ROI');
V = spm_create_vol(V);
ROI = false(DIM);
[~,~,k] = spm_ROI(xY,V);
ROI(k) = true;
V = spm_write_vol(V,ROI);
Best regards,
Guillaume.
On 24/04/15 20:02, Aser A wrote:
> Many thanks all.
>
> Guillaume, can you please explain what is M = [-3 0 0 81;0 3 0 -115;0
> 0 3 -53;0 0 0 1];
>
> I could not get it.
>
> Thanks
>
> AS
>
> On Fri, Apr 24, 2015 at 3:22 PM, Guillaume Flandin <[log in to unmask]
> <mailto:[log in to unmask]>> wrote:
>
> Dear Aser,
>
> you can use the script below:
>
>
> %% image space definition
>
> % either with an image
> imgref = 'beta_0001.nii';
> V = spm_vol(imgref);
> DIM = V.dim;
> M = V.mat;
>
> % or with relevant information
> DIM = [53 63 46];
> M = [-3 0 0 81;0 3 0 -115;0 0 3 -53;0 0 0 1];
>
> xY.def = 'sphere';
> xY.xyz = [-33 -19 55]';
> xY.spec = 8;
>
> V = struct(...
> 'fname', 'ROI_sphere.nii',...
> 'dim', DIM,...
> 'dt', [spm_type('uint8') spm_platform('bigend')],...
> 'mat', M,...
> 'pinfo', [1 0 0]',...
> 'descrip', 'ROI');
> V = spm_create_vol(V);
>
> ROI = false(DIM);
> [~,~,k] = spm_ROI(xY,V);
> ROI(k) = true;
>
> V = spm_write_vol(V,ROI);
>
>
> Best regards,
> Guillaume.
>
>
> On 24/04/15 15:03, fMRI wrote:
> > Hi all,
> >
> > Using SPM, how can a create a ROI with sphere of 8 or 16 mm using
> a defined coordinate, say -33 -19 55?
> >
> > Thanks
> >
> >
> > Aser
> >
>
> --
> Guillaume Flandin, PhD
> Wellcome Trust Centre for Neuroimaging
> University College London
> 12 Queen Square
> London WC1N 3BG
>
>
--
Guillaume Flandin, PhD
Wellcome Trust Centre for Neuroimaging
University College London
12 Queen Square
London WC1N 3BG
|