source: plugins/basic_fmri_analysis.m @ 74

Last change on this file since 74 was 71, checked in by tjniskan, 11 years ago
  • Added support for VNMRj EPIs (linear and central) with phase

correction in an2_readfid.m.

  • Added possibility to omit volumes from fMRI analysis

(fmri_analysis.m and plugins/basic_fmri_analysis.m)

  • Fixed few minor bugs in aedes.m
  • Added misclib/tdist.m which removes Statistics toolbox dependence

from fmri_analysis.m

A misclib/tdist.m
M misclib/fmri_analysis.m
M an2_revision.m
M aedes.m
M plugins/basic_fmri_analysis.m
M an2_readfid.m

File size: 2.5 KB
Line 
1function basic_fmri_analysis(DATA,ROI,AddInfo)
2%
3% This Aedes plugin does a quick basic fMRI analysis.
4%
5
6if AddInfo.isDataMixed
7  return
8end
9
10% Prompt for design and contrast
11prompt={'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'};
14name='Enter parameters for fMRI analysis';
15numlines=1;
16defaultanswer={'30 75 120','15 15 15','1 0',...
17  '2 2 1','2.039','256','0.05',''};
18
19resp=inputdlg(prompt,name,numlines,defaultanswer);
20if isempty(resp)
21  % Canceled
22  return
23end
24
25% Call fmri_analysis in /misclib
26onset = str2num(resp{1});
27durat = str2num(resp{2});
28contr = str2num(resp{3});
29if length(contr)~=2
30  errordlg('Invalid contrast vector!','Error','modal');
31  return
32end
33smooth_sz = str2num(resp{4});
34TR = str2num(resp{5});
35hipass = str2num(resp{6});
36qFDR = str2num(resp{7});
37omitVols = 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
44if length(durat)==1
45  durat = ones(1,length(onset))*durat;
46end
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
54tmap = maps_out.tmap;
55tmap = repmat(tmap,[1,1,1,size(DATA{1}.FTDATA,4)]);
56
57overlay.FTDATA = tmap;
58overlay.ImageOverlayCmapStr = 'hot';
59overlay.ImageOverlayTholdDirPos = 1;
60overlay.ImageOverlayAlpha = 1;
61overlay.fMRIonsets = onset;
62overlay.fMRIdurats = durat;
63if ~isempty(fdr_th)
64  overlay.ImageOverlayThold = fdr_th;
65  overlay.ImOverlayMin = 0;
66else
67  overlay.ImageOverlayAlpha = 0;
68end
69
70% If some volumes were omitted, calculate new onsets and durations
71if ~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)=[];
86end
87
88% Show in Aedes as overlay
89aedes(DATA,[],overlay);
90
91if isempty(fdr_th)
92  warndlg(['No significant voxels over FDR threshold at p < ',...
93    num2str(qFDR),'!'],'No significant voxels!','modal')
94end
95
96
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008