-
Notifications
You must be signed in to change notification settings - Fork 32
/
nwbExport.m
54 lines (51 loc) · 1.64 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function nwbExport(nwbFileObjects, filePaths, mode)
%NWBEXPORT - Writes an NWB file.
%
% Syntax:
% NWBEXPORT(nwb, filename) Writes the nwb object to a file at filename.
%
% Input Arguments:
% - nwb (NwbFile) - Nwb file object
% - filename (string) - Filepath pointing to an NWB file.
%
% Usage:
% Example 1 - Export an NWB file::
%
% % Create an NWB object with some properties:
% nwb = NwbFile;
% nwb.session_start_time = datetime('now');
% nwb.identifier = 'EMPTY';
% nwb.session_description = 'empty test file';
%
% % Write the nwb object to a file:
% nwbExport(nwb, 'empty.nwb');
%
% Example 2 - Export an NWB file using an older schema version::
%
% % Generate classes for an older version of NWB schemas:
% generateCore('2.5.0')
%
% % Create an NWB object with some properties:
% nwb = NwbFile;
% nwb.session_start_time = datetime('now');
% nwb.identifier = 'EMPTY';
% nwb.session_description = 'empty test file';
%
% % Write the nwb object to a file:
% nwbExport(nwb, 'empty.nwb');
%
% See also:
% generateCore, generateExtension, NwbFile, nwbRead
arguments
nwbFileObjects (1,:) NwbFile {mustBeNonempty}
filePaths (1,:) string {mustBeNonzeroLengthText}
mode (1,1) string {mustBeMember(mode, ["edit", "overwrite"])} = "edit"
end
assert(length(nwbFileObjects) == length(filePaths), ...
'NWB:Export:FilepathLengthMismatch', ...
'Lists of NWB objects to export and list of file paths must be the same length.')
for iFiles = 1:length(nwbFileObjects)
filePath = char(filePaths(iFiles));
nwbFileObjects(iFiles).export(filePath, mode);
end
end