0001 function [K, LFstr, HFstr] = pr_get_filter(RT, row)
0002
0003
0004
0005
0006
0007
0008
0009 if nargin < 2
0010 error('Need TR, row / Sess matrix');
0011 end
0012
0013
0014 nsess = length(row);
0015
0016
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
0027 BM = 0;
0028
0029
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
0042
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
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
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
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
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
0106
0107 K = pr_spm_filter('set',K);
0108