Home > marsbar > @mardo > event_signal.m

event_signal

PURPOSE ^

method to compute % signal change from fMRI events

SYNOPSIS ^

function s = event_signal(D, e_spec, dur, diff_func, varargin)

DESCRIPTION ^

 method to compute % signal change from fMRI events
 FORMAT s = event_signal(D, e_spec, dur, diff_func, varargin)
 
 D          - design
 e_spec     - 2 by N array specifying events to combine
                 with row 1 giving session number
                 and row 2 giving event number in session
                 This may in due course become an object type
 dur        - duration in seconds of event to estimate for
 diff_func  - function to calculate signal change from canonical event
              one of 'max', 'max-min', 'abs max', 'abs max-min', 'window'
 varargin   - any needed arguments for diff_func
              No arguments are needed for 
              'max', 'max-min', 'abs max','abs max-min'
              For 'window', you need a 1x2 vector with the time in
              seconds over which to take the mean, and the length in
              seconds of a time bin for the basis functions (returned
              for example by bf_dt(my_design)
  
 Returns
 s          - average % signal change over the events
              1 by n_regions vector

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function s = event_signal(D, e_spec, dur, diff_func, varargin)
0002 % method to compute % signal change from fMRI events
0003 % FORMAT s = event_signal(D, e_spec, dur, diff_func, varargin)
0004 %
0005 % D          - design
0006 % e_spec     - 2 by N array specifying events to combine
0007 %                 with row 1 giving session number
0008 %                 and row 2 giving event number in session
0009 %                 This may in due course become an object type
0010 % dur        - duration in seconds of event to estimate for
0011 % diff_func  - function to calculate signal change from canonical event
0012 %              one of 'max', 'max-min', 'abs max', 'abs max-min', 'window'
0013 % varargin   - any needed arguments for diff_func
0014 %              No arguments are needed for
0015 %              'max', 'max-min', 'abs max','abs max-min'
0016 %              For 'window', you need a 1x2 vector with the time in
0017 %              seconds over which to take the mean, and the length in
0018 %              seconds of a time bin for the basis functions (returned
0019 %              for example by bf_dt(my_design)
0020 %
0021 % Returns
0022 % s          - average % signal change over the events
0023 %              1 by n_regions vector
0024 %
0025 % $Id$
0026 
0027 if nargin < 2
0028   error('Need event specification');
0029 end
0030 if nargin < 3
0031   dur = 0;
0032 end
0033 if nargin < 4
0034   diff_func = '';
0035 end
0036 if isempty(diff_func)
0037   diff_func = 'abs max';
0038 end
0039 
0040 if ~is_fmri(D) | isempty(e_spec)
0041   s = [];
0042   return
0043 end
0044 if ~is_mars_estimated(D)
0045   error('Need a MarsBaR estimated design');
0046 end
0047 if size(e_spec, 1) == 1, e_spec = e_spec'; end
0048 
0049 e_s_l = size(e_spec, 2);
0050 s     = 0;
0051 s_mus = block_means(D);
0052 SPM   = des_struct(D);
0053 for e_i = 1:e_s_l
0054   es    = e_spec(:, e_i);
0055   ss    = es(1);
0056   Yh    = event_fitted(D, es, dur);
0057   d     = pr_ev_diff(Yh, diff_func, varargin{:});
0058   s     = s + d ./ s_mus(ss,:);
0059 end
0060 s = s / e_s_l * 100;

Generated on Thu 17-Mar-2016 01:14:46 by m2html © 2005