Dear Dennis,
Following Colin's suggestion, if you want to extract the mean time
series within each region, you can also do it this way:
m = spm_atlas('load','ROI.nii');
f = spm_vol('functional.nii');
for i=2:numel(m.labels) % assuming first one is background
d = spm_summarise(f, spm_atlas('mask',m,m.labels(i).index), @mean);
end
If you want to extract the first eigenvariate (that will also be
adjusted, whitened and high pass filtered - it might be relevant
depending on what you want to do later on with these time series) as
done with the eigenvariate button in the SPM interface, you can use the
batch module SPM > Util > Volume of Interest or call spm_regions()
manually, for example:
% ROI
m = spm_atlas('load','ROI.nii');
% SPM details
load('SPM.mat');
[x,y,z] = ndgrid(1:SPM.xVol.DIM(1),1:SPM.xVol.DIM(2),1:SPM.xVol.DIM(3));
XYZ = [x(:),y(:),z(:)]'; clear x y z
XYZmm = SPM.xVol.M(1:3,:) * [XYZ;ones(1,size(XYZ,2))];
% xSPM variable
xSPM.XYZmm = XYZmm;
xSPM.XYZ = XYZ;
xSPM.M = SPM.xVol.M;
% Extract eigenvariates from ROI
for i=2:numel(m.labels)
xY.name = sprintf('region_%04d',m.labels(i).index);
xY.Ic = 0; % index of F-contrast used to adjust data
xY.Sess = 1; % session number
xY.xyz = []';
xY.def = 'mask';
xY.spec = spm_atlas('mask',m,m.labels(i).index);
[Y,xY] = spm_regions(xSPM,SPM,[],xY);
end
This will save a VOI_*.mat file for each region and you can get the
representative time series using:
load('VOI_region_xxxx_1.mat','Y')
Best regards,
Guillaume.
On 25/04/17 04:05, Dennis Hernaus wrote:
> Dear SPM community,
>
> I would like to extract average time series from my functional data using an ROI mask containing over a 100 regions. Typically, when I extract time series, I use the eigenvariate button in SPM12 (after loading a results file). However, my understanding is that this option requires specific coordinates as input. I have tried loading the mask, but the saved results only contain time series from the MNI coordinates displayed at the bottom of the menu. Is there a straightforward way to extract many time series at once using a mask (e.g. with integer values ranging from 1-100)? Any help would be greatly appreciated.
>
> Many thanks,
>
> Dennis Hernaus
>
--
Guillaume Flandin, PhD
Wellcome Trust Centre for Neuroimaging
University College London
12 Queen Square
London WC1N 3BG
|