correct a biopac waveform collected with incorrect calibration EEG = biopac_correct_calibration(EEG,defs) This script currently only corrects scr that was not calibrated (i.e. the calibration settings were the default settings). REQUIRES EEG - an EEGlab data structure defs.biopac_correct_calibration.gain - gain setting of amplifier defs.biopac_correct_calibration.channel - name of channel RETURN EEG - an EEGlab data structure, with the given signal having been filtered FB 2009.06.10
0001 function EEG = biopac_correct_calibration(EEG,defs) 0002 0003 % correct a biopac waveform collected with incorrect calibration 0004 % 0005 % EEG = biopac_correct_calibration(EEG,defs) 0006 % 0007 % This script currently only corrects scr that was not calibrated (i.e. the 0008 % calibration settings were the default settings). 0009 % 0010 % REQUIRES 0011 % EEG - an EEGlab data structure 0012 % defs.biopac_correct_calibration.gain - gain setting of amplifier 0013 % defs.biopac_correct_calibration.channel - name of channel 0014 % 0015 % RETURN 0016 % EEG - an EEGlab data structure, with the given signal having been 0017 % filtered 0018 % 0019 % FB 2009.06.10 0020 0021 channel = defs.biopac_correct_calibration.channel; 0022 if iscell(channel), channel = channel{1}; end 0023 cidx = strmatch(channel,{EEG.chanlocs(:).labels}); 0024 if isempty(cidx) 0025 error('target channel %s can not be found within EEG.chanlocs\n',... 0026 channel); 0027 elseif length(cidx) > 1 0028 warning('many channels match target channel %s, using first one\n',... 0029 channel); 0030 cidx = cidx(1); 0031 end 0032 0033 switch channel 0034 case {'scr','gsr'} 0035 try gain = defs.biopac_correct_calibration.gain; catch gain = []; end 0036 0037 if ~isempty(gain) 0038 EEG.data(cidx,:) = EEG.data(cidx,:)*gain; 0039 else 0040 error('no gain provided for SCR calibration'); 0041 end 0042 otherwise 0043 warning('unknown channel %s',channel); 0044 end