-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHumanITTData_v1.m
More file actions
75 lines (50 loc) · 2.39 KB
/
HumanITTData_v1.m
File metadata and controls
75 lines (50 loc) · 2.39 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
%% HumanITTData_v1
% Purpose: import human interval timing data (latency in seconds) and sort. Export to excel.
% Authors: V. Muller Ewald
% Versiion history:
% 11.14.21 - V Muller Ewald - Created script
% Comments:
%% Set paths
clear; clc; close all
dataLocation = 'P:\Victoria\1. Parker Lab\Teaching\2021 - UIowa - Fall MatLab boot camp\Meeting 3\HumanProject\Data\';
saveLocation = 'P:\Victoria\1. Parker Lab\Teaching\2021 - UIowa - Fall MatLab boot camp\Meeting 3\HumanProject\Results\HumanITTData_v1\';
if ~exist(saveLocation); mkdir(saveLocation); end
excelName = 'Human ITT Data v1';
% INSERT LINE THAT ESTABLISHES A SUBJECT DIRECTORY HERE
%% Initialize
cutOff = 7; % this is the cutoff for short vs short
ITTShort = []; ITTLong = []; % these are the matrices that the different trial types will be sorted into
ITTPerformanceTab = []; % this is where the results save, we then export this to excel
%% Analyze
% Import
load([dataLocation, 'Subject1_data.mat']); % CHANGE LOADING SYNTAX SO THAT EACH SUBJECT CAN BE LOADED
nTrials = size(ITTData,1); % find number of trials
% Sort the trials into short and long interval types
for trialSortLoop = 1:nTrials
thisTrial = ITTData(trialSortLoop,1);
if thisTrial > cutOff
ITTLong = vertcat(ITTLong, thisTrial);
elseif thisTrial < cutOff
ITTShort = vertcat(ITTShort, thisTrial);
end % thisTrial > cutOff
end % trialSortLoop
% Calculate metrics for short or long trials
lpShort_mean = nanmean(ITTShort,1);
lpShort_nTrials = size(ITTShort,1);
lpLong_mean = nanmean(ITTLong,1);
lpLong_nTrials = size(ITTLong,1);
% Save to output matrix % CHANGE THIS SO EVERY ROW CONTAINS INFO FROM A SINGLE SUBJECT
ITTPerformanceTab(1,1) = 1; % CHANGE THIS TO REFLECT SUBJECT NUMBER
ITTPerformanceTab(1,2) = lpShort_mean;
ITTPerformanceTab(1,3) = lpShort_nTrials;
ITTPerformanceTab(1,4) = lpLong_mean;
ITTPerformanceTab(1,5) = lpLong_nTrials;
%% Plot
% Plot a bar graph with mean and SEM error bars
% Bar 1 = mean and SEM of short interval trials, bar 2 = mean and SEM of long interval trials
%% Save/export
header = {'Subj', 'latency short', 'total short', 'latency long', 'total long'};
xlswrite([saveLocation, excelName], header, 'ITTTab');
xlswrite([saveLocation, excelName], ITTPerformanceTab, 'ITTTab', 'A2');
%% The End
fprintf('Wohoooo the script ran!');