1 | function basic_fmri_analysis(DATA,ROI,AddInfo) |
---|
2 | % |
---|
3 | % This Aedes plugin does a quick basic fMRI analysis. |
---|
4 | % |
---|
5 | |
---|
6 | if AddInfo.isDataMixed |
---|
7 | return |
---|
8 | end |
---|
9 | |
---|
10 | % Prompt for design and contrast |
---|
11 | prompt={'Stimulus onsets (scans):','Stimulus durations (scans):',... |
---|
12 | 'Contrast vector','Smooth FWHM','TR','High-pass filter cutoff (sec.)',... |
---|
13 | 'P-value for FDR correction','Volumes to omit from analysis'}; |
---|
14 | name='Enter parameters for fMRI analysis'; |
---|
15 | numlines=1; |
---|
16 | defaultanswer={'30 75 120','15 15 15','1 0',... |
---|
17 | '2 2 1','2.039','256','0.05',''}; |
---|
18 | |
---|
19 | resp=inputdlg(prompt,name,numlines,defaultanswer); |
---|
20 | if isempty(resp) |
---|
21 | % Canceled |
---|
22 | return |
---|
23 | end |
---|
24 | |
---|
25 | % Call fmri_analysis in /misclib |
---|
26 | onset = str2num(resp{1}); |
---|
27 | durat = str2num(resp{2}); |
---|
28 | contr = str2num(resp{3}); |
---|
29 | if length(contr)~=2 |
---|
30 | errordlg('Invalid contrast vector!','Error','modal'); |
---|
31 | return |
---|
32 | end |
---|
33 | smooth_sz = str2num(resp{4}); |
---|
34 | TR = str2num(resp{5}); |
---|
35 | hipass = str2num(resp{6}); |
---|
36 | qFDR = str2num(resp{7}); |
---|
37 | omitVols = str2num(strrep(resp{8},'end',num2str(size(DATA{1}.FTDATA,4)))); |
---|
38 | |
---|
39 | % if isfield(DATA{1},'PROCPAR') && isfield(DATA{1}.PROCPAR,'readres') |
---|
40 | % % Remove reference image from VNMR EPI data |
---|
41 | % DATA{1}.FTDATA = DATA{1}.FTDATA(:,:,:,2:end); |
---|
42 | % end |
---|
43 | |
---|
44 | if length(durat)==1 |
---|
45 | durat = ones(1,length(onset))*durat; |
---|
46 | end |
---|
47 | |
---|
48 | [maps_out,fdr_th] = fmri_analysis(DATA{1},'TR',TR,... |
---|
49 | 'onsets',onset,'durations',durat,... |
---|
50 | 'contrast',contr,'smooth',smooth_sz,'FDRth',qFDR,... |
---|
51 | 'hipass',hipass,'omitvolumes',omitVols); |
---|
52 | |
---|
53 | % Resize tmap to EPI time series size |
---|
54 | tmap = maps_out.tmap; |
---|
55 | tmap = repmat(tmap,[1,1,1,size(DATA{1}.FTDATA,4)]); |
---|
56 | |
---|
57 | overlay.FTDATA = tmap; |
---|
58 | overlay.ImageOverlayCmapStr = 'hot'; |
---|
59 | overlay.ImageOverlayTholdDirPos = 1; |
---|
60 | overlay.ImageOverlayAlpha = 1; |
---|
61 | overlay.fMRIonsets = onset; |
---|
62 | overlay.fMRIdurats = durat; |
---|
63 | if ~isempty(fdr_th) |
---|
64 | overlay.ImageOverlayThold = fdr_th; |
---|
65 | overlay.ImOverlayMin = 0; |
---|
66 | else |
---|
67 | overlay.ImageOverlayAlpha = 0; |
---|
68 | end |
---|
69 | |
---|
70 | % If some volumes were omitted, calculate new onsets and durations |
---|
71 | if ~isempty(omitVols) |
---|
72 | % create stick function |
---|
73 | ton = onset; |
---|
74 | tof = onset+durat+1; |
---|
75 | tmp=zeros(1,size(DATA{1}.FTDATA,4)); |
---|
76 | tmp(ton)=1;tmp(tof)=-1; |
---|
77 | sf=cumsum(tmp); |
---|
78 | sf(omitVols)=[]; |
---|
79 | tmp=diff([0 sf]); |
---|
80 | new_onset = find(tmp==1); |
---|
81 | new_durat = find(tmp==-1)-new_onset-1; |
---|
82 | overlay.fMRIonsets = new_onset; |
---|
83 | overlay.fMRIdurats = new_durat; |
---|
84 | DATA{1}.FTDATA(:,:,:,omitVols)=[]; |
---|
85 | overlay.FTDATA(:,:,:,omitVols)=[]; |
---|
86 | end |
---|
87 | |
---|
88 | % Show in Aedes as overlay |
---|
89 | aedes(DATA,[],overlay); |
---|
90 | |
---|
91 | if isempty(fdr_th) |
---|
92 | warndlg(['No significant voxels over FDR threshold at p < ',... |
---|
93 | num2str(qFDR),'!'],'No significant voxels!','modal') |
---|
94 | end |
---|
95 | |
---|
96 | |
---|