> sorry to get onto your nerves as well but can you tell how to get the
> median value?
> The reason is that I want to check (grand) median-based normalisation in
> fMRI to prepare data for a second-level analysis.
I'm not sure how meaningful it is to use a median value, but here goes:
function gl = get_mean_intensity(P)
if nargin<1,
P = spm_get(Inf,'*.img');
end;
V = spm_vol(P);
gl = zeros(length(V),1);
for i=1:length(gl),
vol = zeros(V(i).dim(1:3));
for z=1:V(i).dim(3),
img = spm_slice_vol(V(i),...
spm_matrix([0 0 z]),V(i).dim(1:2),0);
vol(:,:,i) = img;
fprintf('.');
end;
gl(i) = median(vol(:));
clear vol
fprintf('\n');
end;
Best regards,
-John
--
Dr John Ashburner.
Functional Imaging Lab., 12 Queen Square, London WC1N 3BG, UK.
tel: +44 (0)20 78337491 or +44 (0)20 78373611 x4381
fax: +44 (0)20 78131420 http://www.fil.ion.ucl.ac.uk/~john
|