This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
forked from Washington-University/cifti-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cifti_diminfo_make_scalars.m
44 lines (44 loc) · 1.68 KB
/
cifti_diminfo_make_scalars.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
function outmap = cifti_diminfo_make_scalars(nummaps, namelist, metadatalist)
%function outmap = cifti_diminfo_make_scalars(nummaps, namelist, metadatalist)
% Create a new scalars diminfo object.
%
% Only the nummaps argument is required.
% The namelist argument, if provided, may be a char vector if nummaps = 1,
% or a cell vector of char vectors.
% The metadatalist argument, if provided, must be a cell vector of
% struct vectors with the same structure as the metadata in a cifti struct.
outmap = struct('type', 'scalars', 'length', nummaps, 'maps', struct('name', cell(nummaps, 1), 'metadata', cell(nummaps, 1)));
if nargin >= 2 && ~isempty(namelist)
if ~iscell(namelist)
if nummaps ~= 1
error('namelist is not a cell array, and nummaps is not 1');
end
else
if length(namelist) ~= nummaps
error('namelist length and nummaps do not match');
end
end
end
if nargin >= 3 && ~isempty(metadatalist)
if ~iscell(metadatalist)
error('metadatalist must be a cell array');
end
if length(metadatalist) ~= nummaps
error('metadatalist length and nummaps do not match');
end
end
for i = 1:nummaps
if nargin >= 2 && ~isempty(namelist)
if ~iscell(namelist)
outmap.maps(i).name = namelist;
else
outmap.maps(i).name = namelist{i};
end
else
outmap.maps(i).name = '';
end
if nargin >= 3 && ~isempty(metadatalist)
outmap.maps(i).metadata = metadatalist{i};
end
end
end