-
Notifications
You must be signed in to change notification settings - Fork 0
/
experimentLauncher.m
120 lines (99 loc) · 3.8 KB
/
experimentLauncher.m
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
function experimentLauncher()
%function experimentLauncher()
%
% Project: Face Affect Discrimination (FAD) Task, part of CWT
% Queries participant info, sets paths, and calls main.m
%
% Versions:
% FAD_v1-1 Pilot 1. MCS procedure, stimuli faces of 4 individuals from KDEF
% FAD_v1-2 Pilot 2. Adaptive (psi), stimuli two averaged faces (M & F),
% each based on 9 KDEF individuals, OR N-down staircase (4 interleaved stairs)
%
% ======================================================
%
% Run from Pilot_2_PsiAdaptive directory
% -------------- PRESS ESC TO EXIT ---------------------
%
% ======================================================
%
% Niia Nikolova
% Last edit: 11/06/2020
%% Initial settings
% Close existing workspace
close all; clc;
devFlag = 0; % optional flag. Set to 1 when developing the task
vars.exptName = 'FAD_v1-2';
%% Do system checks
% OS-dependent checks?
% if ispc
% % Windows
%
% elseif ismac || isunix
% % Mac/Unix
%
% end
% Check that PTB is installed
PTBv = PsychtoolboxVersion;
if isempty(PTBv)
disp('Please install Psychtoolbox 3. Download and installation can be found here: http://psychtoolbox.org/download');
return
end
% Skip internal synch checks, suppress warnings
oldLevel = Screen('Preference', 'Verbosity', 0);
Screen('Preference', 'SkipSyncTests', 1);
Screen('Preference','VisualDebugLevel', 0);
% check working directory & change if necessary
vars.workingDir = fullfile('FADtask_2_Psi'); % <--- EDIT here as needed ####
currentFolder = pwd;
correctFolder = contains(currentFolder, vars.workingDir);
if ~correctFolder % if we're not in the correct working directory, prompt to change
disp(['Incorrect working directory. Please start from ', vars.workingDir]); return;
end
% check for data dir
if ~exist('data', 'dir')
mkdir('data')
end
% setup path
addpath(genpath('code'));
addpath(genpath('data'));
addpath(genpath('stimuli'));
%% Run both Psi and Ndown tasks
% global PROCEDURE
% if isempty(PROCEDURE)
% PROCEDURE = 1;
%% Ask for subID, age, gender, and display details
if ~devFlag % if we're testing
vars.subNo = input('What is your subject number (given by the experimenter, e.g. 001)? ');
vars.subAge = input('What is your age (# in years, e.g. 35)? ');
vars.subGen = input('What is your gender (f or m)? ', 's');
disp('=====================================================================================');
disp('Now please enter your screen dimensions and viewing distance.');
disp('If left blank, these will default to 16.5 x 23.5cm, 40cm viewing distance, which is approximate for a 13" laptop.');
disp('Press ENTER to continue...');
disp('=====================================================================================');
pause
scr.MonitorHeight = input('Input your monitor height (cm): ');
scr.MonitorWidth = input('Input your monitor width (cm): ');
scr.ViewDist = input('Input your viewing distance (cm). This is usually around 40cm for laptops, and 75cm for desktop displays: ');
HideCursor;
else
scr.ViewDist = 70;
end
if ~isfield(vars,'subNo') || isempty(vars.subNo)
vars.subNo = 999; % test
end
%% Output
vars.OutputFolder = fullfile('.', 'data', filesep);
subIDstring = sprintf('%03d', vars.subNo);
vars.DataFileName = strcat(vars.exptName, '_',subIDstring, '_'); % name of data file to write to
if isfile(strcat(vars.OutputFolder, vars.DataFileName, '.mat'))
% File already exists in Outputdir
if vars.subNo ~= 999
disp('A datafile already exists for this subject ID. Please enter a different ID.')
return
end
end
%% Start experiment
main(vars, scr);
% Restore PTB verbosity
Screen('Preference', 'Verbosity', oldLevel);