Dear Denise,
there was indeed a bug in the current version of the PSC calculation, which causes problems if some of your subjects had NaNs at the respective position. These values were simply thrown away.
Please find attached the revised versions of three routines, which will solve the problem (and also a problem that would arise, if the 2nd level analysis was performed after reslicing the data).
There will be uploaded onto our server in the next few days.
Cheers
Simon
-----------------------------------------
Simon Eickhoff
Institut for Medicine (IME); Research Center Jülich
Leo-Brandt-Str. 5; 52425 Juelich, Germany
Phone + 49 2461-61-5219 / Fax + 49 2461-61-2820
e-mail: [log in to unmask] / [log in to unmask]
----- Original Message -----
From: Denise Dörfel <[log in to unmask]>
Date: Wednesday, December 6, 2006 4:25 pm
Subject: [SPM] PSC values from SPM Anatomy toolbox
> Dear Simon,
> dear List,
>
> in the mail below you described how to extract the Percent Signal
> Change
> values from the Anatomy toolbox.
> I use the version 1.3c with spm2 and loaded the PCS.mat into the
> workspace.I have 30 subjects (one session each) and 4 conditions.
> So I should have 4 rows and 30 columns, shouldn't I?
> The problem is, that I just got 14 columns. Where are the values
> of the
> other subjects?
>
> I'm very bad in dealing with Matlab, so maybe you could help.
>
> Denise.
>
>
>
> Simon B. Eickhoff schrieb:
> >
> > Dear Federico,
> >
> >
> >
> > the extracted PSC values are saved as a matfile called PSC.mat
> in the
> > current working directory.
> >
> >
> >
> > Just type load PSC.mat to get them back into the workspace.
> >
> >
> > The respective variable is called PSC and containes the relevant
> > values in the following fashion:
> >
> > The rows correspond to the different conditions (same order as
> in the
> > plot - in this context I would like to raise the important point
> > again, that the location of the different conditions in the
> design
> > matrix must be identical across subjects !)
> >
> > The columns correspond to subjects/sessions in the order:
> Sub1Ses1
> > Sub1Ses2 Sub1Ses3 ... Sub2Ses1 Sub2Ses2 Sub2Ses3 ... Sub3Ses1
> Sub3Ses2
> > Sub3Ses3 ... ...
> >
> >
> > Hope this helps
> >
> > Simon
> >
> >
> >
> > *----- Original Message -----* *From*: Federico Tubaldi
> > <[log in to unmask]> *Date*: Wednesday, September 6, 2006 7:05
> pm
> > *Subject*: [SPM] extract values from SPM Anatomy toolbox
> >
> > > Dear Simon and dear All,
> > >
> > > I use SPM Anatomy toolbox v.1.3c and I'd like extract the plotted
> > > % signal
> > > change values and the error bar values [option: Mean response
> (group> > analysis)]. I can't see them in matlab workspace. How
> can I do?
> > >
> > > Thank you.
> > >
> > > --
> > > No virus found in this outgoing message.
> > > Checked by AVG Free Edition.
> > > Version: 7.1.405 / Virus Database: 268.11.7/437 - Release Date:
> > > 04/09/2006
> > >
> >
> >
> >
> > -----------------------------------------
> >
> > Simon Eickhoff
> > Institut for Medicine (IME); Research Center Jülich
> > Leo-Brandt-Str. 5; 52425 Juelich, Germany
> > Phone + 49 2461-61-5219 / Fax + 49 2461-61-2820
> > e-mail: [log in to unmask] / [log in to unmask]
> >
>
> --
> Denise Doerfel
> Dipl.-Psych.
>
> Biopsychology
> Dresden University of Technology
> Zellescher Weg 17
> 01069 Dresden
> Germany
>
> Tel.: 0049 - 351 - 463 33708
> Fax.: 0049 - 351 - 463 37274
> mail: [log in to unmask]
> http://biopsychologie.tu-dresden.de
>
>
function getMap(welche,MapName)
global st;
global MAP;
global SPM;
global xSPM;
global CLUSTER;
global group;
global defaults
xtr = 0;
ytr = -4;
ztr = +5;
switch welche
case 'anat'
load(MapName);
flip = -1;
try, flip = defaults.analyze.flip; defaults.analyze.flip = 0; end
MAP(1).MaxMap = spm_vol([MapName(1:end-8) '.img']);
MAP(1).AnatMask = spm_vol(fullfile(spm('Dir','se_anatomy'),'AnatMask.img'));
MAP(1).Macro = spm_vol(fullfile(spm('Dir','se_anatomy'),'MacroLabels.img'));
MAP(1).MLabels = load('Macro.mat');
for i=1:size(MAP,2)
MAP(i).ref = strrep(MAP(i).ref,'\',filesep);
MAP(i).ref = strrep(MAP(i).ref,'/',filesep);
MAP(i).PMap = spm_vol([spm('Dir','se_anatomy') filesep 'PMaps' filesep spm_str_manip(MAP(i).ref,'t')]);
for side = [-1 1]
MAP(i).AM(side+2) = mean(MAP(i).allZ(MAP(i).allLR == side));
tmp = hist(MAP(i).allZ(MAP(i).allLR == side),[0:10]);
MAP(i).nA{side+2} = tmp(2:end)/sum(tmp)*100;
end
end
if flip ~= -1; defaults.analyze.flip = flip; end
case 'IMAGE'
OLimg = spm_vol(spm_select(1,'image','Select overlay image'));
xSPM = struct('xVOL',{});
xSPM(1).xVOL.M = OLimg.mat; xSPM.xVOL.iM = inv(OLimg.mat);
xSPM.xVOL.DIM = OLimg.dim(1:3); xSPM.xVOL.VOX = [abs(OLimg.mat(1,1)); abs(OLimg.mat(2,2)); abs(OLimg.mat(3,3))];
xSPM.xVOL.orig = spm_input('Is the origin already corrected to AC ?','+1','y/n',[1,2],2);
pmult = spm_input(['Premultiply data by '],'+0','r',1,1);
u = spm_input(['Hight threshold (0 for none)'],'+0','r',0,1); k = 0;
k = spm_input(['Extend threshold (0 for none)'],'+0','r',0,1);
if xSPM.xVOL.orig == 2
xSPM.xVOL.M(1,4) = xSPM.xVOL.M(1,4) + xtr;
xSPM.xVOL.M(2,4) = xSPM.xVOL.M(2,4) + ytr;
xSPM.xVOL.M(3,4) = xSPM.xVOL.M(3,4) + ztr;
try, set(st.mAssign,'ToolTipString','Corrdinates given in anatomical MNI space, orig. MNI coordinates in brackets'); end
end
SPM = struct('title','');
SPM.title = spm_str_manip(OLimg.fname,'rt');
SPM.XYZ = []; SPM.Z = [];
spm_progress_bar('Init',OLimg.dim(3),'Preparing data');
for p = 1:OLimg.dim(3)
d = spm_slice_vol(OLimg,inv(spm_matrix([0 0 -p 0 0 0 1 1 1])),OLimg.dim(1:2),[0, NaN])*pmult;
if any(any(d>=u))
[i,j] = find(d>u);
SPM.XYZ = [SPM.XYZ [i'; j'; p*ones(1,size(j,1))]];
SPM.Z = [SPM.Z d(find(d>u))'];
end
spm_progress_bar('Set',p);
end
if any(isinf(SPM.Z))
SPM.Z(isinf(SPM.Z)) = max(SPM.Z(~isinf(SPM.Z)));
spm('alert!','Infinitive values replace by maximum finite value');
end
spm_progress_bar('Clear')
if numel(SPM.XYZ)>0
A = spm_clusters(SPM.XYZ);
Q = [];
for i = 1:max(A)
j = find(A == i);
if length(j) >= k; Q = [Q j]; end
end
SPM.Z = SPM.Z(:,Q);
SPM.XYZ = SPM.XYZ(:,Q);
SPM.XYZmm = xSPM.xVOL.M * [SPM.XYZ; ones(1,size(SPM.XYZ,2))]; SPM.XYZmm = SPM.XYZmm(1:3,:);
SPM.XYZp = [round(SPM.XYZmm(1,:)-MAP(1).MaxMap.mat(1,4)); round(SPM.XYZmm(2,:)-MAP(1).MaxMap.mat(2,4)); round(SPM.XYZmm(3,:)-MAP(1).MaxMap.mat(3,4))];
SPM.u = u; SPM.k = k;
end
case 'SPM'
st.SPM = spm('FnBanner');
switch st.SPM;
case 'SPM99'
[SPM,VOL,xX,xCon,xSDM] = spm_getSPM;
xSPM = struct('xVOL',VOL,'xX',xX,'xCon',xCon,'Vbeta',xSDM.Vbeta);
load(fullfile(SPM.swd,'SPMcfg.mat'));
SPM.FWHM = VOL.FWHM;
SPM.VOX = VOL.VOX';
xSPM.xY.VY = VY;
xSPM.xsDes = xsDes;
SPM.S = xSDM.S;
otherwise
[xSPM,SPM] = spm_getSPM;
if isfield(xSPM.xVol,'mat');
xSPM.xVol.M = xSPM.xVol.mat
end
xSPM.xVol.VOX = [abs(xSPM.xVol.M(1,1)) abs(xSPM.xVol.M(2,2)) abs(xSPM.xVol.M(3,3))];
xSPM.xVOL = xSPM.xVol;
xSPM = rmfield(xSPM,'xVol');
end
if numel(SPM.XYZ)>0
xSPM.xVOL.orig = spm_input('Is the origin already corrected to AC ?','+1','y/n',[1,2],2);
if xSPM.xVOL.orig == 2
xSPM.xVOL.M(1,4) = xSPM.xVOL.M(1,4) + xtr;
xSPM.xVOL.M(2,4) = xSPM.xVOL.M(2,4) + ytr;
xSPM.xVOL.M(3,4) = xSPM.xVOL.M(3,4) + ztr;
SPM.XYZmm = xSPM.xVOL.M * [SPM.XYZ; ones(1,size(SPM.XYZ,2))]; SPM.XYZmm = SPM.XYZmm(1:3,:);
try, set(st.mAssign,'ToolTipString','Corrdinates given in anatomical MNI space, orig. MNI coordinates in brackets'); end
end
SPM.XYZp = [round(SPM.XYZmm(1,:)-MAP(1).MaxMap.mat(1,4)); round(SPM.XYZmm(2,:)-MAP(1).MaxMap.mat(2,4)); round(SPM.XYZmm(3,:)-MAP(1).MaxMap.mat(3,4))];
end
case 'cluster'
[A] = spm_clusters(SPM.XYZ);
CLUSTER = struct('Z',{},'XYZ',{},'XYZmm',{},'voxel',{},'nrMax',{},'maxZ',{},'maxM',{});
Buffer = struct('Z',{},'XYZ',{},'XYZmm',{},'voxel',{},'nrMax',{},'maxZ',{},'maxM',{});
mx = zeros(1,size(unique(A),2));
for cl=1: size(unique(A),2)
CLUSTER(cl).Z = SPM.Z(:,A == cl);
CLUSTER(cl).XYZ = SPM.XYZ(:,A == cl);
CLUSTER(cl).XYZmm = SPM.XYZmm(:,A == cl);
CLUSTER(cl).XYZp = [CLUSTER(cl).XYZmm(1,:)-MAP(1).MaxMap.mat(1,4); CLUSTER(cl).XYZmm(2,:)-MAP(1).MaxMap.mat(2,4); CLUSTER(cl).XYZmm(3,:)-MAP(1).MaxMap.mat(3,4)];
[CLUSTER(cl).voxel CLUSTER(cl).maxZ CLUSTER(cl).maxM dummy] = spm_max(SPM.Z(:,A == cl),SPM.XYZ(:,A == cl));
if isempty(max(CLUSTER(cl).maxZ)); % binary image
CLUSTER(cl).voxel = prod(size(find(A == cl)));
end
CLUSTER(cl).nrMax = size(CLUSTER(cl).maxZ,2);
mx(cl) = CLUSTER(cl).voxel(1);
end
CLUSTER(1).VOL = zeros(MAP(1).MaxMap.dim(1:3));
[B,INDEX] = sort(mx); INDEX = fliplr(INDEX); CLUSTER = CLUSTER(INDEX);
for i=1:size(unique(A),2); RIX(i) = find(INDEX == i); end
for i=1:size(A,2)
try
CLUSTER(1).VOL([SPM.XYZp(1,i)-1:SPM.XYZp(1,i)+1],...
[SPM.XYZp(2,i)-1:SPM.XYZp(2,i)+1],...
[SPM.XYZp(3,i)-1:SPM.XYZp(3,i)+1]) = RIX(A(i));
end
end
case 'groupStat'
st.SPM = spm('FnBanner');
group = [];
def = spm_input('Load an existing group ?','+1','y/n',[1,0],1);
if def == 0 % Create new group
cwd = pwd;
nsubjects = spm_input('Number of subjects','+1','i',1);
group = struct('xSPM',{});
for i=1:nsubjects
a = spm_select(1,'^SPM\.mat$',['Select SPM.mat for subject ' num2str(i)]);
load(a);
st.SPM = spm('FnBanner');
switch st.SPM;
case 'SPM99'
for ii=1:size(Vbeta,1)
try
f = cell2struct(Vbeta(ii,1),'name',1);
group(i).xSPM.Vbeta(ii) = spm_vol([spm_str_manip(a,'H') '/' f.name]);
catch
f = struct('name',Vbeta{ii,1})
group(i).xSPM.Vbeta(ii) = spm_vol([spm_str_manip(a,'H') '/' f.name]);
end
end
group(i).xSPM.xX = xX;
group(i).xSPM.Sess = Sess;
otherwise
for ii=1:size(SPM.Vbeta,2)
group(i).xSPM.Vbeta(ii) = spm_vol([spm_str_manip(a,'H') '/' SPM.Vbeta(1,ii).fname]);
end
group(i).xSPM.xX = SPM.xX;
group(i).xSPM.VY = SPM.xY.VY;
group(i).xSPM.XYZ = SPM.xVol.XYZ;
group(i).xSPM.xVOL.M = SPM.xVol.M;
group(i).xSPM.xVOL.iM = inv(SPM.xVol.M);
group(i).xSPM.xCon = SPM.xCon;
group(i).xSPM.Sess = SPM.Sess;
group(i).xSPM.swd = SPM.swd;
end
end
load(spm_select(1,'^SPM\.mat$',['Select SPM.mat for the 2nd level analysis']));
group(1).xSPM.xVOL.orig = spm_input('Is the origin already corrected to AC ?','+1','y/n',[1,2],2);
if group(1).xSPM.xVOL.orig == 2
for i=1:nsubjects
group(i).xSPM.xVOL.M(1,4) = group(i).xSPM.xVOL.M(1,4) + xtr;
group(i).xSPM.xVOL.M(2,4) = group(i).xSPM.xVOL.M(2,4) + ytr;
group(i).xSPM.xVOL.M(3,4) = group(i).xSPM.xVOL.M(3,4) + ztr;
try, set(st.mAssign,'ToolTipString','Corrdinates given in anatomical MNI space, orig. MNI coordinates in brackets'); end
group(i).xSPM.XYZmm = group(i).xSPM.xVOL.M * [group(i).xSPM.XYZ; ones(1,size(group(i).xSPM.XYZ,2))];
group(i).xSPM.XYZmm = group(i).xSPM.XYZmm(1:3,:);
end
end
name = spm_input('Name of group','!+1','s','GroupAnalysis');
cd(cwd);
save(deblank(fullfile(pwd,name)),'group','xSPM','SPM')
else % load existing group
load(spm_select(1,'mat',['Select information about the subjects']));
xSPM.xVOL = group(1).xSPM.xVOL;
end
spm('alert!','Statistical information loaded');
case 'group'
st.SPM = spm('FnBanner');
def = spm_input('Load an existing group ?','+1','y/n',[1,0],1);
if def == 0 % Create new group
cwd = pwd;
nsubjects = spm_input('Number of subjects','+1','i',1);
group = struct('xSPM',{});
for i=1:nsubjects
a = spm_select(1,'^SPM\.mat$',['Select SPM.mat for subject ' num2str(i)]);
load(a);
switch st.SPM;
case 'SPM99'
for ii=1:size(Vbeta,1)
try
f = cell2struct(Vbeta(ii,1),'name',1);
group(i).xSPM.Vbeta(ii) = spm_vol([spm_str_manip(a,'H') '/' f.name]);
catch
f = struct('name',Vbeta{ii,1})
group(i).xSPM.Vbeta(ii) = spm_vol([spm_str_manip(a,'H') '/' f.name]);
end
end
group(i).xSPM.xX = xX;
group(i).xSPM.Sess = Sess;
otherwise
for ii=1:size(SPM.Vbeta,2)
group(i).xSPM.Vbeta(ii) = spm_vol([spm_str_manip(a,'H') '/' SPM.Vbeta(1,ii).fname]);
end
group(i).xSPM.xX = SPM.xX;
group(i).xSPM.VY = SPM.xY.VY;
group(i).xSPM.XYZ = SPM.xVol.XYZ;
group(i).xSPM.xVOL.M = SPM.xVol.M;
group(i).xSPM.xVOL.iM = inv(SPM.xVol.M);
group(i).xSPM.xCon = SPM.xCon;
group(i).xSPM.Sess = SPM.Sess;
group(i).xSPM.swd = SPM.swd;
end
end
spm('alert"',{'Please specify now the second level statistic'},'Next Step',0,1);
se_getMap('SPM','');
if xSPM.xVOL.orig == 2
for i=1:nsubjects
group(i).xSPM.xVOL.M(1,4) = group(i).xSPM.xVOL.M(1,4) + xtr;
group(i).xSPM.xVOL.M(2,4) = group(i).xSPM.xVOL.M(2,4) + ytr;
group(i).xSPM.xVOL.M(3,4) = group(i).xSPM.xVOL.M(3,4) + ztr;
try, set(st.mAssign,'ToolTipString','Corrdinates given in anatomical MNI space, orig. MNI coordinates in brackets'); end
group(i).xSPM.XYZmm = group(i).xSPM.xVOL.M * [group(i).xSPM.XYZ; ones(1,size(group(i).xSPM.XYZ,2))];
group(i).xSPM.XYZmm = group(i).xSPM.XYZmm(1:3,:);
end
end
name = spm_input('Name of group','!+1','s','GroupAnalysis');
cd(cwd);
save(deblank(fullfile(pwd,name)),'group','xSPM','SPM')
else % load existing group
load(spm_select(1,'mat',['Select information about the subjects']));
spm('alert"',{'Please specify now the second level statistic'},'Next Step',0,1);
se_getMap('SPM','');
end
end
function [psc] = se_PSC_area(xSPM,targets)
global st;
global MAP;
global SPM;
global CLUSTER;
global displayType;
global group
% define number of sessions etc.
switch st.SPM;
case 'SPM99'
sess = size(xSPM.Sess,2); %number of sessions
sps = size(xSPM.Sess{1}.row,2); %scans per session
regressors = size(xSPM.Sess{1}.col,2); %number of regressors per session (incl. movement regressors)
allreg = (regressors);
condSeq = [1:regressors];
otherwise
sess = size(xSPM.Sess,2); %number of sessions
sps = size(xSPM.Sess(1).row,2); %scans per session
regressors = size(group(1).xSPM.Sess(1).Fc,2); %number of regressors per session (incl. movement regressors)
allreg = max(xSPM.Sess(1).col);
condSeq =[];
for i=1:regressors
condSeq = [condSeq xSPM.Sess(1).Fc(i).i(1)];
end
end
PSC = [];
xyz = xSPM.xVOL.iM*[targets;ones(1,size(targets,2))];
betaAll = [];
for i = 1:length(xSPM.Vbeta)
betaAll = [betaAll spm_sample_vol(xSPM.Vbeta(i),xyz(1,:),xyz(2,:),xyz(3,:),0)];
end
betaAll = reshape(betaAll,size(targets,2),length(xSPM.Vbeta));
dimBeta = size(betaAll,2);
for tar = 1:size(targets,2)
beta = betaAll(tar,:);
for c = 1:size(condSeq,2)
k = condSeq(c);
seq = []; for i = 1:sess; seq = [seq (i-1)*allreg+k]; end; s = 0;
for i = seq,
s = s+1; beta_xyz(c,s) = beta(i);
signChg(1:sps) = beta_xyz(c,s)*xSPM.xX.xKXs.X(((s-1)*sps+1):(s*sps),i);
if beta_xyz(c,s)>0
delta(c,s) = max(signChg); % positive signal change
else
delta(c,s) = min(signChg); % negative signal change
end;
sMSI(s) = beta(dimBeta-(sess-s));
PSCtmp(c,s) = (delta(c,s)/sMSI(s))*100; % k = konditions, s = sessions
end;
end
PSC = [PSC PSCtmp];
end
psc = struct('beta',beta_xyz,'delta',delta,'sMSI',sMSI,'PSC',PSC,'number',size(targets,2),'Sessions',size(condSeq,2));
%-Reset title
%-----------------------------------------------------------------------
spm('Pointer','Arrow')
function se_anatomy(op,varargin)
global st;
global MAP;
global SPM;
global xSPM;
global CLUSTER;
global displayType;
global group
global defaults;
if strncmp(op,'init',4) & prod(size(op))>4;
clear global MAP SPM xSPM CLUSTER group
fg = se_figure('getWin','Graphics');
delete(fg)
[Finter,Fgraph,CmdLine] = spm('FnUIsetup','Display',0);
SPMid = spm('FnBanner',mfilename,'2.15');
spm_help('!ContextHelp',[mfilename,'.m']);
% get the image's filename {P}
%-----------------------------------------------------------------------
MapName = spm_select(1,'mat',['Select Map'],[],spm('Dir','se_anatomy'),'MPM.',1);
se_getMap('anat',MapName);
P = deblank([MapName(1:end-8) '.img']);
fg = se_figure('GetWin','Graphics');
if isempty(fg), error('Can''t create graphics window'); end
se_figure('Clear','Graphics');
se_orthviews('Reset');
switch spm('FnBanner')
case 'SPM99'
se_orthviews('Image', P, [0.0 0.22 1 .8]); % Image appears
otherwise
se_orthviews('Image', P, [0.0 0.2 1 .8]); % Image appears
end
if strcmp(op,'initO');
st.prog = 'OV';
elseif strcmp(op,'initG');
st.prog = 'GR';
elseif strcmp(op,'initP');
st.prog = 'PX';
elseif strcmp(op,'initA');
st.prog = 'AR';
end
se_anatomy('init',fg);
return;
end;
if ~strcmp(op,'init') & ~strcmp(op,'reset') & isempty(st.vols{1}), my_reset; warning('Lost all the image information'); return; end;
if strcmp(op,'shopos'),
% The position of the crosshairs has been moved.
%-----------------------------------------------------------------------
if strcmp(st.prog,'PX')
fg = se_figure('Findwin','Graphics');
if xSPM.xVOL.orig == 2
set(st.mp,'String',sprintf('%.1f %.1f %.1f',se_orthviews('pos')+[0;+4;-5]));
else
set(st.mp,'String',sprintf('%.1f %.1f %.1f',se_orthviews('pos')));
end
[loc, aVox] = hier_area;
set(st.in,'String',loc);
CLUSTER.XYZmm = se_orthviews('pos');
CLUSTER.XYZp = se_orthviews('pos',1);
[MLev, VLev, m_anz] = se_overlap(1);
set(st.mAssign,'String',MLev);
else
if isfield(st,'mp'),
fg = se_figure('Findwin','Graphics');
if any(findobj(fg) == st.mp),
set(st.mp,'String',sprintf('%.1f %.1f %.1f',se_orthviews('pos')));
pos = se_orthviews('pos',1);
set(st.vp,'String',sprintf('%.1f %.1f %.1f',pos));
[loc, aVox] = hier_area;
set(st.in,'String',loc);
if prod(size(CLUSTER))>0
fDa = 0;
try ,fDa = CLUSTER(1).VOL(round(pos(1)),round(pos(2)),round(pos(3))); end
if fDa;
if CLUSTER(1).VOL(round(pos(1)),round(pos(2)),round(pos(3))) ~= get(st.cluster,'Value')-1;
set(st.cluster,'Value',1+CLUSTER(1).VOL(round(pos(1)),round(pos(2)),round(pos(3))));
clu_title;
end
else
try; delete(st.FX); end
try; se_anatomy('clearRender'); end
set(st.titel,'String','');
if ~strcmp(st.prog,'AR')
set(st.vAssign,'String',''); set(st.mAssign,'String','');
end
set(st.cluster,'Value',1)
end
end
else,
st.Callback = ';'; rmfield(st,{'mp','vp','in'});
end;
else,
st.Callback = ';';
end;
end
return;
end;
if strcmp(op,'clearRender')
st.Fgraph = findobj(get(0,'Children'),'Flat','Tag','xSATB');
if ~isempty(st.Fgraph)
try
set(0,'CurrentFigure',st.Fgraph);
clf
catch
st.Fgraph = [];
end
end
ax=axes('Parent',st.Fgraph,'units','normalized','Position',[0, 0, 1, 1],'Visible','off'); image(0,'Parent',ax); set(ax,'YTick',[],'XTick',[]);
end
if strcmp(op,'setposmm'),
% Move the crosshairs to the specified position
%-----------------------------------------------------------------------
if isfield(st,'mp'),
fg = se_figure('Findwin','Graphics');
if any(findobj(fg) == st.mp),
pos = sscanf(get(st.mp,'String'), '%g %g %g');
if strcmp(st.prog,'PX') & xSPM.xVOL.orig == 2
pos = pos+[0;-4;5];
se_orthviews('Reposition',pos);
else
se_orthviews('Reposition',pos);
end
end;
end;
return;
end;
if strcmp(op,'setposclust'),
% Move the crosshairs to the specified cluster
%--------------------------------------------------------------------------------------------------------------------------------
fg = se_figure('Findwin','Graphics');
poscl = get(st.cluster,'Value')-1;
if poscl > 0
pos = [round(mean(CLUSTER(poscl).XYZmm(1,:)));
round(mean(CLUSTER(poscl).XYZmm(2,:)));
round(mean(CLUSTER(poscl).XYZmm(3,:)))];
set(st.cluster,'Value',poscl+1)
clu_title;
set(st.maxima,'Value',2)
se_anatomy('setposmax');
end;
if get(st.zoomer,'Value')>1
se_anatomy('zoom_in')
end
return;
end;
if strcmp(op,'setposmax'),
% Move the crosshairs to the specified position
%--------------------------------------------------------------------------------------------------------------------------------
fg = se_figure('Findwin','Graphics');
posmx = get(st.maxima,'Value')-1;
poscl = get(st.cluster,'Value')-1;
if posmx > 0
[B,INDEX] = sort(CLUSTER(poscl).maxZ);
posmx = size(B,2)+1-posmx;
if CLUSTER(poscl).maxZ == 0
pos = xSPM.xVOL.M * [CLUSTER(poscl).maxM(1);...
CLUSTER(poscl).maxM(2);...
CLUSTER(poscl).maxM(3); 1]; %-Reorientation matrix
else
pos = xSPM.xVOL.M * [CLUSTER(poscl).maxM(1,INDEX(posmx));...
CLUSTER(poscl).maxM(2,INDEX(posmx));...
CLUSTER(poscl).maxM(3,INDEX(posmx)); 1]; %-Reorientation matrix
pos = pos(1:3);
end
if size(CLUSTER(poscl).XYZ,2) ~= 1
se_orthviews('Reposition',pos);
end
end
end;
if strcmp(op,'setposarea'),
poscl = get(st.cluster,'Value')-1;
if prod(size(group))<2; se_getMap('groupStat'); end
se_figure('Clear','Interactive');
if isfield(st,'hAx');
delete(st.hAx); st = rmfield(st,'hAx');
end
se_orthviews('rmblobs',1);
PSC = []; GV = [MAP.GV];
locNr = get(st.cluster,'Value')-1;
check = spm_input(['Process area ' MAP(locNr).name ' ?'],'+1','y/n',[1,2],1);
if check == 1
side = MAP(1).orient*spm_input_ui('Side','!+1','b','Left|Right',[-1 1],1,'Select side');
mode = spm_input_ui('Voxel','!+1','b','All assigned|Highest probability',[2 1],2,'Select mode');
[nvox, QQ, targets] = se_defineVoxel(side,locNr,mode);
XYZ = MAP(locNr).XYZ(:,QQ);
Z = MAP(locNr).Z(QQ);
se_orthviews('addcolouredblobs',1,XYZ,Z,MAP(1).MaxMap.mat,[1 0 0]);
se_orthviews('Reposition',mean(targets'));
spm_progress_bar('Init',prod(size(group)),'Subjects completed');
for i=1:prod(size(group))
psc(i) = se_PSC_area(group(i).xSPM,targets);
PSC = [PSC mean(psc(i).PSC')'];
spm_progress_bar('Set',i);
end
spm_progress_bar('Clear')
nvox = psc(i).number;
regressors = size(PSC,1)
[PSCmin PSCmax Ay] = displayPSC(PSC,regressors,[0.51 0.17 0.46 0.335],1);
text(PSCmin,Ay-10,sprintf('Area: %s overlap %s (%s voxel)',MAP(locNr).name,int2str(min(Z)/25),int2str(nvox)),'FontSize',12);
else
se_figure('Clear','Interactive');
return
end
end;
if strcmp(op,'setposvx'),
% Move the crosshairs to the specified position
%-----------------------------------------------------------------------
if isfield(st,'mp'),
fg = se_figure('Findwin','Graphics');
if any(findobj(fg) == st.vp),
pos = sscanf(get(st.vp,'String'), '%g %g %g');
if length(pos)~=3,
pos = se_orthviews('pos',1);
end;
tmp = st.vols{1}.premul*st.vols{1}.mat;
pos = tmp(1:3,:)*[pos ; 1];
se_orthviews('Reposition',pos);
end;
end;
return;
end;
if strcmp(op,'addblobs'),
if st.prog == 'AR'
else
% Add blobs to the image - in full colour
se_figure('Clear','Interactive');
if st.prog == 'GR'
try
group(1);
spm('alert"',{'Please specify the secound level statistic'},'Next Step',0,1);
se_getMap('SPM','');
catch
se_getMap('group','');
end
elseif st.prog == 'PX'
spm('alert!','No activation map in quick-check mode',sqrt(-1));
elseif st.prog == 'OV'
OLwhat = spm_input_ui('Overlay','!+1','b','SPM|Image',[1 2],1,'Select mode');
if OLwhat == 1
se_getMap('SPM','');
else
se_getMap('IMAGE','');
end
else
se_getMap('SPM','');
end
if numel(SPM.XYZ)>0
se_getMap('cluster','')
c = spm_input('Colour',1,'m','Red -> White colormap|Red blobs|Yellow blobs|Green blobs|Cyan blobs|Blue blobs|Magenta blobs',[1 2 3 4 5 6 7],1);
if c > 1
colours = [1 0 0;1 1 0;0 1 0;0 1 1;0 0 1;1 0 1];
se_orthviews('addcolouredblobs',1,SPM.XYZ,SPM.Z,xSPM.xVOL.M,colours(c-1,:));
else
se_orthviews('AddBlobs',1,SPM.XYZ,SPM.Z,xSPM.xVOL.M);
end
set(st.blobber,'String','Remove Blobs','Callback','se_anatomy(''rmblobs'');');
set(st.cluster,'String',str2mat(getCluster(1)));
se_orthviews('Redraw');
else
spm('alert"',{'No superthreshold voxel !'},'',0,1);
end
end
end;
if strcmp(op,'rmblobs'),
% Remove all blobs from the images
se_orthviews('rmblobs',1);
set(st.blobber,'String','Add Blobs','Callback','se_anatomy(''addblobs'');');
set(st.cluster,'String','No activation cluster found','Value',1);
set(st.titel,'String','');
try; delete(st.FX); end
try; se_anatomy('clearRender'); end
if ~(st.prog == 'AR')
set(st.vAssign,'String','');
set(st.mAssign,'String','');
end
end;
if strcmp(op,'window'),
op = get(st.win,'Value');
if op == 1,
se_orthviews('window',1);
else,
se_orthviews('window',1,spm_input('Range','+1','e','',2));
end;
end;
if strcmp(op,'reset'),
my_reset;
end;
if strcmp(op,'exit'),
my_reset;
Anatomy('select');
end;
if strcmp(op,'zoom_in'),
op = get(st.zoomer,'Value');
if op==1,
se_orthviews('resolution',1);
se_orthviews('MaxBB');
else,
vx = sqrt(sum(st.Space(1:3,1:3).^2));
vx = vx.^(-1);
pos = se_orthviews('pos');
pos = st.Space\[pos ; 1];
pos = pos(1:3)';
if op == 2, st.bb = [pos-80*vx ; pos+80*vx] ; se_orthviews('resolution',1);
elseif op == 3, st.bb = [pos-40*vx ; pos+40*vx] ; se_orthviews('resolution',.5);
elseif op == 4, st.bb = [pos-20*vx ; pos+20*vx] ; se_orthviews('resolution',.25);
elseif op == 5, st.bb = [pos-10*vx ; pos+10*vx] ; se_orthviews('resolution',.125);
else , st.bb = [pos- 5*vx ; pos+ 5*vx] ; se_orthviews('resolution',.125);
end;
end;
return;
end;
if strcmp(op,'Info'),
st.mode = 1;
if isfield(st,'hAx');
delete(st.hAx);
st = rmfield(st,'hAx');
end
set(st.titel,'Visible','on');
set(st.mAssign,'Visible','on');
set(st.vAssign,'Visible','on');
set(st.clustBox,'Visible','on');
set(st.maxBox,'Visible','on');
set(st.cluster,'Visible','on');
set(st.maxima,'Visible','on');
se_figure('Clear','Interactive');
end
if strcmp(op,'SVC'),
if strcmp(spm('FnBanner'),'SPM99')
h = spm('alert*','Only available for SPM2 and SPM5');
else
if strcmp(get(st.blobber,'String'),'Remove Blobs') & isfield(SPM,'STAT')
Msk = spm_select(1,'image','Image defining search volume',[],pwd,'ROI');
D = spm_vol(Msk);
str = sprintf('image mask: %s',spm_str_manip(Msk,'a30'));
VOX = sqrt(sum(D.mat(1:3,1:3).^2));
FWHM = SPM.FWHM.*(SPM.VOX./VOX);
XYZm = inv(D.mat) * (xSPM.xVOL.M(1:3,:)*[xSPM.xVOL.XYZ; ones(1, xSPM.xVOL.S)]);
k = find(spm_sample_vol(D, XYZm(1,:), XYZm(2,:), XYZm(3,:),0) > 0);
SPM.XYZ = xSPM.xVOL.XYZ(:,k);
SPM.S = length(k);
SPM.R = spm_resels(FWHM,D,'I');
SPM.Z = Inf;
for i = SPM.Ic
SPM.Z = min(SPM.Z,spm_get_data(xSPM.xCon(i).Vspm,SPM.XYZ));
end
switch SPM.STAT
case 'T'
SPM.Ps = (1 - spm_Tcdf(SPM.Z,SPM.df(2))).^SPM.n;
case 'P'
SPM.Ps = (1 - SPM.Z).^SPM.n;
case 'F'
SPM.Ps = (1 - spm_Fcdf(SPM.Z,SPM.df)).^SPM.n;
end
SPM.u = -Inf; SPM.k = 0;
if SPM.STAT ~= 'P'
str = 'FWE|none';
switch spm_input('p value adjustment to control','+1','b',str,[],1)
case 'FWE' % family-wise false positive rate
u = spm_input('p value (family-wise error)','+0','r',0.05,1,[0,1]);
SPM.u = spm_uc(u,SPM.df,SPM.STAT,SPM.R,SPM.n,SPM.S);
otherwise %-NB: no adjustment
SPM.u = spm_input(['threshold {',SPM.STAT,' or p value}'],'+0','r',0.001,1);
if SPM.u <= 1; SPM.u = spm_u(SPM.u^(1/SPM.n),SPM.df,SPM.STAT); end
end
elseif STAT == 'P'
SPM.u = spm_input(['p value threshold for PPM'],'+0','r',.95,1);
end % (if STAT)
Q = find(SPM.Z > SPM.u);
SPM.Z = SPM.Z(:,Q);
SPM.XYZ = SPM.XYZ(:,Q);
if isempty(Q)
warning(sprintf('No voxels survive height threshold u=%0.2g',u))
end
if ~isempty(SPM.XYZ)
SPM.k = spm_input('& extent threshold {voxels}','+1','r',0,1,[0,Inf]);
A = spm_clusters(SPM.XYZ); Q = [];
for i = 1:max(A); j = find(A == i); if length(j) >= SPM.k; Q = [Q j]; end; end
SPM.Z = SPM.Z(:,Q);
SPM.XYZ = SPM.XYZ(:,Q);
if isempty(Q); warning(sprintf('No voxels survive extent threshold k=%0.2g',k)); end
end
SPM.XYZmm = xSPM.xVOL.M * [SPM.XYZ; ones(1,size(SPM.XYZ,2))]; SPM.XYZmm = SPM.XYZmm(1:3,:);
SPM.XYZp = [round(SPM.XYZmm(1,:)-MAP(1).MaxMap.mat(1,4)); round(SPM.XYZmm(2,:)-MAP(1).MaxMap.mat(2,4)); round(SPM.XYZmm(3,:)-MAP(1).MaxMap.mat(3,4))];
if numel(SPM.XYZ)>0
se_getMap('cluster','')
c = spm_input('Colour',1,'m','Red blobs|Yellow blobs|Green blobs|Cyan blobs|Blue blobs|Magenta blobs',[1 2 3 4 5 6],1);
colours = [1 0 0;1 1 0;0 1 0;0 1 1;0 0 1;1 0 1];
se_orthviews('rmblobs',1);
se_orthviews('addcolouredblobs',1,SPM.XYZ,SPM.Z,xSPM.xVOL.M,colours(c,:));
set(st.cluster,'String',str2mat(getCluster(1)));
else
spm('alert"',{'No superthreshold voxel !'},'',0,1);
end
else
h = spm('alert*','No activation map loaded','SVC not possible');
end
end
end
if strcmp(op,'Plot'),
se_figure('clear','Interactive')
if strcmp(get(st.blobber,'String'),'Remove Blobs') & isfield(SPM,'STAT')
try; delete(st.FX); end
try; se_anatomy('clearRender'); end
xyzp = round(se_orthviews('pos',1));
fDa = 0;, try ,fDa = CLUSTER(1).VOL((xyzp(1)),(xyzp(2)),(xyzp(3))); end
if 0; fDa
definition = spm_input('Process whole cluster ?','+1','y/n',[1,2],2);
if definition == 1
xyz = xSPM.xVOL.M*[CLUSTER(fDa).XYZ;ones(1,size(CLUSTER(fDa).XYZ,2))];
else
xyz = [se_orthviews('pos'); 1];
end
else
definition = 2;
xyz = [se_orthviews('pos'); 1];
end
se_graph(SPM,xSPM,xyz,definition)
else
h = spm('alert*','No activation map loaded');
end
end
if strcmp(op,'Tab'),
if strcmp(get(st.blobber,'String'),'Remove Blobs') & strcmp(st.prog,'OV')
try
thres = strrep(SPM.thresDef,'0.','');, thres = strrep(thres,'(','-'); thres = strrep(thres,')',''); thres = strrep(thres,'p<','_p'); thres = strrep(thres,'P>','_P');
catch
thres = strrep(num2str(5.231,'%2.1f'),'.','-');
end
filename = [strrep(SPM.title,' ','_') strrep(thres,' ','') '.txt'];
filename = strrep(filename,'>','vs'); filename = strrep(filename,'<','vs');
filename = strrep(filename,')','-'); filename = strrep(filename,'(','-');
filename = strrep(filename,'/','-'); filename = strrep(filename,'\','-');
filename = fullfile(pwd,filename);
if strcmp(computer,'PCWIN')
fid = fopen(filename,'wt');
else
fid = fopen(filename,'w+');
end
for poscl = 1:size(CLUSTER,2)
se_tabelate(poscl,fid)
fprintf(fid,repmat('\n',1,5));
end
status = fclose(fid);
spm('alert"',{'Results saved to file'; spm_str_manip(filename,'t'); 'in path'; pwd});
else
h = spm('alert*','No activation map loaded');
end
end
if strcmp(op,'PSCG'),
try
group(1);
catch
se_anatomy('addblobs')
end
PSC = [];
xyzp = round(se_orthviews('pos',1));
fDa = 0;, try ,fDa = CLUSTER(1).VOL((xyzp(1)),(xyzp(2)),(xyzp(3))); end
% if fDa;
% PSCmode = spm_input('Which mode ?', '!+1', 'm','Single voxel|Cluster by area|Cluster',[1 2 4],1);
% else
PSCmode = 1;
% end
switch PSCmode
case 1 % Single voxel
targets = round(se_orthviews('pos'));
case 2 % Cluster by area
cl = (get(st.cluster,'Value')-1); GV = [MAP.GV];
tmp = CLUSTER(cl).XYZp; tms = sign(CLUSTER(cl).XYZmm); clear gtmp;
for xbx = 0:xSPM.xVOL.VOX(1)-1, for ybx = 0:xSPM.xVOL.VOX(2)-1, for zbx = 0:xSPM.xVOL.VOX(3)-1
if exist('gtmp')
gtmp = [gtmp(1,:) tmp(1,:)-(tms(1,:)*xbx);...
gtmp(2,:) tmp(2,:)-(tms(2,:)*ybx);...
gtmp(3,:) tmp(3,:)-(tms(3,:)*zbx)];
else
gtmp = [tmp(1,:)-(tms(1,:)*xbx);...
tmp(2,:)-(tms(2,:)*ybx);...
tmp(3,:)-(tms(3,:)*zbx)];
end
end, end, end
Msk = spm_sample_vol(MAP(1).AnatMask,gtmp(1,:),gtmp(2,:),gtmp(3,:),0);
Volume = spm_sample_vol(MAP(1).MaxMap,gtmp(1,:),gtmp(2,:),gtmp(3,:),0); % Corresponding voxel + next towards origin in all directions
VLev = {}; vp = [];
for v=1:size(MAP,2)
if any(Volume(Msk == 2) == GV(v)), vp = [vp; size(find(Volume(Msk == 2) == GV(v)),2) v 2]; end
if any(Volume(Msk == 1) == GV(v)), vp = [vp; size(find(Volume(Msk == 1) == GV(v)),2) v 1]; end
end, vp = sortrows(vp);
if ~any(vp); spm('alert!','No areas found at the specified positions',sqrt(-1)); return; end
selec = []; sel = []; vp = sortrows(vp); lr = [];
for v=(size(vp,1)):-1:1
if (100*vp(v,1)/(CLUSTER(cl).voxel(1)*prod(xSPM.xVOL.VOX))) >= 5
if vp(v,3) == -1;
selec = [selec '|' ['left ' MAP(vp(v,2)).name] ': ' int2str((100*vp(v,1)/(CLUSTER(cl).voxel(1)*prod(xSPM.xVOL.VOX)))) '%']; sel = [sel vp(v,2)]; lr = [lr vp(v,3)];
else
selec = [selec '|' ['right ' MAP(vp(v,2)).name] ': ' int2str((100*vp(v,1)/(CLUSTER(cl).voxel(1)*prod(xSPM.xVOL.VOX)))) '%']; sel = [sel vp(v,2)]; lr = [lr vp(v,3)];
end
end
end
choice = spm_input('Select area ', '!+1', 'm',selec,[1:size(sel,2)],1); locNr = sel(choice);
pxyz = round(se_orthviews('pos')); onXYZ = find(SPM.XYZmm(1,:) == pxyz(1) & SPM.XYZmm(2,:) == pxyz(2) & SPM.XYZmm(3,:) == pxyz(3));
A = spm_clusters(SPM.XYZ); Q = find(A == A(onXYZ));
xx = round(SPM.XYZmm(1,Q)-MAP(1).MaxMap.mat(1,4)); yy = round(SPM.XYZmm(2,Q)-MAP(1).MaxMap.mat(2,4)); zz = round(SPM.XYZmm(3,Q)-MAP(1).MaxMap.mat(3,4));
Q = Q(spm_sample_vol(MAP(1).MaxMap,xx,yy,zz,0) == MAP(locNr).GV & ...
spm_sample_vol(MAP(1).AnatMask,xx,yy,zz,0) == lr(choice));
case 4
A = spm_clusters(SPM.XYZ);
pxyz = round(se_orthviews('pos')); onXYZ = find(SPM.XYZmm(1,:) == pxyz(1) & SPM.XYZmm(2,:) == pxyz(2) & SPM.XYZmm(3,:) == pxyz(3));
Q = find(A == A(onXYZ));
end
if PSCmode > 1
targets = SPM.XYZmm(:,Q);
end
spm_progress_bar('Init',prod(size(group)),'Subjects completed');
for i=1:prod(size(group))
psc(i) = se_PSC_area(group(i).xSPM,targets);
% if size(targets,2)>1
% PSC = [PSC mean(psc(i).PSC')'];
% else
PSC = [PSC psc(i).PSC];
% end
spm_progress_bar('Set',i);
end
spm_progress_bar('Clear')
if psc(i).Sessions == 1
descrip = ['Rows: Conditions; Columns: Sub1, Sub2, Sub3... Sub' int2str(prod(size(group)))];
else
descrip = ['Rows: Conditions; Columns: Sub1 Ses1 - Ses' int2str(psc(i).Sessions ) ', Sub2 Ses1 - Ses' int2str(psc(i).Sessions ) '... Sub' int2str(prod(size(group))) ' Ses1 - Ses' int2str(psc(i).Sessions )];
end
save PSC.mat PSC descrip;
if PSCmode > 1
nvox = size(targets,2);
else
nvox = 1;
end
regressors = size(PSC,1);
fg = se_figure('GetWin','Graphics'); WS = spm('WinScale');
set(st.mAssign,'Visible','off'); set(st.vAssign,'Visible','off');
set(st.clustBox,'Visible','off'); set(st.maxBox,'Visible','off'); set(st.cluster,'Visible','off'); set(st.maxima,'Visible','off');
st.mode = 3;
se_figure('Clear','Interactive');
if isfield(st,'hAx');
delete(st.hAx);
st = rmfield(st,'hAx');
end
if any(~isnan(sum(PSC)))
[PSCmin, PSCmax, Ay] = displayPSC(PSC(:,~isnan(sum(PSC))),regressors,[0.51 0.21 0.46 0.335],0);
switch PSCmode
case 1
text(PSCmin,Ay,sprintf('Position: x=%1.0f, y=%1.0f, z=%1.0f,',se_orthviews('pos')),'FontSize',12);
[Area, code] = hier_area;
text(PSCmin,Ay-17*WS(2),sprintf('Area: %s',Area),'FontSize',12);
case 2
text(PSCmin,Ay,['Activated voxels in area ' MAP(locNr).name],'FontSize',12);
case 4
text(PSCmin,Ay,['All ' int2str(CLUSTER(CLUSTER(1).VOL(round(xyzp(1)),round(xyzp(2)),round(xyzp(3)))).voxel(1)) ' voxels in cluster ' sprintf('%2.0f', get(st.cluster,'Value')-1)],'FontSize',12);
end
else
spm('alert"',{'No data available !'},'',0,1);
se_anatomy('Info')
end
end
% ----------------------- INITIALIZE ----------------------------
if strcmp(op,'init'),
st.pwd = pwd;
st.SPM = spm('FnBanner');
fg = se_figure('GetWin','Graphics');
se_orthviews('Interp',0)
if isempty(st.vols{1}), return; end;
se_orthviews('MaxBB');
st.callback = 'se_anatomy(''shopos'');';
st.B = [0 0 0 0 0 0 1 1 1 0 0 0];
WS = spm('WinScale');
xp = -20;
switch st.SPM
case 'SPM99'
otherwise
set(gcf,'DefaultUicontrolFontSize',spm('FontSizes',8));
xp = -30;
end
% Crosshair position
%-----------------------------------------------------------------------
% uicontrol(fg,'Style','Frame','Position',[45 110+xp 190 100].*WS,'DeleteFcn','se_anatomy(''reset'');');
uicontrol(fg,'Style','Frame','Position',[50+10 105-27 180 82].*WS);
uicontrol(fg,'Style','Text', 'Position',[55+10 166-25 170 016].*WS,'String','Crosshair Position');
uicontrol(fg,'Style','PushButton', 'Position',[55+10 161-25 170 006].*WS,...
'Callback','se_orthviews(''Reposition'',[0 0 0]);','ToolTipString','move crosshairs to origin');
uicontrol(fg,'Style','Text', 'Position',[55+10 135-25 35 020].*WS,'String','mm:');
uicontrol(fg,'Style','Text', 'Position',[55+10 115-25 35 020].*WS,'String','vx:');
uicontrol(fg,'Style','Text', 'Position',[55+10 106-25 65 014].*WS,'String','Area:');
st.mp = uicontrol(fg,'Style','edit', 'Position',[90+10 140-25 135 020].*WS,'String','','Callback','se_anatomy(''setposmm'')','ToolTipString','move crosshairs to mm coordinates');
st.vp = uicontrol(fg,'Style','edit', 'Position',[90+10 120-25 135 020].*WS,'String','','Callback','se_anatomy(''setposvx'')','ToolTipString','move crosshairs to voxel coordinates');
st.in = uicontrol(fg,'Style','Text', 'Position',[120+10 106-25 85 014].*WS,'String','');
% Assorted other buttons.
%-----------------------------------------------------------------------
uicontrol(fg,'Style','Frame','Position',[5 30+xp 270 70].*WS);
st.zoomer = uicontrol(fg,'Style','popupmenu' ,'Position',[10 75+xp 125 20].*WS,...
'String',str2mat('Full Volume','160x160x160mm','80x80x80mm','40x40x40mm','20x20x20mm','10x10x10mm'),...
'Callback','se_anatomy(''zoom_in'')','ToolTipString','zoom in by different amounts');
c = 'if get(gco,''Value'')==1, se_orthviews(''Space''), else, se_orthviews(''Space'', 1);end;se_anatomy(''zoom_in'')';
uicontrol(fg,'Style','popupmenu' ,'Position',[10 55+xp 125 20].*WS,...
'String',str2mat('World Space','Voxel Space'),...
'Callback',c,'ToolTipString','display in aquired/world orientation');
c = 'if get(gco,''Value'')==1, se_orthviews(''Xhairs'',''off''), else, se_orthviews(''Xhairs'',''on''); end;';
uicontrol(fg,'Style','togglebutton','Position',[145 75+xp 125 20].*WS,...
'String','Hide Crosshairs','Callback',c,'ToolTipString','show/hide crosshairs');
uicontrol(fg,'Style','popupmenu' ,'Position',[145 55+xp 125 20].*WS,...
'String',str2mat('NN interp','bilin interp','sinc interp'),...
'Callback','tmp_ = [0 1 -4];se_orthviews(''Interp'',tmp_(get(gco,''Value'')))',...
'Value',1,'ToolTipString','interpolation method for displaying images');
uicontrol(fg,'Style','PushButton','Position',[10 35+xp 125 20].*WS,'ForegroundColor','r','FontWeight','bold',...
'String','EXIT','Callback','se_anatomy(''exit'');','ToolTipString','quit');
if ~strcmp(st.prog,'AR')
st.blobber = uicontrol(fg,'Style','pushbutton','Position',[145 35+xp 125 20].*WS,...
'String','Add Blobs','Callback','se_anatomy(''addblobs'');','ToolTipString','superimpose activations');
end
FS = spm('FontSizes');
hFS = FS(8);
if (~strcmp(st.prog,'PX') & ~strcmp(st.prog,'AR'))
if ~isfield(st,'mAssignNr');
st.mAssignNr = 0;
end
if st.mAssignNr
Smax = 'No maximum selected'; for cl=1:st.mAssignNr; Smax = [Smax '|' 'Maximum (' sprintf('%2.0f', cl) ')']; end
else
Smax = 'No maxima found';
end
st.maxBox = uicontrol(fg,'Style','Frame','Position',[285 362 197 35].*WS);
st.maxima = uicontrol(fg,'Style','popupmenu','Position',[290 372 190 20].*WS,...
'String',str2mat(Smax),'Callback','se_anatomy(''setposmax'')','ToolTipString','move crosshairs to maximum','FontSize',hFS+1);
st.clustBox = uicontrol(fg,'Style','Frame','Position',[285 489 260 37].*WS);
st.cluster = uicontrol(fg,'Style','popupmenu','Position',[290 500 250 20].*WS,...
'String',str2mat(getCluster(2)),'Callback','se_anatomy(''setposclust'')','ToolTipString','move crosshairs to cluster','FontSize',hFS+1);
st.titel = uicontrol(fg,'Style','text','Position',[290 460 308 20].*WS,'BackgroundColor',[1 1 1],'FontWeight','bold','HorizontalAlignment','left',...
'String','','FontSize',hFS+1);
st.vAssign = uicontrol(fg,'Style','text','Position',[290 398 300 65].*WS,'BackgroundColor',[1 1 1],'HorizontalAlignment','left',...
'String',{},'FontSize',hFS);
if strcmp(st.prog,'OV')
st.mAssign = uicontrol(fg,'Style','text','Position',[290 50 300 305].*WS,'BackgroundColor',[1 1 1],'HorizontalAlignment','left',...
'String',{},'FontSize',hFS);
else
st.mAssign = uicontrol(fg,'Style','text','Position',[290 60+xp 300 300-xp].*WS,'BackgroundColor',[1 1 1],'HorizontalAlignment','left',...
'String',{},'FontSize',hFS);
end
end
if strcmp(st.prog,'AR');
displayType = 'AR';
st.blobber = uicontrol(fg,'Style','pushbutton','Position',[145+20 35+xp 125 20].*WS,...
'String','Read statistics','Callback','se_getMap(''groupStat'')','ToolTipString','load statistical data');
clust = 'No area selected';
for cl=1:size(MAP,2); clust = [clust '|' MAP(cl).name]; end
st.clustBox = uicontrol(fg,'Style','Frame','Position',[285 490 260 35].*WS);
st.cluster = uicontrol(fg,'Style','popupmenu','Position',[290 500 250 20].*WS,...
'String',str2mat(clust),'Callback','se_anatomy(''setposarea'')','ToolTipString','move crosshairs to area','FontSize',hFS+1);
st.titel = uicontrol(fg,'Style','text','Position',[290 460 300 20].*WS,'BackgroundColor',[1 1 1],'FontWeight','bold','HorizontalAlignment','left',...
'String','','FontSize',hFS+1);
elseif strcmp(st.prog,'OV');
displayType = 'OL';
st.SVC = uicontrol(fg,'Style','PushButton','Position',[300 35+xp 75 20].*WS,'FontWeight','bold',...
'String','S. V. C.','Callback','se_anatomy(''SVC'');','ToolTipString','Small volume correction');
st.Tab = uicontrol(fg,'Style','PushButton','Position',[400 35+xp 75 20].*WS,'FontWeight','bold',...
'String','Tab','Callback','se_anatomy(''Tab'');','ToolTipString','Tabelated output to file');
st.Plot = uicontrol(fg,'Style','PushButton','Position',[500 35+xp 75 20].*WS,'FontWeight','bold',...
'String','Plot','Callback','se_anatomy(''Plot'');','ToolTipString','Tabelated output to file');
elseif strcmp(st.prog,'GR')
displayType = 'GA';
st.mode = 1;
st.Info = uicontrol(fg,'Style','PushButton','Position',[300 35+xp 80 20].*WS,'FontWeight','bold',...
'String','Info','Callback','se_anatomy(''Info'');','ToolTipString','Localization of volumes and maxima');
if strcmp(st.prog,'GR')
st.PSC = uicontrol(fg,'Style','PushButton','Position',[480 35+xp 100 20].*WS,'FontWeight','bold',...
'String','% signal change','Callback','se_anatomy(''PSCG'');','ToolTipString','Calculate % signal change');
end
elseif strcmp(st.prog,'PX')
displayType = 'PX';
hFS = FS(9);
st.mAssign = uicontrol(fg,'Style','text','Position',[290 390 300 135].*WS,'BackgroundColor',[1 1 1],'HorizontalAlignment','left',...
'String',{},'FontSize',hFS);
if ~exist(xSPM)
xSPM = struct('xVOL',{});
end
xSPM(1).xVOL.M = MAP(1).MaxMap.mat;
xF = spm_figure('GetWin','Graphics'); xI = spm_figure('GetWin','Interactive');
set(xF,'visible','off'), figure(xI)
xSPM(1).xVOL.orig = spm_input_ui('Coordinates','!+1','b','Anatomical|MNI',[1 2],2,'Select mode'); set(xF,'visible','on'),
end
end;
return;
function my_reset
st.FX = findobj(get(0,'Children'),'Flat','Tag','SATB');
st.Fgraph = findobj(get(0,'Children'),'Flat','Tag','xSATB');
try; delete(st.FX); delete(st.Fgraph); end
se_figure('Clear','Graphics');
return;
function [PSCmin, PSCmax, Ay] = displayPSC(PSC,regressors,position,dotext)
global st
global group
FS = spm('FontSizes'); %-Scaled font sizes
WS = spm('WinScale');
set(st.titel,'Visible','off'); fg = se_figure('GetWin','Graphics');
st.hAx = axes('Position',position,'DefaultTextInterpreter','Tex',...
'DefaultTextVerticalAlignment','Baseline','Units','points','Visible','on');
AxPos = get(st.hAx,'Position'); Ay = floor(AxPos(4))-10;
sem = sqrt(var(PSC')/size(PSC,2)); PSCmin = min([0 min(mean(PSC')-sem*1.2)]); PSCmax = max([0 max(mean(PSC')+sem*1.2)]);
boxMax = Ay-25-regressors*35;
set(st.hAx,'YLim',[boxMax,AxPos(4)-28]); set(st.hAx,'XLim',[PSCmin,PSCmax]);
set(st.hAx,'YTick',[]); set(st.hAx,'YTickLabel',''); pp = 0;
line([PSCmin PSCmin],[Ay-19 boxMax],'Color','k');
line([PSCmax PSCmax],[Ay-19 boxMax],'Color','k');
line([PSCmin PSCmax],[boxMax boxMax],'Color','k');
line([PSCmin PSCmax],[Ay-19 Ay-19],'Color','k');
line([0 0],[Ay-19 boxMax],'Color','k','LineWidth',1);
lab = {'% signal change','(Mean and SEM indicated)'};
off = (max(max(PSCmax))-min(min(PSCmin)))*0.01;
for k = 1:regressors,
line([0 mean(PSC(k,:))],[Ay-40-pp*35 Ay-40-pp*35],'Color',[0 0 0],'LineWidth',25)
if mean(PSC(k,:))>0
line([off/2 mean(PSC(k,:))-off],[Ay-40-pp*35 Ay-40-pp*35],'Color',[0.5 0.5 0.5],'LineWidth',22)
else
line([-off/2 mean(PSC(k,:))+off],[Ay-40-pp*35 Ay-40-pp*35],'Color',[0.5 0.5 0.5],'LineWidth',22)
end
line([mean(PSC(k,:))-sem(k) mean(PSC(k,:))+sem(k)],[Ay-40-pp*35 Ay-40-pp*35],'Color',[0 0 0],'LineWidth',1)
line([mean(PSC(k,:))-sem(k) mean(PSC(k,:))-sem(k)],[Ay-45-pp*35 Ay-35-pp*35],'Color',[0 0 0],'LineWidth',1)
line([mean(PSC(k,:))+sem(k) mean(PSC(k,:))+sem(k)],[Ay-45-pp*35 Ay-35-pp*35],'Color',[0 0 0],'LineWidth',1)
text(0,Ay-40-pp*35,int2str(k),'Color','r','FontWeight','bold','FontSize',17,...
'HorizontalAlignment','Center','VerticalAlignment','Middle')
pp = pp+1;
end
xlabel(lab);
ys = get(st.hAx,'YLim');
Ay2 = boxMax-(ys(2)-ys(1))*.27;
for i=1:ceil(regressors/3)
text(PSCmin,Ay2-((i-1)*(10+regressors)),[int2str(i*3-2) ': ' getCondLabel(i*3-2) ' (' num2str(mean(PSC(i*3-2,:)),'%5.3f') ')'],'VerticalAlignment','middle','FontSize',FS(10));
if (i-1)*3+2 <= regressors
text(PSCmin+((PSCmax-PSCmin)/3)*1,Ay2-((i-1)*(10+regressors)),[int2str(i*3-1) ': ' getCondLabel(i*3-1) ' (' num2str(mean(PSC(i*3-1,:)),'%5.3f') ')'],'VerticalAlignment','middle','FontSize',FS(10))
end
if (i-1)*3+3 <= regressors
text(PSCmin+((PSCmax-PSCmin)/3)*2,Ay2-((i-1)*(10+regressors)),[int2str(i*3) ': ' getCondLabel(i*3) ' (' num2str(mean(PSC(i*3,:)),'%5.3f') ')'],'VerticalAlignment','middle','FontSize',FS(10))
end
end
function string = getCondLabel(i)
global st
global group
switch st.SPM
case 'SPM99'; strin = group(1).xSPM.Sess{1}.name{i};
otherwise, strin = group(1).xSPM.Sess(1).Fc(i).name;
end
string = strrep(strin,'0',''); string = strrep(string,'1',''); string = strrep(string,'_',' '); string = strrep(string,' ',' ');
function [Area, code] = hier_area
global MAP
global st
xyzv = se_orthviews('pos',1); locNr = 0;
aVox = find([MAP.GV] == spm_sample_vol(st.vols{1},xyzv(1),xyzv(2),xyzv(3),st.hld));
if aVox; Area = MAP(aVox).name; code = aVox;
else;
ML = spm_sample_vol(MAP(1).Macro,xyzv(1),xyzv(2),xyzv(3),0)';
code = 0;
if ML > 0;
Area = MAP(1).MLabels.Labels{ML};
else
Area = 'Unknown area';
end
end
function clu_title
global st
global SPM
global CLUSTER
if isfield(SPM,'STAT')
try
set(st.titel,'String',['Cluster ' int2str(get(st.cluster,'Value')-1) ' (' int2str(CLUSTER(get(st.cluster,'Value')-1).voxel(1)) ' vox)'...
': ' SPM.title ' ' SPM.thresDef]);
catch
set(st.titel,'String',['Cluster ' int2str(get(st.cluster,'Value')-1) ' (' int2str(CLUSTER(get(st.cluster,'Value')-1).voxel(1)) ' vox)'...
': ' SPM.title ' ( ' SPM.STAT '> ' sprintf('%4.2f', SPM.u) ')']);
end
else
titl = SPM.title;
if length(titl)>15; titl = titl(1:15); end
set(st.titel,'String',['Cluster ' int2str(get(st.cluster,'Value')-1) ' (' int2str(CLUSTER(get(st.cluster,'Value')-1).voxel(1)) ' vox)'...
': ' titl ' (u > ' sprintf('%4.2f', SPM.u) ', k > ' int2str(SPM.k) ')']);
end
[MLev, VLev, m_anz] = se_overlap(get(st.cluster,'Value')-1);
set(st.vAssign,'String',VLev); set(st.mAssign,'String',MLev); st.mAssignNr = m_anz;
Smax = 'No maximum selected';
for cl=1:st.mAssignNr;
Smax = [Smax '|' 'Maximum (' sprintf('%2.0f', cl) ')'];
end
set(st.maxima,'String',Smax,'Value',1);
function clust = getCluster(mode)
global st;
global MAP;
global SPM;
global xSPM;
global CLUSTER;
global displayType;
global group
global defaults;
if mode == 1
clust = 'No cluster selected';
for cl=1:size(CLUSTER,2)
clust = [clust '|Cluster ' sprintf('%2.0f', cl) ': x= ' sprintf('%+3.0f', mean(CLUSTER(cl).XYZmm(1,:)))...
' y= ' sprintf('%+2.0f', mean(CLUSTER(cl).XYZmm(2,:))) ' z= ' sprintf('%+2.0f', mean(CLUSTER(cl).XYZmm(3,:)))];
if xSPM.xVOL.orig == 2
clust = [clust ' (MNI: ' sprintf('%+3.0f', mean(CLUSTER(cl).XYZmm(1,:))) '/'...
sprintf('%+3.0f', mean(CLUSTER(cl).XYZmm(2,:))+4) '/' sprintf('%+3.0f', mean(CLUSTER(cl).XYZmm(3,:))-4) ')'];
end
end
else
clear clust
if prod(size(CLUSTER))>0
clust = 'No cluster selected';
for cl=1:size(CLUSTER,2)
clust = [clust '|Cluster ' sprintf('%2.0f', cl) ': x= ' sprintf('%+3.0f', mean(CLUSTER(cl).XYZmm(1,:)))...
' y= ' sprintf('%+2.0f', mean(CLUSTER(cl).XYZmm(2,:))) ' z= ' sprintf('%+2.0f', mean(CLUSTER(cl).XYZmm(3,:)))];
if xSPM.xVOL.orig == 2
clust = [clust ' (orig. MNI: ' sprintf('%+3.0f', mean(CLUSTER(cl).XYZmm(1,:))) '/'...
sprintf('%+3.0f', mean(CLUSTER(cl).XYZmm(2,:))+4) '/' sprintf('%+3.0f', mean(CLUSTER(cl).XYZmm(3,:))-4) ')'];
end
end
end
if ~exist('clust')
clust = 'No activation cluster found';
end
end
|