46 lines
1.3 KiB
Mathematica
46 lines
1.3 KiB
Mathematica
|
function[time trace] = getTrialDataShiftedForMarker(trial, type, baseline_corrected, marker)
|
||
|
%% get signal pivoted based on marker
|
||
|
|
||
|
time = [];
|
||
|
trace = [];
|
||
|
|
||
|
if baseline_corrected
|
||
|
signals = trial.data.baseline_corrected;
|
||
|
fields = fieldnames(signals);
|
||
|
else
|
||
|
signals = trial.data.uncorrected;
|
||
|
fields = fieldnames(signals);
|
||
|
end
|
||
|
|
||
|
if ismember(type, fields)
|
||
|
trace = signals.(type);
|
||
|
time = trial.time;
|
||
|
else
|
||
|
error('Could not find signal type in trial data');
|
||
|
end
|
||
|
|
||
|
%% TODO add: markers
|
||
|
ton_codings = {'trial onset','trial on', 'start trial', 'trial start', 'trial_start'};
|
||
|
toff_codings = {'trial offset','trial off', 'end trial', 'trial end', 'trial_end'};
|
||
|
|
||
|
son_codings = {'stimulus onset','stimulus on', 'soa', 'stim on', 'stim_on'};
|
||
|
soff_codings = {'stimulus offset','stimulus off', 'stim off', 'stim_off'};
|
||
|
bon_codings = {'baseline on', 'baseline start', 'baseline onset', 'bl on', 'bl'};
|
||
|
boff_codings = {'baseline off', 'baseline end', 'baseline offset', 'bl off'};
|
||
|
|
||
|
possible_markers = {'trial_start','trial_end',...
|
||
|
'baseline_onset','baseline_offset',...
|
||
|
'stimulus_onset', 'stimulus_offset'};
|
||
|
|
||
|
if ismember(marker, possible_markers)
|
||
|
marker_timestamp = trial.(marker);
|
||
|
else
|
||
|
error('Marker type is not defined for trial');
|
||
|
end
|
||
|
|
||
|
time = time - trial.(marker);
|
||
|
|
||
|
|
||
|
|
||
|
|