Dear Philip,
spm_global is implemented as a MEX file in C (see src/spm_global.c).
A pure MATLAB implementation would be:
function GX = spm_global(V)
% Compute the global mean for a volume image
GX = zeros(numel(V),1);
for i=1:numel(V)
D = spm_read_vols(V(i));
iD = isfinite(D);
S = mean(D(iD)) / 8;
GX(i) = mean(D(iD & (D > S)));
end
GX should match the content of SPM.xGX.rg provided V contains the file
handles from the raw (ie unscaled) fMRI data.
Best wishes,
Guillaume.
On 20/12/13 12:11, Philip Lin wrote:
> Dear Guillaume,
>
> Thank you for your help, it helps me understand more about masking.
>
> After looking into 'spm_fmri_spm_ui.m', I understand the threshold is basically calculated by three components: "SPM.xGX.rg", "SPM.xGX.GM", and "SPM.xGX.gSF". But the first component "SPM.xGX.rg" is calculated by spm_global.m, which has only one line code "error('spm_global.c not compiled - see Makefile')".
>
> The information in the comments of spm_global.m is as follows:
>
> %__________________________________________________________________________
> %
> % spm_global returns the mean counts integrated over all the
> % slices from the volume.
> %
> % The mean is estimated after discounting voxels outside the object
> % using a criteria of greater than > (global mean)/8.
> %
> %____________________________________________________
>
> - I tried to reproduce this step in the Auditory fmri example (Manual of SPM8, ch28) by R
> - the dimension of auditory data is 79*95*68 with 84 images (or scans)
> - If the storage of this data is an array with dimension [79,95,68,84]
>
> As my understanding for this paragraph, the first value of rg should be:
>
> # select the first of 84 images
> y1 = y[,,,1]
>
> # discount voxels by the criteria of greater than (global mean)/8
> y2 = subset(y1, y1>mean(y1)/8)
>
> # the mean of y2 is equal to the first value of rg
> mean(y2)
>
> But the result is not correct (compared to the SPM.xGX.rg), would you please help me ?
>
>
>
> many thanks
>
> Philip Lin
>
--
Guillaume Flandin, PhD
Wellcome Trust Centre for Neuroimaging
University College London
12 Queen Square
London WC1N 3BG
|