forked from NeurodataWithoutBorders/matnwb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nwbExport.m
38 lines (36 loc) · 1.19 KB
/
nwbExport.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
function nwbExport(nwb, filenames)
%NWBEXPORT Writes an NWB file.
% nwbRead(nwb,filename) Writes the nwb object to a file at filename.
%
% Example:
% % Generate Matlab code for the NWB objects from the core schema.
% % This only needs to be done once.
% generateCore('schema\core\nwb.namespace.yaml');
% % Create some fake fata and write
% nwb = NwbFile;
% nwb.session_start_time = datetime('now');
% nwb.identifier = 'EMPTY';
% nwb.session_description = 'empty test file';
% nwbExport(nwb, 'empty.nwb');
%
% See also GENERATECORE, GENERATEEXTENSION, NWBFILE, NWBREAD
validateattributes(nwb, {'NwbFile'}, {'nonempty'});
validateattributes(filenames, {'cell', 'string', 'char'}, {'nonempty'});
if iscell(filenames)
assert(iscellstr(filenames), 'filename cell array must consist of strings');
end
if ~isscalar(nwb)
assert(~ischar(filenames) && length(filenames) == length(nwb), ...
'NwbFile and filename array dimensions must match.');
end
for i=1:length(nwb)
if iscellstr(filenames)
filename = filenames{i};
elseif isstring(filenames)
filename = filenames(i);
else
filename = filenames;
end
nwb(i).export(filename);
end
end