-
Notifications
You must be signed in to change notification settings - Fork 1
/
WACOM_parse_subjects.m
30 lines (24 loc) · 1.13 KB
/
WACOM_parse_subjects.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
function [subject_list, lesioned_sides] = WACOM_parse_subjects(metadata_filepath,datadir,taskname,timepoint)
paths = dir([datadir filesep '*' timepoint '.mat']);
paths = paths(~[paths.isdir]); %remove extraneous files
names = {paths.name};
subject_list = erase(names,{'pre.mat','post.mat'});
lesioned_sides = get_lesioned_sides(metadata_filepath, subject_list);
for i = 1:length(paths) %iterate over subjects
datapath = [paths(i).folder filesep paths(i).name];
if lesioned_sides{i} == 'L' && contains(taskname, 'contra') %get contra or ipsi side
taskname = strrep(taskname,'contra','R');
elseif lesioned_sides{i} == 'R' && contains(taskname, 'contra')
taskname = strrep(taskname,'contra','L');
elseif lesioned_sides{i} == 'L' && contains(taskname, 'ipsi')
taskname = strrep(taskname,'ipsi','L');
elseif lesioned_sides{i} == 'R' && contains(taskname, 'ipsi')
taskname = strrep(taskname,'ipsi','R');
end
data = load(datapath);
tasklist = (data.cond);
hastask(i) = ismember(taskname,tasklist);
end
subject_list = subject_list(hastask);
lesioned_sides = lesioned_sides(hastask);
end