source: plugins/fmri_plugins/basic_fmri_analysis.m @ 78

Last change on this file since 78 was 78, checked in by tjniskan, 10 years ago
  • Moved fMRI related plugins to their own subdirectories
  • Created a subdirectory for map calculation plugins and added a few

basic plugins for those. At the moment these plugins do not support
masking etc. and I didn't test them at all so be cautious...

  • Made a minor memory optimation to an2_readfid.m
  • Fixed a few issues in files related updating via SVN
  • Disabled some annoying warnings that Matlab R2008a and higher

generate from uitree and uitreenode functions inan2_juigetfiles.m

  • Coded something minor to an2_maptool.m. This is still stub and does

not work at all. Please don't try to use it.

  • Fixed a bug that caused Aedes to fail without generating an error

when reading VNMR FID-files that don't have PROCPAR in the same folder.

  • Fixed a javaFrame -warning (with R2008a and higher) in aedes.m

M an2_revision.m
M an2_data_read.m
M an2_maptool.m
M aedes.m
D plugins/calculate_t2_map.m
D plugins/calculate_t1r_map.m
D plugins/basic_fmri_analysis.m
D plugins/resting_state_fc.m
A plugins/fmri_plugins
A plugins/fmri_plugins/basic_fmri_analysis.m
A plugins/fmri_plugins/resting_state_fc.m
A plugins/map_plugins
A plugins/map_plugins/t2.m
A plugins/map_plugins/t1_3_parameter_fit.m
A plugins/map_plugins/t1_saturation_recovery.m
A plugins/map_plugins/t1_rho.m
A plugins/map_plugins/t2_rho.m
A plugins/map_plugins/t1_inversion_recovery.m
M an2_readfid.m
M an2_check_updates.m
M an2_juigetfiles.m
M an2_update.m

File size: 2.9 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
48if ~isempty(ROI) && any(strcmpi({ROI(:).label},'mask'))
49  roi_ind = find(strcmpi({ROI(:).label},'mask'));
50  [maps_out,fdr_th] = fmri_analysis(DATA{1},'TR',TR,...
51    'onsets',onset,'durations',durat,...
52    'contrast',contr,'smooth',smooth_sz,'FDRth',qFDR,...
53    'hipass',hipass,'omitvolumes',omitVols,...
54    'mask',ROI(roi_ind).voxels{1}(:,:,:,1));
55else
56  [maps_out,fdr_th] = fmri_analysis(DATA{1},'TR',TR,...
57    'onsets',onset,'durations',durat,...
58    'contrast',contr,'smooth',smooth_sz,'FDRth',qFDR,...
59    'hipass',hipass,'omitvolumes',omitVols);
60end
61
62% Resize tmap to EPI time series size
63tmap = maps_out.tmap;
64tmap = repmat(tmap,[1,1,1,size(DATA{1}.FTDATA,4)]);
65
66overlay.FTDATA = tmap;
67overlay.ImageOverlayCmapStr = 'hot';
68overlay.ImageOverlayTholdDirPos = 1;
69overlay.ImageOverlayAlpha = 1;
70overlay.fMRIonsets = onset;
71overlay.fMRIdurats = durat;
72if ~isempty(fdr_th)
73  overlay.ImageOverlayThold = fdr_th;
74  overlay.ImOverlayMin = 0;
75else
76  overlay.ImageOverlayAlpha = 0;
77end
78
79% If some volumes were omitted, calculate new onsets and durations
80if ~isempty(omitVols)
81  % create stick function
82  ton = onset;
83  tof = onset+durat+1;
84  tmp=zeros(1,size(DATA{1}.FTDATA,4));
85  tmp(ton)=1;tmp(tof)=-1;
86  sf=cumsum(tmp);
87  sf(omitVols)=[];
88  tmp=diff([0 sf]);
89  new_onset = find(tmp==1);
90  new_durat = find(tmp==-1)-new_onset-1;
91  overlay.fMRIonsets = new_onset;
92  overlay.fMRIdurats = new_durat;
93  DATA{1}.FTDATA(:,:,:,omitVols)=[];
94  overlay.FTDATA(:,:,:,omitVols)=[];
95end
96
97% Show in Aedes as overlay
98aedes(DATA,[],overlay);
99
100if isempty(fdr_th)
101  warndlg(['No significant voxels over FDR threshold at p < ',...
102    num2str(qFDR),'!'],'No significant voxels!','modal')
103end
104
105
Note: See TracBrowser for help on using the repository browser.

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