function getTrialParameters(obj) %GETPARAMETERS Extract additional trial parameters from saved DAQ data % BASED ON SlidebookObj\getTrialParameters by Ben % KYC 1/31/2020 % % Function 'getTrialtimes' extract the minimum data required for a basic analysis. % This function extracts any additional data. % % Subfunctions do the basic detection of peaks etc. on signals. These % should generally be left alone - just modify the input arguments to % tweak. This parent function assigns parameters to the object and is the % one that should be customized if needed. % % Currently, the function saves to the object: % % Different values per trial: all [1 x numTrials] arrays: % obj.TrialPatNum Voltage level on DAQ(:,2) multiplied by 2 * % obj.TrialSeqNum Voltage level on DAQ(:,3) multiplied by 5; % UNUSED % obj.TrialOdor Voltage level on DAQ(:,1); % obj.TrialWBAleft Voltage level on DAQ(:,5) for left winbgeat % amplitude % obj.TrialWBAright Voltage level on DAQ(:,6) for right WBA % obj.TrialYGain Panels Y gain from DAQ(:,4)? % obj.TrialWBF Voltage level on DAQ(:,7) for wingbeat % frequency % % Note: % The default behaviour is panels X data on ch5 | Y data on ch4 % This can be reversed by assigning the following parameter value: % obj.SwitchXYDaqChans = 1 % % Similarly, default is Pattern Number on ch2 | Sequence Numbero n ch3 % This can be reversed by assigning the following parameter value: % obj.SwitchPatSeqDaqChans = 1 % % Same values for entire object: % obj.ExpXGains Array of X gains used in experiment % obj.ExpYGains Array of Y gains used in experiment % obj.ExpXOnTime Median stimulus onset/offset, in seconds % obj.ExpXOffTime (relative to trial onset: used to indicate % obj.ExpYOnTime stimulus region in 'plotTrials') % obj.ExpYOffTime % % To be added, if required: % Stimulus position (static) % Timing of changes in static stim position % % See also getTrialtimes, getDaqData, getFrametimes. %{ if isempty(obj.Abf) getAbfData(obj) end %} if isempty(obj.TrialStartSample) getTrialtimes(obj); end wstim = obj.Daq; % For each trial find some parameters from the Abf file: % for each trial, % for each channel (except Abf(:,1)) % get voltage level or slope ch6 = []; ch7 = []; for tidx = 1:length(obj.TrialStartSample) % Get ch1 mean voltage within trials ch1(tidx) = round(mean(wstim(obj.TrialStartSample(tidx):obj.TrialEndSample(tidx), 1))); % Get ch2 mean voltage within trials *2 ch2(tidx) = round(mean( wstim( obj.TrialStartSample(tidx) : obj.TrialEndSample(tidx) ,2) )*2); % Get ch3 mean voltage within trials ch3(tidx) = mean(wstim( obj.TrialStartSample(tidx) : obj.TrialEndSample(tidx) ,3) ); % % % If they exist, get mean voltages within trials on channels 6 and 7 % if size(wstim,2) >= 6 % % voltage amplitude wstim(:,6) % ch6(tidx) = mean(wstim( obj.TrialStartSample(tidx) : obj.TrialEndSample(tidx) ,6) ); % end % % if size(wstim,2) >= 7 % % voltage amplitude wstim(:,7) % ch7(tidx) = mean(wstim( obj.TrialStartSample(tidx): obj.TrialEndSample(tidx) ,7) ); % end % end % Get Panels x- and y-gain values (not assigned at this point): panels_refresh_rate = 50; % Approximate value is sufficient - used as a threshold % ch4gain = detectAxoTrialGains(obj, 4, panels_refresh_rate); % ch5gain = detectAxoTrialGains(obj, 5, panels_refresh_rate); % % Push to object: % X and Y Gains % Default behaviour is x on ch5, y on ch4 % These can be reversed by adding a property to the object and setting it % to 1: % if isprop(obj,'SwitchXYAbfChans') && ~isempty(obj.SwitchXYAbfChans) && obj.SwitchXYAbfChans == 1 % obj.TrialXGain = ch4gain; % % obj.TrialYGain = ch5gain; % obj.ExpXGains = unique(obj.TrialXGain); % % else % % obj.TrialXGain = ch5gain; % obj.TrialYGain = ch4gain; % % obj.ExpYGains = unique(obj.TrialYGain); % % end % Ch2 and Ch3 data % Default behaviour is patternNum on ch2, sequenceNum on ch3 % These can also be reversed by adding a property to the object and setting it % to 1: % wstim(:,2) voltage x 5 % wstim(:,7) voltage x 5 if isprop(obj,'SwitchPatSeqAbfChans') && ~isempty( obj.SwitchPatSeqAbfChans ) && obj.SwitchPatSeqAbfChans == 1 obj.TrialPatNum = round(ch3); obj.TrialSeqNum = (ch2); obj.TrialOdorNum = ch1; else obj.TrialPatNum = ch2; obj.TrialSeqNum = (ch3); obj.TrialOdorNum = ch1; end % % Display results % disp(['ExpXGains found: [' regexprep(num2str(obj.ExpXGains),'\s{1,}',' ') ']']); % disp(['ExpYGains found: [' regexprep(num2str(obj.ExpYGains),'\s{1,}',' ') ']']); % % Now get stimulus onset/offsets from ch4 and ch5 ( relies on obj.TrialXGain % and obj.TrialYgain that we just found, so this must be run after previous % info has already been found) disp('Done.') end