-
Notifications
You must be signed in to change notification settings - Fork 3
/
DNBloaddata.m
101 lines (94 loc) · 2.34 KB
/
DNBloaddata.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
function f = DNBloaddata(varargin)
% ***** Calling style 1:
%
% function dataset = DNBloaddata(datasetnumber,'all');
%
% <datasetnumber> is a positive integer
%
% Return <dataset>, which is a struct with all information
% regarding that dataset.
%
% ***** Calling style 2:
%
% function XYZ = DNBloaddata(datasetnumber,'XYZ');
%
% <datasetnumber> is a positive integer
%
% Return a single piece of information named XYZ.
% XYZ can be any of the fields in the dataset struct,
% such as 'design', 'data', or 'hrf'. Please see the
% README file for full details.
%
% ***** Calling style 3:
%
% function ... = DNBloaddata(datasetnumber,...,runix)
%
% <datasetnumber> is a positive integer
% <runix> is a vector of indices
%
% This is the same as the first two calling styles, except
% that <runix> is passed in. By passing in <runix>, only information
% corresponding to the specific set of runs referred to by <runix>
% is returned. If <runix> is [] or not specified, we return
% information for all runs.
%
% ***** Examples:
%
% Example of calling style 1:
% dataset = DNBloaddata(14,'all');
% dataset
%
% Example of calling style 2:
% design = DNBloaddata(14,'design');
% design
%
% Example of calling style 3:
% design = DNBloaddata(14,'design',[1 2]);
% design
% input
datasetnumber = varargin{1};
% figure out the path to the dataset file
filename = absolutepath(strrep(which('DNBloaddata'),'DNBloaddata.m', ...
sprintf('DNBdata/dataset%02d.mat',datasetnumber)));
% load in the desired information
if isequal(varargin{2},'all')
f = load(filename);
else
f = load(filename,varargin{2});
end
% figure out the runs that are desired
if length(varargin) < 3
runix = [];
else
runix = varargin{3};
end
% extract subset if necessary
if ~isempty(runix)
if isfield(f,'data')
f.data = f.data(runix);
end
if isfield(f,'dataRETRO1')
f.dataRETRO1 = f.dataRETRO1(runix);
end
if isfield(f,'dataRETRO2')
f.dataRETRO2 = f.dataRETRO2(runix);
end
if isfield(f,'design')
f.design = f.design(runix);
end
if isfield(f,'motionparameters')
f.motionparameters = f.motionparameters(runix);
end
if isfield(f,'runsets')
f.runsets = f.runsets(runix);
end
if isfield(f,'runtypes')
f.runtypes = f.runtypes(runix);
end
end
% undo the struct if necessary
switch varargin{2}
case 'all'
otherwise
f = f.(varargin{2});
end