Repository navigation
Expand file tree
/
Copy pathSetupMRI.m
More file actions
153 lines (131 loc) · 4.13 KB
/
Copy pathSetupMRI.m
File metadata and controls
153 lines (131 loc) · 4.13 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
% Offset the boilerplate stuff to make the main loop easier/shorter to read
%% Add paths
Screen('Preference', 'SkipSyncTests', 1);
Screen('Preference','VisualDebugLevel', 0);
addpath(genpath('Psychoobox'));
addpath(genpath('ptbutils'));
tgt = ParseTgt(file_name, ',');
HideCursor;
tgt = struct2table(tgt); % R2013b ++!
% break it up into segments
split_str = regexp(file_name, '/', 'split');
% return values of particular portions
% use name as stand-in for id
id = split_str{end - 1};
tgt_name = split_str{end};
% lop off extension
tgt_name = regexprep(tgt_name, '.tgt', '');
% data directory
data_dir = ['data/', id, '/'];
% final file name (explicitly append .mat?)
data_name = [data_dir, id, '_', tgt_name, '_', datestr(now, 'hhMMSS'), '.mat'];
%% Set up screen
Screen('Preference', 'Verbosity', 1);
if fullscreen
win_size = [];
else
win_size = [50 50 500 500];
end
win = PobWindow('screen', max(Screen('screens')), ...
'color', [0 0 0], ...
'rect', win_size);
%% Set up images
imgs = PobImage;
if tgt.image_type(1)
img_dir = 'misc/images/shapes/';
img_names = dir('misc/images/shapes/*.jpg');
else
img_dir = 'misc/images/hands/';
img_names = dir('misc/images/hands/*.jpg');
end
for ii = 1:length(img_names)
tmpimg = imcomplement(...
imread([img_dir, img_names(ii).name])...
);
imgs.Add(ii, 'original_matrix', {tmpimg}, ...
'rel_x_pos', 0.5, ...
'rel_y_pos', 0.5, ...
'rel_x_scale', 0.25, ...
'rel_y_scale', nan);
end
%% Set up text
helptext = ['This experiment is \nthe MRI one.\n', ...
'Waiting for the initial TR.'];
info_txt = PobText('value', helptext, 'size', 40, ...
'color', [255 255 255], ...
'rel_x_pos', 0.5, ...
'rel_y_pos', 0.5, ...
'style', 'bold');
%% Set up responses & feedback
% use entire right hand
if ~simulate_resp
kbrd = BlamForceboard(1:5);
end
feedback = PobRectangle();
feedback.Add(1, 'rel_x_pos', 0.5, ...
'rel_y_pos', 0.5, ...
'rel_x_scale', 0.3, ...
'rel_y_scale', nan, ...
'fill_color', [255 255 255], ...
'fill_alpha', 0, ...
'frame_color', [255 255 255]);
% go_cue = PobRectangle();
%
% go_cue.Add(1, 'rel_x_pos', 0.5, ...
% 'rel_y_pos', 0.9, ...
% 'rel_x_scale', 0.4, ...
% 'rel_y_scale', .05, ...
% 'fill_color', [255 255 255], ...
% 'frame_color', [255 255 255], ...
% 'frame_alpha', 0, ...
% 'frame_stroke', 10);
go_cue = PobText('value', '+', 'size', 160, ...
'color', [255 255 255], ...
'rel_x_pos', 0.5, ...
'rel_y_pos', 0.5, ...
'style', 'bold');
%% Register relative to window
imgs.Register(win.pointer);
feedback.Register(win.pointer);
go_cue.Register(win.pointer);
imgs.Prime();
feedback.Prime();
info_txt.Register(win.pointer);
%% TR obj (plus other keys)
if ~simulate
tr = BlamTr();
else
% do something else?
end
%% Data storage
tr_struct = struct('times', zeros(1, max(tgt.trnum)),...
'count', zeros(1, max(tgt.trnum)));
trial(1:length(tgt.trial)) = struct('trial_start', [], ... x
'between_data', [], ...x
'within_data', [], ...x
'image_index', [], ...x
'intended_finger', [], ...x
'stim_delay', [], ...x
'stim_time', [], ...x
'go_delay', [], ...x
'go_time', [], ...x
'trnum', [], ...x
'trial_type', [], ...x
'press_index', [], ...x
'press_time', []); % which finger was pressedx
for ii = 1:length(tgt.trial)
trial(ii).image_index = tgt.image_index(ii);
trial(ii).intended_finger = tgt.intended_finger(ii);
trial(ii).trnum = tgt.trnum(ii);
trial(ii).stim_delay = tgt.stim_delay(ii);
trial(ii).go_delay = tgt.go_delay(ii);
trial(ii).trial_type = tgt.trial_type(ii);
end
dat = struct('trial', trial, ...
'id', id, ...
'session', tgt.sess(1), ...
'shapes', tgt.image_type(1), ...
'block_start', [], ...x
'presses', [], ...x
'tr', tr_struct, ...
'tgt', tgt);