Dear Mirko,
I attach a function which will give you global signal time courses for a
number of timeseries you select (click done without selecting data after
you have entered the last time series).
entering the matlab commands
> tc=global_signal_tc;
> std(tc(1).glob_sig)
will give you the standard deviation for the first timeseries
Good luck,
Kai
mirko wrote:
> I would like to know if there is a code to calculate standard
> deviation (variance) of the global value of a brain volume.
>
> Many thanks,
>
> Mirko Diksic.
> --
>
> Professor Mirko Diksic, PhD
>
> Director, Cyclotron-Radiochemistry Unit,
>
> Department of Neurology and Neurosurgery
>
> McGill University
>
> 3801 University St.
>
> Montreal, QC H3A 2B4
>
> Canada
>
> Tel.: (1)-514-398-8526;
>
> Fax: (1)-514-398-8195
>
>
> Disclaimer: This message contains privileged confidential information which is
> not to be disclosed. If you are not the intended recipient of this message
> please contact the sender and destroy this message as well as all existing
> copies and attachments.
>
>
>
--
Dr. Kai Lutz
Neuropsychology
Institute for Psychology
University of Zurich
Binzmühlestrasse 14 /Box 25
CH-8050 Zürich
Switzerland
function tc = global_signal_tc
%calculates global signals from time series data
%tc: 1xn structure containing the fields
% glob_sig: global signal value per image
% V: structure from spm_vol (see there)
%uses spm_global (see there)
%Kai Lutz, 2007
i=1;
weiter=true;
tc=struct('V',{},'glob_sig',{});
while weiter
if strcmp(spm('ver'),'SPM5')
P = spm_select(inf,'image',['select images from timecourse ', num2str(i)]);
else
P = spm_get(inf,'*.img',['select images from timecourse ', num2str(i)]);
end
tc(i).V = spm_vol(P);
weiter = ~isempty(P);
i=i+1;
end
tc(end)=[];
for i=1:length(tc)
spm_progress_bar('init',length(tc(i).V),['timecourse ',num2str(i)],'images completed');
for j=1:length(tc(i).V)
tc(i).glob_sig(j)=spm_global(tc(i).V(j))';
spm_progress_bar('set',j);
end
end
spm_progress_bar('clear');
% maskieren = strcmp(questdlg('Bilder Maskieren?','bitte wählen','ja','nein','ja'),'ja');
% if maskieren
% % Vo = V(1);
% % [pname, fname, ext] = fileparts(V(1).fname);
% % Vo.fname = fullfile(pname, ['mean_',fname(1:end-4),ext]);
% % Vo = spm_imcalc(V,Vo,'mean(X)',flags,varargin)
% spm_mask(P,P)
% for i=1:size(P,1)
% [pname, fname, ext] = fileparts(P(i,:));
% P(i)=fullfile(pname, ['m',fname,ext]);
% end
% end
%
% V = spm_vol(P);
% d = spm_read_vols(V);
%
% %p = squeeze(d(c(1),c(2),c(3), :));
% gs = squeeze(mean(mean(mean(d))));
% % figure
% % plot(gs);
|