-
Notifications
You must be signed in to change notification settings - Fork 2
/
MICE_scr_overview.m
61 lines (44 loc) · 1.88 KB
/
MICE_scr_overview.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
function MICE_scr_overview(task)
%%% A MICE Raw SCR Data Overview %%%
% harcoded parameters
datadir = '/Volumes/memolab/MICE/MICE_fMRI/data';
datadirs = cellstr(spm_select('FPList', datadir, 'dir', '^sub-s0(?!15|21|23|29|31)'));
names = regexp(datadirs, 'sub-s...', 'match');
names = unNest_cell_array(names);
output = cellfun(@concatenate_sessions, datadirs, repmat({lower(task(1:3))}, length(datadirs), 1), 'UniformOutput', false);
output = cellfun(@timeseries, output, ...
repmat({'Name'}, length(output), 1), names, ...
'UniformOutput', false);
% Remove outlying samples
% for i = 1:length(output)
% outlierBool = output{i}.Data > (output{i}.mean + (7 * output{i}.std)); % more then 7 stdard deviations away from the mean
% output{i}.Data(outlierBool) = NaN;
% output{i}.Data = output{i}.Data - output{i}.mean;
% end
figure('Position', [0 0 1920 1920], 'Name', [task ' SCR Data']);
for i = 1:length(output)
subplot(ceil(length(output)/2),2,i)
plot(output{i})
end
function output = concatenate_sessions(directory, task)
% identify data file names
filenames = cellstr(spm_select('FPListRec', directory, ['^sub-.*' task '\.mat']));
% load all of the data simultaneously
data = cellfun(@load, filenames, 'UniformOutput', false);
% define a temporary function that:
% - extracts
% - removes the mean from and
% - median filters
% each RUN of the data
ext = @(x) medfilt1(x.data{1} - mean(x.data{1}), 10);
% define a temporary function that:
% - extracts
% each RUN of the data
%ext = @(x) x.data{1};
% use the above defined function to extract, remove mean, and
% median filter each run of the data
data = cellfun(ext, data, 'UniformOutput', false);
% concatenate the runs
output = vertcat(data{:})';
end
end