-
Notifications
You must be signed in to change notification settings - Fork 2
/
PSPM_EXAMPLE_scr_overview.m
70 lines (42 loc) · 1.86 KB
/
PSPM_EXAMPLE_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
62
63
64
65
66
67
68
69
70
function PSPM_EXAMPLE_scr_overview()
%%% A MICE Raw SCR Data Overview %%%
% harcoded parameters
datadir = '/Users/kylekurkela/Documents/datasets';
datadirs = cellstr(spm_select('FPList', datadir, 'dir', '^PsPM'));
names = regexp(datadirs, 'SCRV.', 'match');
names = unNest_cell_array(names);
trims = {1:180, 1:45, 1:20};
for iData = 1:length(datadirs)
trimL = trims(iData);
output = concatenate_sessions(datadirs{iData});
iNames = repmat(names(iData), length(output), 1);
ndash = repmat({'-'}, length(output), 1);
subjectNums = cellstr(num2str( (1:length(output))', '%02d' ));
iNames = strcat(iNames, ndash, subjectNums);
output = cellfun(@timeseries, output, ...
repmat({'Name'}, length(output), 1), iNames, ...
'UniformOutput', false);
output = cellfun(@trim, output, ...
repmat(trimL, length(output), 1), ...
'UniformOutput', false);
%output = cellfun(@meancenter, output, 'UniformOutput', false);
figure('Position', [0 0 1920 1920], 'Name', names{iData});
for i = 1:length(output)
subplot(ceil(length(output)/2),2,i)
plot(output{i})
end
end
function data = concatenate_sessions(directory)
% load sessions and concatenate
filenames = cellstr(spm_select('FPList', directory, '.*spike.*\.mat'));
data = cellfun(@load, filenames, 'UniformOutput', false);
ext = @(x) vertcat(x.data{1}.data, x.data{2}.data);
data = cellfun(ext, data, 'UniformOutput', false);
end
function y = trim(y, trimL)
y = delsample(y, 'Index', trimL);
end
function l = meancenter(l)
l.Data = l.Data - l.mean;
end
end