Home > database > physio > ensemble_physio_adjust.m

ensemble_physio_adjust

PURPOSE ^

manual inspection and adjustment of physio waveforms and peaks

SYNOPSIS ^

function outdata = ensemble_physio_adjust(indata,params)

DESCRIPTION ^

 manual inspection and adjustment of physio waveforms and peaks
 
   outdata = ensemble_physio_adjust(indata,params)
 
 this script takes physiological data generated by either ensemble_physio
 or ensemble_physio_summ and imports each given signal into
 manual_adjust_signal_data, which allows for artifact correction and peak
 rejection of provided signals. The data returned from
 manual_adjust_signal_data is then re-packaged and returned as outdata
 from this script. Essentially, this script is a wrapper for
 manual_adjust_singal_data.
 
 REQUIRES
   indata - an ensemble data struct containing one or many of the
       following sub-structs:
       - 'physio_paths'
       - 'gsr_epochs'
       - 'cardiac_epochs'
   params.manual_adjust_signal_data - parameters sent to
       manual_adjust_signal_data
   params.manual_adjust_signal_data.samplingRate - if not sampling rate is
       provided within the input dataset, this sampling rate will be used
 
 OUTPUT
   outdata - structures provided within indata, after having been
       processed by manual_adjust_signal_data
 
 FB 2009.06.19

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function outdata = ensemble_physio_adjust(indata,params)
0002 
0003 % manual inspection and adjustment of physio waveforms and peaks
0004 %
0005 %   outdata = ensemble_physio_adjust(indata,params)
0006 %
0007 % this script takes physiological data generated by either ensemble_physio
0008 % or ensemble_physio_summ and imports each given signal into
0009 % manual_adjust_signal_data, which allows for artifact correction and peak
0010 % rejection of provided signals. The data returned from
0011 % manual_adjust_signal_data is then re-packaged and returned as outdata
0012 % from this script. Essentially, this script is a wrapper for
0013 % manual_adjust_singal_data.
0014 %
0015 % REQUIRES
0016 %   indata - an ensemble data struct containing one or many of the
0017 %       following sub-structs:
0018 %       - 'physio_paths'
0019 %       - 'gsr_epochs'
0020 %       - 'cardiac_epochs'
0021 %   params.manual_adjust_signal_data - parameters sent to
0022 %       manual_adjust_signal_data
0023 %   params.manual_adjust_signal_data.samplingRate - if not sampling rate is
0024 %       provided within the input dataset, this sampling rate will be used
0025 %
0026 % OUTPUT
0027 %   outdata - structures provided within indata, after having been
0028 %       processed by manual_adjust_signal_data
0029 %
0030 % FB 2009.06.19
0031 
0032 if (iscell(indata) && ~isempty(indata) && ...
0033         isfield(indata{1},'task') && ...
0034         ~isempty(strmatch('return_outdir',indata{1}.task))) || ...
0035         (isstruct(indata) && isfield(indata,'task') && ...
0036         ~isempty(strmatch('return_outdir',indata.task)))
0037   outdata = '';
0038   return
0039 elseif ~isstruct(params) || ...
0040         ~isfield(params,'ensemble_jobman_interactive') ...
0041         || ~params.ensemble_jobman_interactive
0042   outdata = '';
0043   error('please run within an interactive session');
0044 end
0045 
0046 outdata = ensemble_init_data_struct();
0047 
0048 global r
0049 
0050 r = init_results_struct;
0051 
0052 r.type = 'physio_summ';  % Identify the type of this reporting instance
0053 r.report_on_fly = 1;
0054 
0055 % convert to cell if needed
0056 if isstruct(indata), indata = {indata}; end
0057 
0058 try masdp = params.manual_adjust_signal_data; catch masdp = struct(); end
0059 
0060 % iterate over indata indices
0061 for in=1:length(indata)
0062   % get indata
0063   if isfield(indata{in},'type')
0064     switch indata{in}.type
0065       case {'gsr_epoch','cardiac_epoch','gsr_epochs','cardiac_epochs'}
0066         % load data
0067         data = indata{in};
0068         cols = set_var_col_const(data.vars);
0069         
0070         % init vars
0071         if ~isfield(cols,'signal')
0072           warning('no signal variable for indata %d, SKIPPING',in);
0073           continue
0074         else
0075           signals = data.data{cols.signal};
0076           ne = length(signals);
0077         end
0078         
0079         if isfield(cols,'srate')
0080           srates = data.data{cols.srate};
0081         elseif ~isfield(params,'srate')
0082           srates = repmat(params.srate,ne,1);
0083         else
0084           warning('no sampling rate for indata %d, SKIPPING',in);
0085           continue
0086         end
0087         
0088         if isfield(cols,'pidxs')
0089           peaks = data.data{cols.pidxs};
0090           pcol = 'pidxs';
0091         elseif isfield(cols,'peakidxs')
0092           peaks = data.data{cols.peakidxs};
0093           pcol = 'peakidxs';
0094         else
0095           peaks = cell(ne,1);
0096           pcol = '';
0097         end
0098 
0099         if ~isfield(cols,'subject_id')
0100           warning('no subject info in indata %d',in);
0101           subids = [];
0102         else
0103           subids = data.data{cols.subject_id};
0104         end
0105 
0106         % iterate over epochs
0107         for ie=1:ne
0108           % set sampling rate
0109           masdp.samplingRate = srates(ie);
0110           if ~isempty(subids)
0111             vars = {sprintf('subject: %s, epoch %1.0f',subids{ie},ie)};
0112           else
0113             vars = {sprintf('epoch %1.0f',ie)};
0114           end
0115 
0116           % edit epoch
0117           [lsig,lpeaks] = manual_adjust_signal_data('signal',signals{ie},...
0118               'peaks',peaks(ie),'params',masdp,'vars',vars);
0119           
0120           % repack data
0121           data.data{cols.signal}{ie} = lsig;
0122           if ~isempty(pcol)
0123             data.data{cols.(pcol)}{ie} = lpeaks;
0124           end
0125         end
0126 
0127         outdata.vars = [outdata.vars data.type];
0128         outdata.data = [outdata.data data];
0129       case {'physio_paths'}
0130         warning('this option is not yet supported, SKIPPING');
0131       otherwise
0132         warning('unknown type %s, SKIPPING',indata{in}.type);
0133     end % switch indata{in}.type
0134   end % if isfield(indata{in},'type
0135 end % for in=1:length(indata

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003