Home > marsbar > @mardo_99 > private > pr_get_filter.m

pr_get_filter

PURPOSE ^

gets filter using spm_fmri_spm_ui routines

SYNOPSIS ^

function [K, LFstr, HFstr] = pr_get_filter(RT, row)

DESCRIPTION ^

 gets filter using spm_fmri_spm_ui routines
 FORMAT [K, LFstr, HFstr]= pr_get_filter(RT, row)
 or
 FORMAT [K, LFstr, HFstr]= pr_get_filter(RT, Sess)

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [K, LFstr, HFstr] = pr_get_filter(RT, row)
0002 % gets filter using spm_fmri_spm_ui routines
0003 % FORMAT [K, LFstr, HFstr]= pr_get_filter(RT, row)
0004 % or
0005 % FORMAT [K, LFstr, HFstr]= pr_get_filter(RT, Sess)
0006 %
0007 % $Id$
0008   
0009 if nargin < 2
0010   error('Need TR, row / Sess matrix');
0011 end
0012 
0013 % number of sessions
0014 nsess = length(row);
0015 
0016 % rows from Sess
0017 if isfield(row{1}, 'row')
0018   Sess = row;
0019   for s = 1:nsess
0020     row{s} = Sess{s}.row;
0021   end
0022 else
0023   Sess = [];
0024 end
0025 
0026 % copied from spm_fmri_spm_ui
0027 BM = 0;
0028 
0029 % High-pass filtering
0030 %-----------------------------------------------------------------------
0031 if BM
0032     cLF = 'none';
0033 else
0034     cLF = spm_input('High-pass filter?','+1','b','none|specify');
0035 end
0036 switch cLF
0037 
0038     case 'specify'
0039 
0040     if ~isempty(Sess)
0041     % default based on peristimulus time
0042     % param = cut-off period (max = 512, min = 32)
0043     %---------------------------------------------------------------
0044     HParam = 512*ones(1,nsess);
0045     for  i = 1:nsess
0046         for j = 1:length(Sess{i}.pst)
0047            HParam(i) = min([HParam(i) 2*max(RT + Sess{i}.pst{j})]);
0048         end
0049     end
0050     HParam = ceil(HParam);
0051     HParam(HParam < 32) = 32;
0052     else % don't have SPM to work from
0053       HParam = 120 * ones(1,nsess);
0054     end
0055     str    = 'session cutoff period (secs)';
0056     HParam = spm_input(str,'+1','e',HParam,[1 nsess]);
0057 
0058     % LF description
0059     %---------------------------------------------------------------
0060     LFstr = sprintf('[min] Cutoff period %d seconds',min(HParam));
0061 
0062     case 'none'
0063     %---------------------------------------------------------------
0064     HParam = cell(1,nsess);
0065     LFstr  = cLF;
0066 
0067 end
0068 
0069 
0070 % Low-pass filtering
0071 %-----------------------------------------------------------------------
0072 if BM
0073     cHF = 'none';
0074 else
0075     cHF = spm_input('Low-pass filter?','+1','none|Gaussian|hrf');
0076 
0077 
0078 end
0079 switch cHF
0080 
0081     case 'Gaussian'
0082     %---------------------------------------------------------------
0083     LParam  = spm_input('Gaussian FWHM (secs)','+1','r',4);
0084     HFstr   = sprintf('Gaussian FWHM %0.1f seconds',LParam);
0085     LParam  = LParam/sqrt(8*log(2));
0086 
0087     case {'hrf', 'none'}
0088     %---------------------------------------------------------------
0089     LParam  = [];
0090     HFstr   = cHF;
0091 
0092 end
0093 
0094 % create filter struct and band-pass specification
0095 %-----------------------------------------------------------------------
0096 for i = 1:nsess
0097     K{i} = struct(    'HChoice',    cLF,...
0098             'HParam',    HParam(i),...
0099             'LChoice',    cHF,...
0100             'LParam',    LParam,...
0101             'row',        row{i},...
0102             'RT',        RT);
0103 end
0104 
0105 % Construct K struct
0106 %=======================================================================
0107 K       = pr_spm_filter('set',K);
0108         

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019