Home > . > nwbExport.m

nwbExport

PURPOSE ^

NWBEXPORT Writes an NWB file.

SYNOPSIS ^

function nwbExport(nwb, filenames)

DESCRIPTION ^

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function nwbExport(nwb, filenames)
0002 %NWBEXPORT Writes an NWB file.
0003 %  nwbRead(nwb,filename) Writes the nwb object to a file at filename.
0004 %
0005 %  Example:
0006 %    % Generate Matlab code for the NWB objects from the core schema.
0007 %    % This only needs to be done once.
0008 %    generateCore('schema\core\nwb.namespace.yaml');
0009 %    % Create some fake fata and write
0010 %    nwb = NwbFile;
0011 %    nwb.session_start_time = datetime('now');
0012 %    nwb.identifier = 'EMPTY';
0013 %    nwb.session_description = 'empty test file';
0014 %    nwbExport(nwb, 'empty.nwb');
0015 %
0016 %  See also GENERATECORE, GENERATEEXTENSION, NWBFILE, NWBREAD
0017 validateattributes(nwb, {'NwbFile'}, {'nonempty'});
0018 validateattributes(filenames, {'cell', 'string', 'char'}, {'nonempty'});
0019 if iscell(filenames)
0020     assert(iscellstr(filenames), 'filename cell array must consist of strings');
0021 end
0022 if ~isscalar(nwb)
0023     assert(~ischar(filenames) && length(filenames) == length(nwb), ...
0024         'NwbFile and filename array dimensions must match.');
0025 end
0026 
0027 for i=1:length(nwb)
0028     if iscellstr(filenames)
0029         filename = filenames{i};
0030     elseif isstring(filenames)
0031         filename = filenames(i);
0032     else
0033         filename = filenames;
0034     end
0035     export(nwb(i), filename);
0036 end
0037 end

Generated on Fri 09-Aug-2019 14:27:49 by m2html © 2005