forked from tiesmaaj/trial_and_error
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocessData.m
More file actions
20 lines (18 loc) · 799 Bytes
/
preprocessData.m
File metadata and controls
20 lines (18 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function processedData = preprocessData(rawData)
% Extract columns
stimulus = rawData(:, 1);
SNR = rawData(:, 2);
response = rawData(:, 3);
RT = rawData(:, 4);
% Compute derived columns
prevStimulus = [NaN; stimulus(1:end-1)];
prevSNR = [NaN; SNR(1:end-1)];
prevResponse = [NaN; response(1:end-1)];
correct = (stimulus == response); % Correct or incorrect
prevOutcome = [NaN; correct(1:end-1)];
% Combine into a table
processedData = table(stimulus, SNR, response, RT, ...
prevStimulus, prevSNR, prevResponse, prevOutcome, ...
'VariableNames', {'Stimulus', 'SNR', 'Response', 'RT', ...
'PrevStimulus', 'PrevSNR', 'PrevResponse', 'PrevOutcome'});
end