forked from tiesmaaj/trial_and_error
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocessAVdata.m
More file actions
35 lines (32 loc) · 1.38 KB
/
preprocessAVdata.m
File metadata and controls
35 lines (32 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function processedAVdata = preprocessAVdata(rawData, mod)
% Extract columns based on the new assignments
if strcmp(mod, "A")
stimulus = rawData(:, 1);
SNR = rawData(:, 2);
elseif strcmp(mod, "V")
stimulus = rawData(:, 3);
SNR = rawData(:, 4);
elseif strcmp(mod, "AV")
stimulus = rawData(:, [1, 3]);
SNR = rawData(:, [2, 4]);
elseif strcmp(mod, "N")
stimulus = rawData(:, [1, 3]); %change
SNR = rawData(:, [2, 4]); %change
else
error("Invalid modality specified. Use 'A', 'V', or 'AV'.");
end
% Extract other columns
response = rawData(:, 5); % Response
RT = rawData(:, 6); % Reaction Time
% Compute derived columns
prevStimulus = [NaN(1, size(stimulus, 2)); stimulus(1:end-1, :)];
prevSNR = [NaN(1, size(SNR, 2)); SNR(1:end-1, :)];
prevResponse = [NaN; response(1:end-1)];
correct = (stimulus(:, 1) == response); % Correct or incorrect using column 1 of stimulus
prevOutcome = [NaN; correct(1:end-1)];
% Combine into a table
processedAVdata = table(stimulus, SNR, response, RT, ...
prevStimulus, prevSNR, prevResponse, prevOutcome, ...
'VariableNames', {'Stimulus', 'SNR', 'Response', 'RT', ...
'PrevStimulus', 'PrevSNR', 'PrevResponse', 'PrevOutcome'});
end