My apologies, I have a simple problem.
I have:
i) two sets of contrast images
ii) would like to do a T-test with FDR correction
I have done a t test using MATLAB (see attached code), but unfortunately do not have easy access to code for FDR correction in MATLAB.
I thought the corresponding SPM code might be fairly simple - any ideas?
Thank you
Misha
p.s. I would prefer to do this through code and _not_ through the GUI. Thank you
--
Misha Koshelev
MD/PhD Student
Human Neuroimaging Laboratory
One Baylor Plaza
S104
Baylor College of Medicine
Houston, TX 77030
function ttest6(runid,imgs)
% Perform a ttest on beta images. Creates two images as output
% corresponding to ttest's h and p parameters.
%
% Purpose: Verify our beta maps satisfy King-Casas et al 2008 results.
%
% input:
% runid - unique run identifier for all groups
% imgs - which images to use (folder names)
%
% Misha Koshelev
% March 4th, 2010
% Montague Laboratory
if ~exist('runid')
runid='600';
end
source=['/mnt/nfs/proj/trust_agnostic',filesep,runid];
target=[source,filesep,'other',filesep,'ttest'];
if ~exist(source,'dir')
keyboard
end
% if exist(target,'dir')
% system(['rm -rf ',target]);
% end
if ~exist(target,'dir')
mkdir(target);
end
warning off;
% save paths
paths=path;pwds=pwd;
addpath(genpath(pwd));
img=dir(source);
if length(img)>=2
img(1:2)=[];
end
img(find(~[img.isdir]))=[];
img(find(strcmp({img.name},'other')))=[];
if ~exist('imgs','var')
fprintf('Images:\n');
for i=1:length(img)
fprintf('%d. %s\n',i,img(i).name);
end
return;
else
suffix='';
for idx=1:length(imgs)
i=imgs(idx);
if idx>1
suffix=[suffix,'_'];
end
suffix=[suffix,img(i).name];
end
end
if length(imgs)~=1&&length(imgs)~=2
keyboard
end
M=cell(length(imgs),1);
for idx=1:length(imgs)
i=imgs(idx);
f=dir([source,filesep,img(i).name,filesep,'*.img']);
if length(f)>2
f(1:2)=[];
end
M{idx}=Inf*ones(length(f),41,48,35);
for j=1:length(f)
V=spm_vol([source,filesep,img(i).name,filesep,f(j).name]);
M{idx}(j,:,:,:)=spm_read_vols(V);
end
end
if length(imgs)==1
[h,p,ci,stats]=ttest(M{1});
else
[h,p,ci,stats]=ttest2(M{1},M{2});
end
V.fname=[target,filesep,'h_',suffix,'.img'];
spm_write_vol(V,squeeze(h));
V.fname=[target,filesep,'p_',suffix,'.img'];
spm_write_vol(V,squeeze(p));
save([target,filesep,'ttest_',suffix,'.mat'],'h','p','ci','stats');
% restore paths
path(paths);
cd(pwds);
warning on;
function ttest6(runid,imgs)
% Perform a ttest on beta images. Creates two images as output
% corresponding to ttest's h and p parameters.
%
% Purpose: Verify our beta maps satisfy King-Casas et al 2008 results.
%
% input:
% runid - unique run identifier for all groups
% imgs - which images to use (folder names)
%
% Misha Koshelev
% March 4th, 2010
% Montague Laboratory
if ~exist('runid')
runid='600';
end
source=['/mnt/nfs/proj/trust_agnostic',filesep,runid];
target=[source,filesep,'other',filesep,'ttest'];
if ~exist(source,'dir')
keyboard
end
% if exist(target,'dir')
% system(['rm -rf ',target]);
% end
if ~exist(target,'dir')
mkdir(target);
end
warning off;
% save paths
paths=path;pwds=pwd;
addpath(genpath(pwd));
img=dir(source);
if length(img)>=2
img(1:2)=[];
end
img(find(~[img.isdir]))=[];
img(find(strcmp({img.name},'other')))=[];
if ~exist('imgs','var')
fprintf('Images:\n');
for i=1:length(img)
fprintf('%d. %s\n',i,img(i).name);
end
return;
else
suffix='';
for idx=1:length(imgs)
i=imgs(idx);
if idx>1
suffix=[suffix,'_'];
end
suffix=[suffix,img(i).name];
end
end
if length(imgs)~=1&&length(imgs)~=2
keyboard
end
M=cell(length(imgs),1);
for idx=1:length(imgs)
i=imgs(idx);
f=dir([source,filesep,img(i).name,filesep,'*.img']);
if length(f)>2
f(1:2)=[];
end
M{idx}=Inf*ones(length(f),41,48,35);
for j=1:length(f)
V=spm_vol([source,filesep,img(i).name,filesep,f(j).name]);
M{idx}(j,:,:,:)=spm_read_vols(V);
end
end
if length(imgs)==1
[h,p,ci,stats]=ttest(M{1});
else
[h,p,ci,stats]=ttest2(M{1},M{2});
end
V.fname=[target,filesep,'h_',suffix,'.img'];
spm_write_vol(V,squeeze(h));
V.fname=[target,filesep,'p_',suffix,'.img'];
spm_write_vol(V,squeeze(p));
save([target,filesep,'ttest_',suffix,'.mat'],'h','p','ci','stats');
% restore paths
path(paths);
cd(pwds);
warning on;
|