diff --git a/+file/Dataset.m b/+file/Dataset.m index 77a2bbda..ff3a3323 100644 --- a/+file/Dataset.m +++ b/+file/Dataset.m @@ -121,15 +121,19 @@ %constrained % error unless it defines the object. - - if isempty(obj.type) - error('You shouldn''t be calling getProps on an untyped dataset'); - end - - if obj.isConstrainedSet && ~obj.definesType - error('You shouldn''t be calling getProps on a constrained dataset'); - end - + + assert(... + ~isempty(obj.type), ... + 'NWB:Dataset:UnsupportedOperation', ... + 'The method `getProps` should not be called on an untyped dataset.' ... + ); + + assert( ... + ~obj.isConstrainedSet || obj.definesType, ... + 'NWB:Dataset:UnsupportedOperation', ... + 'The method `getProps` should not be called on constrained dataset.' ... + ); + if ~isempty(obj.dtype) props('data') = obj.dtype; end diff --git a/+file/Group.m b/+file/Group.m index d9fababe..00e62146 100644 --- a/+file/Group.m +++ b/+file/Group.m @@ -146,8 +146,14 @@ %should never happen if obj.isConstrainedSet && ~obj.definesType - error('getProps shouldn''t be called on a constrained set.'); + error('NWB:Group:UnsupportedOperation', ... + 'The method `getProps` should not be called on a constrained dataset.'); end + assert( ... + ~obj.isConstrainedSet || obj.definesType, ... + 'NWB:Group:UnsupportedOperation', ... + 'The method `getProps` should not be called on a constrained group.' ... + ); %datasets for i=1:length(obj.datasets) diff --git a/+file/fillConstructor.m b/+file/fillConstructor.m index 124330d4..269829d2 100644 --- a/+file/fillConstructor.m +++ b/+file/fillConstructor.m @@ -100,7 +100,8 @@ end end - %warn for missing namespaces/property types + % warn for missing namespaces/property types + warningId = 'NWB:ClassGenerator:NamespaceOrTypeNotFound'; warnmsg = ['`' parentName '`''s constructor is unable to check for type `%1$s` ' ... 'because its namespace or type specifier could not be found. Try generating ' ... 'the namespace or class definition for type `%1$s` or fix its schema.']; @@ -109,7 +110,7 @@ invalidWarn = invalid & (dynamicConstrained | isAnonymousType) & ~isAttribute; invalidVars = varnames(invalidWarn); for i=1:length(invalidVars) - warning(warnmsg, invalidVars{i}); + warning(warningId, warnmsg, invalidVars{i}); end varnames = lower(varnames); diff --git a/+file/fillCustomConstraint.m b/+file/fillCustomConstraint.m index 5be7d9e8..afe34a52 100644 --- a/+file/fillCustomConstraint.m +++ b/+file/fillCustomConstraint.m @@ -12,9 +12,11 @@ customConstraintStr = sprintf( [... 'function checkCustomConstraint(obj)\n', ... ' assert(~isempty(obj.timestamps) || ~isempty(obj.starting_time), ...\n', ... + ' ''NWB:TimeSeries:TimeNotSpecified'', ...\n ', ... ' "''timestamps'' or ''starting_time'' must be specified")\n', ... ' if ~isempty(obj.starting_time)\n', ... ' assert(~isempty(obj.starting_time_rate), ...\n', ... + ' ''NWB:TimeSeries:RateMissing'', ...\n', ... ' "''starting_time_rate'' must be specified when ''starting_time'' is specified")\n', ... ' end\n', ... 'end'] ); diff --git a/+file/fillProps.m b/+file/fillProps.m index 114234f7..51062cd2 100644 --- a/+file/fillProps.m +++ b/+file/fillProps.m @@ -58,7 +58,8 @@ case 'object' refTypeName = 'Object'; otherwise - error('Invalid reftype found whilst filling Constructor prop docs.'); + error('NWB:ClassGenerator:InvalidRefType', ... + 'Invalid reftype found while filling description for class property "%s".', propName); end typeStr = sprintf('%s Reference to %s', refTypeName, prop.dtype('target_type')); else @@ -71,7 +72,8 @@ case 'object' refTypeName = 'object'; otherwise - error('Invalid reftype found whilst filling Constructor prop docs.'); + error('NWB:ClassGenerator:InvalidRefType', ... + 'Invalid reftype found while filling description for class property "%s".', propName); end typeStr = sprintf('%s Reference to %s', refTypeName, prop('target_type')); elseif isa(prop, 'file.interface.HasProps') diff --git a/+file/fillValidators.m b/+file/fillValidators.m index caacadb2..e2daac36 100644 --- a/+file/fillValidators.m +++ b/+file/fillValidators.m @@ -240,7 +240,7 @@ ' return;'... 'end'... 'if ~istable(val) && ~isstruct(val) && ~isa(val, ''containers.Map'')'... - [' error(''Property `' name '` must be a table,struct, or containers.Map.'');']... + [' error(''NWB:Type:InvalidPropertyType'', ''Property `' name '` must be a table, struct, or containers.Map.'');']... 'end'... 'vprops = struct();'... }, newline); @@ -294,8 +294,7 @@ classNameSplit = strsplit(className, '.'); shortName = classNameSplit{end}; - - errorStr = sprintf( 'error(''Unable to set the ''''%s'''' property of class ''''%s'''' because it is read-only.'')', name, className, shortName); + errorStr = sprintf( 'error(''NWB:Type:ReadOnlyProperty'', ''Unable to set the ''''%s'''' property of class ''''%s'''' because it is read-only.'')', name, className, shortName); if ischar(value) condition = strjoin({ ... @@ -311,7 +310,8 @@ % Note: According to the documentation for Attribute specification keys % (https://schema-language.readthedocs.io/en/latest/description.html#sec-attributes-spec), % the above cases should be sufficient. - error('Unhandled case') + error('NWB:ClassGenerator:ReadOnlyValidatorNotImplemented', ... + 'Read-only validator is not implemented for values of type "%s"', class(value)) end fdvstr = strjoin({... diff --git a/+io/getBaseType.m b/+io/getBaseType.m index 680019a0..bd1a37f2 100644 --- a/+io/getBaseType.m +++ b/+io/getBaseType.m @@ -45,6 +45,7 @@ id = [prefix suffix]; else - error('Type `%s` is not a supported raw type', type); + error('NWB:IO:UnsupportedBaseType', ... + 'Type `%s` is not a supported raw type', type); end end \ No newline at end of file diff --git a/+io/parseGroup.m b/+io/parseGroup.m index 46a87c6c..791f2ecf 100644 --- a/+io/parseGroup.m +++ b/+io/parseGroup.m @@ -116,14 +116,14 @@ if any(leads) %since set has been edited, we bubble up deletion of the old keys. subset = elide(pvalue, prop(leads), pvar); - elided = [elided; subset]; + elided = [elided; subset]; %#ok if pvalue.Count == 0 drop(i) = true; elseif any(strcmp(pvar, prop)) elided(pvar) = pvalue; drop(i) = true; else - warning('Unable to match property `%s` under prefix `%s`',... + warning('NWB:Parse:UnmatchedProperty', 'Unable to match property `%s` under prefix `%s`',... pvar, prefix); end end diff --git a/+io/resolvePath.m b/+io/resolvePath.m index 7ffcdbd7..0a1cb3f6 100644 --- a/+io/resolvePath.m +++ b/+io/resolvePath.m @@ -8,7 +8,6 @@ %process slash tokens o = nwb; -errmsg = 'Could not resolve path `%s`.'; while ~isempty(tokens) if isa(o, 'types.untyped.Set') [o, tokens] = resolveSet(o, tokens); @@ -18,7 +17,7 @@ [o, tokens] = resolveObj(o, tokens); end if isempty(o) - error(errmsg, path); + error('NWB:IO:UnresolvedPath', 'Could not resolve path `%s`.', path); end end end diff --git a/+io/timestamp2datetime.m b/+io/timestamp2datetime.m index e1db9198..f1fd165f 100644 --- a/+io/timestamp2datetime.m +++ b/+io/timestamp2datetime.m @@ -113,9 +113,8 @@ elseif ischar(timestamps) cells = {timestamps}; else - errorId = "NWB:timestamp2datetime:MustBeCharCellArrayOrString"; - errorMsg = ['timestamps must be a string, character array, ', ... - 'or cell array of strings/character arrays.']; - error(errorId, errorMsg); + error('NWB:timestamp2datetime:MustBeCharCellArrayOrString', ... + [ 'Timestamps must be a string, character array, ', ... + 'or cell array of strings/character arrays.' ]); end end diff --git a/+io/writeCompound.m b/+io/writeCompound.m index 503b03b2..1e1b7131 100644 --- a/+io/writeCompound.m +++ b/+io/writeCompound.m @@ -1,4 +1,32 @@ function writeCompound(fid, fullpath, data, varargin) +% writeCompound - Write structured data to an HDF5 compound dataset. +% +% io.writeCompound(fid, fullpath, data, varargin) converts data (in table, +% struct, or containers.Map format) into a scalar struct, optimizes it for +% HDF5 storage, and writes it to an HDF5 compound dataset specified by fid +% and fullpath. +% +% Inputs: +% fid - File identifier for an open HDF5 file. +% fullpath - Full path within the HDF5 file where data will be stored. +% data - Data to write, provided as a table, struct, or containers.Map. +% varargin - Additional optional arguments. +% +% Functionality: +% - Converts input data into a scalar struct, rearranging fields and types as needed. +% - Detects data types, sizes, and handles compound HDF5 type creation. +% - Optimizes data for HDF5 by transposing column vectors and converting logicals. +% - Manages references to external data objects, regions, or untyped views. +% - Attempts to extend or overwrite existing datasets if a compound dataset at +% the specified path already exists. +% +% Notes: +% - If `fullpath` already exists in the HDF5 file, the function tries to adjust +% dimensions if the dataset is chunked, and issues a warning if resizing is not allowed. +% +% Example: +% io.writeCompound(fid, '/group/dataset', data); + %convert to a struct if istable(data) data = table2struct(data); @@ -103,7 +131,8 @@ function writeCompound(fid, fullpath, data, varargin) if is_chunked H5D.set_extent(did, dims); else - warning('Attempted to change size of continuous compound `%s`. Skipping.',... + warning('NWB:WriteCompund:ContinuousCompoundResize', ... + 'Attempted to change size of continuous compound `%s`. Skipping.', ... fullpath); end end diff --git a/+io/writeDataset.m b/+io/writeDataset.m index 7601864b..031b1281 100644 --- a/+io/writeDataset.m +++ b/+io/writeDataset.m @@ -26,7 +26,8 @@ function writeDataset(fid, fullpath, data, varargin) if ~is_same_dims && is_chunked H5D.set_extent(did, dims); elseif ~is_same_dims - warning('Attempted to change size of continuous dataset `%s`. Skipping.',... + warning('NWB:WriteDataset:ContinuousDatasetResize', ... + 'Attempted to change size of continuous dataset `%s`. Skipping.',... fullpath); H5S.close(sid); H5D.close(did); diff --git a/+misc/str2validName.m b/+misc/str2validName.m index 126e6c8c..dd93de15 100644 --- a/+misc/str2validName.m +++ b/+misc/str2validName.m @@ -3,6 +3,7 @@ % Converts the property name into a valid matlab property name. % propname: the offending property name % prefix: optional prefix to use instead of the ambiguous "dyn" + if ~iscell(propname) && isvarname(propname) valid = propname; return; @@ -12,7 +13,8 @@ prefix = 'dyn_'; else if ~isvarname(prefix) - warning('Prefix contains invalid variable characters. Reverting to "dyn"'); + warning('NWB:CreateValidPropertyName:InvalidPrefix', ... + 'Prefix contains invalid variable characters. Reverting to "dyn"'); prefix = 'dyn_'; end end diff --git a/+schemes/Namespace.m b/+schemes/Namespace.m index 271d77d3..6899f542 100644 --- a/+schemes/Namespace.m +++ b/+schemes/Namespace.m @@ -41,7 +41,7 @@ function parent = getParent(obj, classname) class = obj.getClass(classname); if isempty(class) - error('Could not find class %s', classname); + error('NWB:Namespace:ClassNotFound', 'Could not find class %s', classname); end parent = []; @@ -49,10 +49,10 @@ if any(hasParentKey) parentName = class(obj.PARENT_KEYS{hasParentKey}); parent = obj.getClass(parentName); - assert(~isempty(parent),... - 'Parent %s for class %s doesn''t exist! Missing Dependency?',... - parentName,... - classname); + assert(~isempty(parent), ... + 'NWB:Namespace:ParentNotFound', ... + 'Parent %s for class %s doesn''t exist! Missing Dependency?', ... + parentName, classname); end end diff --git a/+types/+core/AnnotationSeries.m b/+types/+core/AnnotationSeries.m index b199c3af..c821b8d6 100644 --- a/+types/+core/AnnotationSeries.m +++ b/+types/+core/AnnotationSeries.m @@ -52,14 +52,14 @@ if isequal(val, -1) val = -1; else - error('Unable to set the ''data_resolution'' property of class ''AnnotationSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_resolution'' property of class ''AnnotationSeries'' because it is read-only.') end end function val = validate_data_unit(obj, val) if isequal(val, 'n/a') val = 'n/a'; else - error('Unable to set the ''data_unit'' property of class ''AnnotationSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''AnnotationSeries'' because it is read-only.') end end %% EXPORT diff --git a/+types/+core/CurrentClampSeries.m b/+types/+core/CurrentClampSeries.m index 8def6770..fe27e0cb 100644 --- a/+types/+core/CurrentClampSeries.m +++ b/+types/+core/CurrentClampSeries.m @@ -109,7 +109,7 @@ if isequal(val, 'volts') val = 'volts'; else - error('Unable to set the ''data_unit'' property of class ''CurrentClampSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''CurrentClampSeries'' because it is read-only.') end end %% EXPORT diff --git a/+types/+core/CurrentClampStimulusSeries.m b/+types/+core/CurrentClampStimulusSeries.m index ec31d0db..ab8d7a4d 100644 --- a/+types/+core/CurrentClampStimulusSeries.m +++ b/+types/+core/CurrentClampStimulusSeries.m @@ -35,7 +35,7 @@ if isequal(val, 'amperes') val = 'amperes'; else - error('Unable to set the ''data_unit'' property of class ''CurrentClampStimulusSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''CurrentClampStimulusSeries'' because it is read-only.') end end %% EXPORT diff --git a/+types/+core/ElectricalSeries.m b/+types/+core/ElectricalSeries.m index 212e88ff..9a81aa87 100644 --- a/+types/+core/ElectricalSeries.m +++ b/+types/+core/ElectricalSeries.m @@ -97,7 +97,7 @@ if isequal(val, 'volts') val = 'volts'; else - error('Unable to set the ''data_unit'' property of class ''ElectricalSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''ElectricalSeries'' because it is read-only.') end end function val = validate_electrodes(obj, val) diff --git a/+types/+core/ElectrodeGroup.m b/+types/+core/ElectrodeGroup.m index 174c0e6d..d44737b8 100644 --- a/+types/+core/ElectrodeGroup.m +++ b/+types/+core/ElectrodeGroup.m @@ -93,7 +93,7 @@ return; end if ~istable(val) && ~isstruct(val) && ~isa(val, 'containers.Map') - error('Property `position` must be a table,struct, or containers.Map.'); + error('NWB:Type:InvalidPropertyType', 'Property `position` must be a table, struct, or containers.Map.'); end vprops = struct(); vprops.x = 'single'; diff --git a/+types/+core/IZeroClampSeries.m b/+types/+core/IZeroClampSeries.m index 39e5814e..03049eb6 100644 --- a/+types/+core/IZeroClampSeries.m +++ b/+types/+core/IZeroClampSeries.m @@ -90,7 +90,7 @@ if isequal(val, 'N/A') val = 'N/A'; else - error('Unable to set the ''stimulus_description'' property of class ''IZeroClampSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''stimulus_description'' property of class ''IZeroClampSeries'' because it is read-only.') end end %% EXPORT diff --git a/+types/+core/IndexSeries.m b/+types/+core/IndexSeries.m index 1c47e17f..8ba26b10 100644 --- a/+types/+core/IndexSeries.m +++ b/+types/+core/IndexSeries.m @@ -124,7 +124,7 @@ if isequal(val, 'N/A') val = 'N/A'; else - error('Unable to set the ''data_unit'' property of class ''IndexSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''IndexSeries'' because it is read-only.') end end function val = validate_indexed_images(obj, val) diff --git a/+types/+core/IntervalSeries.m b/+types/+core/IntervalSeries.m index 22edd6fc..27fd745a 100644 --- a/+types/+core/IntervalSeries.m +++ b/+types/+core/IntervalSeries.m @@ -52,14 +52,14 @@ if isequal(val, -1) val = -1; else - error('Unable to set the ''data_resolution'' property of class ''IntervalSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_resolution'' property of class ''IntervalSeries'' because it is read-only.') end end function val = validate_data_unit(obj, val) if isequal(val, 'n/a') val = 'n/a'; else - error('Unable to set the ''data_unit'' property of class ''IntervalSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''IntervalSeries'' because it is read-only.') end end %% EXPORT diff --git a/+types/+core/IntracellularElectrodesTable.m b/+types/+core/IntracellularElectrodesTable.m index b3f2b4fd..ce75faef 100644 --- a/+types/+core/IntracellularElectrodesTable.m +++ b/+types/+core/IntracellularElectrodesTable.m @@ -41,7 +41,7 @@ if isequal(val, 'Table for storing intracellular electrode related metadata.') val = 'Table for storing intracellular electrode related metadata.'; else - error('Unable to set the ''description'' property of class ''IntracellularElectrodesTable'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''description'' property of class ''IntracellularElectrodesTable'' because it is read-only.') end end function val = validate_electrode(obj, val) diff --git a/+types/+core/IntracellularRecordingsTable.m b/+types/+core/IntracellularRecordingsTable.m index 41be93db..1fc8d5c9 100644 --- a/+types/+core/IntracellularRecordingsTable.m +++ b/+types/+core/IntracellularRecordingsTable.m @@ -53,7 +53,7 @@ if isequal(val, 'A table to group together a stimulus and response from a single electrode and a single simultaneous recording and for storing metadata about the intracellular recording.') val = 'A table to group together a stimulus and response from a single electrode and a single simultaneous recording and for storing metadata about the intracellular recording.'; else - error('Unable to set the ''description'' property of class ''IntracellularRecordingsTable'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''description'' property of class ''IntracellularRecordingsTable'' because it is read-only.') end end function val = validate_electrodes(obj, val) diff --git a/+types/+core/IntracellularResponsesTable.m b/+types/+core/IntracellularResponsesTable.m index 2f98eee7..1b4979b7 100644 --- a/+types/+core/IntracellularResponsesTable.m +++ b/+types/+core/IntracellularResponsesTable.m @@ -41,7 +41,7 @@ if isequal(val, 'Table for storing intracellular response related metadata.') val = 'Table for storing intracellular response related metadata.'; else - error('Unable to set the ''description'' property of class ''IntracellularResponsesTable'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''description'' property of class ''IntracellularResponsesTable'' because it is read-only.') end end function val = validate_response(obj, val) diff --git a/+types/+core/IntracellularStimuliTable.m b/+types/+core/IntracellularStimuliTable.m index 8e933b92..b0cf39e9 100644 --- a/+types/+core/IntracellularStimuliTable.m +++ b/+types/+core/IntracellularStimuliTable.m @@ -50,7 +50,7 @@ if isequal(val, 'Table for storing intracellular stimulus related metadata.') val = 'Table for storing intracellular stimulus related metadata.'; else - error('Unable to set the ''description'' property of class ''IntracellularStimuliTable'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''description'' property of class ''IntracellularStimuliTable'' because it is read-only.') end end function val = validate_stimulus(obj, val) diff --git a/+types/+core/OptogeneticSeries.m b/+types/+core/OptogeneticSeries.m index 5741153c..92176f50 100644 --- a/+types/+core/OptogeneticSeries.m +++ b/+types/+core/OptogeneticSeries.m @@ -58,7 +58,7 @@ if isequal(val, 'watts') val = 'watts'; else - error('Unable to set the ''data_unit'' property of class ''OptogeneticSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''OptogeneticSeries'' because it is read-only.') end end function val = validate_site(obj, val) diff --git a/+types/+core/SpikeEventSeries.m b/+types/+core/SpikeEventSeries.m index 80611ca7..e397634b 100644 --- a/+types/+core/SpikeEventSeries.m +++ b/+types/+core/SpikeEventSeries.m @@ -56,7 +56,7 @@ if isequal(val, 'volts') val = 'volts'; else - error('Unable to set the ''data_unit'' property of class ''SpikeEventSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''SpikeEventSeries'' because it is read-only.') end end function val = validate_timestamps(obj, val) @@ -81,14 +81,14 @@ if isequal(val, 1) val = 1; else - error('Unable to set the ''timestamps_interval'' property of class ''SpikeEventSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''timestamps_interval'' property of class ''SpikeEventSeries'' because it is read-only.') end end function val = validate_timestamps_unit(obj, val) if isequal(val, 'seconds') val = 'seconds'; else - error('Unable to set the ''timestamps_unit'' property of class ''SpikeEventSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''timestamps_unit'' property of class ''SpikeEventSeries'' because it is read-only.') end end %% EXPORT diff --git a/+types/+core/TimeSeries.m b/+types/+core/TimeSeries.m index 5245289c..2fad2f65 100644 --- a/+types/+core/TimeSeries.m +++ b/+types/+core/TimeSeries.m @@ -418,9 +418,11 @@ %% CUSTOM CONSTRAINTS function checkCustomConstraint(obj) assert(~isempty(obj.timestamps) || ~isempty(obj.starting_time), ... - "'timestamps' or 'starting_time' must be specified") + 'NWB:TimeSeries:TimeNotSpecified', ... + "'timestamps' or 'starting_time' must be specified") if ~isempty(obj.starting_time) assert(~isempty(obj.starting_time_rate), ... + 'NWB:TimeSeries:RateMissing', ... "'starting_time_rate' must be specified when 'starting_time' is specified") end end diff --git a/+types/+core/TimeSeriesReferenceVectorData.m b/+types/+core/TimeSeriesReferenceVectorData.m index 20f77944..719c12d2 100644 --- a/+types/+core/TimeSeriesReferenceVectorData.m +++ b/+types/+core/TimeSeriesReferenceVectorData.m @@ -30,7 +30,7 @@ return; end if ~istable(val) && ~isstruct(val) && ~isa(val, 'containers.Map') - error('Property `data` must be a table,struct, or containers.Map.'); + error('NWB:Type:InvalidPropertyType', 'Property `data` must be a table, struct, or containers.Map.'); end vprops = struct(); vprops.idx_start = 'int32'; diff --git a/+types/+core/VoltageClampSeries.m b/+types/+core/VoltageClampSeries.m index 7591fdd9..50984fc5 100644 --- a/+types/+core/VoltageClampSeries.m +++ b/+types/+core/VoltageClampSeries.m @@ -139,7 +139,7 @@ if isequal(val, 'amperes') val = 'amperes'; else - error('Unable to set the ''data_unit'' property of class ''VoltageClampSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''VoltageClampSeries'' because it is read-only.') end end function val = validate_resistance_comp_bandwidth(obj, val) diff --git a/+types/+core/VoltageClampStimulusSeries.m b/+types/+core/VoltageClampStimulusSeries.m index e81651bd..2df68b7e 100644 --- a/+types/+core/VoltageClampStimulusSeries.m +++ b/+types/+core/VoltageClampStimulusSeries.m @@ -35,7 +35,7 @@ if isequal(val, 'volts') val = 'volts'; else - error('Unable to set the ''data_unit'' property of class ''VoltageClampStimulusSeries'' because it is read-only.') + error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''data_unit'' property of class ''VoltageClampStimulusSeries'' because it is read-only.') end end %% EXPORT diff --git a/+types/+util/+dynamictable/addRow.m b/+types/+util/+dynamictable/addRow.m index 3afceb70..328223c1 100644 --- a/+types/+util/+dynamictable/addRow.m +++ b/+types/+util/+dynamictable/addRow.m @@ -40,7 +40,7 @@ function addRow(DynamicTable, varargin) 'If this was produced with pynwb, please enable chunking for this table.']); if istable(varargin{1}) - error("NWB:DynamicTable", ... + error('NWB:DynamicTable', ... ['Using MATLAB tables as input to the addRow DynamicTable method has '... 'been deprecated. Please, use key-value pairs instead']); else diff --git a/+types/+util/+dynamictable/addTableColumn.m b/+types/+util/+dynamictable/addTableColumn.m index 38503809..dfdba534 100644 --- a/+types/+util/+dynamictable/addTableColumn.m +++ b/+types/+util/+dynamictable/addTableColumn.m @@ -1,4 +1,4 @@ function addTableColumn(DynamicTable, subTable) -error("NWB:DynamicTable", ... +error('NWB:DynamicTable', ... ['Using MATLAB tables as input to the addColumn DynamicTable method has '... 'been deprecated. Please, use key-value pairs instead']) \ No newline at end of file diff --git a/+types/+util/+dynamictable/getRow.m b/+types/+util/+dynamictable/getRow.m index bc5c00a6..97850f21 100644 --- a/+types/+util/+dynamictable/getRow.m +++ b/+types/+util/+dynamictable/getRow.m @@ -63,7 +63,7 @@ if is_row_dim(1) && is_row_dim(end) % Last dimension takes precedence is_row_dim(1:end-1) = false; - warning(... + warning('NWB:DynamicTable:VectorDataAmbiguousSize', ... ['The length of the first and last dimensions of ', ... 'VectorData for column "%s" match the number of ', ... 'rows in the dynamic table. Data is rearranged based on ', ... diff --git a/+types/+util/checkDependent.m b/+types/+util/checkDependent.m index 8de45586..f1b72344 100644 --- a/+types/+util/checkDependent.m +++ b/+types/+util/checkDependent.m @@ -3,7 +3,8 @@ function checkDependent(parent, children, unconstructed) for i=1:length(children) child = children{i}; if any(strcmp(child, unconstructed)) - error('Dependent type `%s` is required for parent property `%s`', child, parent); + error('NWB:CheckDependentType:TypeRequiredForParent', ... + 'Dependent type `%s` is required for parent property `%s`', child, parent); end end end diff --git a/+util/loadTimeSeriesData.m b/+util/loadTimeSeriesData.m index 4fc58d5b..6c6ce212 100644 --- a/+util/loadTimeSeriesData.m +++ b/+util/loadTimeSeriesData.m @@ -30,7 +30,8 @@ if isfinite(interval(2)) data = NaN(ceil(diff(interval) * fs), length(electrodes)); else - error('must specify time interval'); + error('NWB:LoadTimeSeries:UnspecifiedTimeInterval', ... + 'must specify time interval'); end for i = 1:length(electrodes) data(:,i) = util.loadTimeSeriesData(timeseries, interval, ... @@ -47,7 +48,8 @@ fs = timeseries.starting_time_rate; t0 = timeseries.starting_time; if interval(1) < t0 - error('interval bounds outside of time range'); + error('NWB:LoadTimeSeries:InvalidTimeInterval', ... + 'interval bounds outside of time range'); end start_ind = (interval(1) - t0) * fs; end @@ -63,7 +65,8 @@ fs = timeseries.starting_time_rate; t0 = timeseries.starting_time; if interval(2) > (dims(end) * fs + t0) - error('interval bounds outside of time range'); + error('NWB:LoadTimeSeries:InvalidTimeInterval', ... + 'interval bounds outside of time range'); end end_ind = (interval(2) - t0) * fs; end diff --git a/+util/loadTimeSeriesTimestamps.m b/+util/loadTimeSeriesTimestamps.m index 1d5b5efc..c2579c2f 100644 --- a/+util/loadTimeSeriesTimestamps.m +++ b/+util/loadTimeSeriesTimestamps.m @@ -28,8 +28,9 @@ else if downsample_factor ~= 1 - warning(['Downsampling a timestamps of a timeseries that may'... - 'not be uniformly sampled. This may have unintended behavior']) + warning('NWB:LoadTimeStamps:DownsampleNonUniformTimestamps', ... + [ 'Downsampling timestamps of a timeseries that may' ... + 'not be uniformly sampled. This may have unintended behavior']) end start_ind = fastsearch(timeseries.timestamps, interval(1), 1); if isinf(interval(2)) diff --git a/+util/read_indexed_column.m b/+util/read_indexed_column.m index 90af97ec..34e0c9c6 100644 --- a/+util/read_indexed_column.m +++ b/+util/read_indexed_column.m @@ -1,5 +1,5 @@ function data = read_indexed_column(vector_index, vector_data, row) -error("NWB:read_indexed_column", ... +error('NWB:read_indexed_column', ... ['The utility function read_indexed_column has been reprecated. Please,' ... ' use the getRow method of DynamicTable objects instead'] ... ) \ No newline at end of file