source: misclib/filter_fmri_data.m @ 37

Last change on this file since 37 was 37, checked in by tjniskan, 11 years ago
  • Renamed analyze2.m to aedes.m
  • Changed all references to "Analyze2" -> "Aedes" (hopefully I didn't

break anything...)

  • Added some nifti-tools to misclib
  • Fixed bug in an2_readfid.m that occurred when reading EPI-data

(thanks Teemu)

M an2_export_gui.m
D analyze2.m
M an2_getfilefilter.m
M an2_calc_wait.m
A misclib/nifti4dto3d.m
A misclib/nifti3dto4d.m
A misclib/filter_fmri_data.m
M misclib/dcm_info.m
M an2_cellwrite.m
M an2_revision.m
M startup.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
D about_analyze2.png
M an2_resviewer.m
M an2_maptool.m
A aedes.m
M an2_helpabout.m
M plugins/save_roi_as_mask.m
M plugins/calculate_t2_map.m
M an2_inputdlg.m
M an2_readctdata.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.m
M an2_check_updates.m
A about_aedes.png
M an2_saveres.m
M an2_editstack.m
M an2_errordump.m
M an2_update.m
M an2_write_nifti.m

File size: 1.4 KB
Line 
1function filter_fmri_data()
2
3if nargin==0
4  % Prompt for the input file
5  [fname,fpath,findex] = uigetfile({'*.nii','4D NIfTI Files (*.nii)';...
6        '*.*','All Files (*.*)'},'Select 4D NIfTI file');
7  if isequal(fname,0)
8        % Canceled
9        return
10  end
11  infile = fullfile(fpath,fname);
12end
13
14if nargin==0
15  % Prompt for the output file
16  [fn,fp] = uiputfile({'*.nii','NIfTI files (*.nii)';...
17        '*.*','All Files (*.*)'},'Select output file',...
18        '4D_nifti.nii');
19  if isequal(fn,0)
20        % Canceled
21        return
22  end
23  outfile = fullfile(fp,fn);
24end
25
26% Read the data
27data = an2_read_nifti(infile);
28if length(size(data.FTDATA))<4
29  error('Input data has to be 4D data!')
30end
31
32% High-pass cutoff
33hp_co = 0.009;
34lp_co = 0.085;
35TR = 1.7;
36
37% High pass filter
38[B_hi,A_hi]=butter(8,hp_co/((1/TR)/2),'high');
39
40% Low-pass filter
41[B_lo,A_lo]=butter(15,lp_co/((1/TR)/2),'low');
42
43% Waitbar
44wbh=an2_wbar(0,'Filtering image data...');
45
46counter=1;
47sz=size(data.FTDATA);
48nVox = prod(sz(1:3));
49for ii=1:size(data.FTDATA,1)
50  for kk=1:size(data.FTDATA,2)
51        for zz=1:size(data.FTDATA,3)
52          tmp = squeeze(double(data.FTDATA(ii,kk,zz,:)));
53          data.FTDATA(ii,kk,zz,:) = filtfilt(B_lo,A_lo,filtfilt(B_hi,A_hi,tmp))+mean(tmp);
54          an2_wbar(counter/nVox,wbh)
55          counter=counter+1;
56        end
57  end
58end
59close(wbh)
60
61
62% Write new 4D NIfTI  image
63cwh = an2_calc_wait(sprintf('Writing 4D NIfTI file:\n%s',outfile));
64an2_write_nifti(data,outfile);
65delete(cwh)
66
67
Note: See TracBrowser for help on using the repository browser.

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