Skip to content

Commit

Permalink
Pregenerate class files in the repo (#556)
Browse files Browse the repository at this point in the history
* add generated classes for schema version 2.6.0

* remove previously ignored class files from repo

* add script for clearing generated classes

* ignore class files when running tests

* remove utility script from coverage

* adjust README.md

---------

Co-authored-by: Ben Dichter <[email protected]>
  • Loading branch information
lawrence-mbf and bendichter authored Jan 4, 2024
1 parent ec01001 commit 5674971
Show file tree
Hide file tree
Showing 97 changed files with 10,535 additions and 94 deletions.
141 changes: 141 additions & 0 deletions +types/+core/AbstractFeatureSeries.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
classdef AbstractFeatureSeries < types.core.TimeSeries & types.untyped.GroupClass
% ABSTRACTFEATURESERIES Abstract features, such as quantitative descriptions of sensory stimuli. The TimeSeries::data field is a 2D array, storing those features (e.g., for visual grating stimulus this might be orientation, spatial frequency and contrast). Null stimuli (eg, uniform gray) can be marked as being an independent feature (eg, 1.0 for gray, 0.0 for actual stimulus) or by storing NaNs for feature values, or through use of the TimeSeries::control fields. A set of features is considered to persist until the next set of features is defined. The final set of features stored should be the null set. This is useful when storing the raw stimulus is impractical.


% REQUIRED PROPERTIES
properties
features; % REQUIRED (char) Description of the features represented in TimeSeries::data.
end
% OPTIONAL PROPERTIES
properties
feature_units; % (char) Units of each feature.
end

methods
function obj = AbstractFeatureSeries(varargin)
% ABSTRACTFEATURESERIES Constructor for AbstractFeatureSeries
varargin = [{'data_unit' 'see `feature_units`'} varargin];
obj = [email protected](varargin{:});


p = inputParser;
p.KeepUnmatched = true;
p.PartialMatching = false;
p.StructExpand = false;
addParameter(p, 'data',[]);
addParameter(p, 'data_unit',[]);
addParameter(p, 'feature_units',[]);
addParameter(p, 'features',[]);
misc.parseSkipInvalidName(p, varargin);
obj.data = p.Results.data;
obj.data_unit = p.Results.data_unit;
obj.feature_units = p.Results.feature_units;
obj.features = p.Results.features;
if strcmp(class(obj), 'types.core.AbstractFeatureSeries')
cellStringArguments = convertContainedStringsToChars(varargin(1:2:end));
types.util.checkUnset(obj, unique(cellStringArguments));
end
end
%% SETTERS
function set.feature_units(obj, val)
obj.feature_units = obj.validate_feature_units(val);
end
function set.features(obj, val)
obj.features = obj.validate_features(val);
end
%% VALIDATORS

function val = validate_data(obj, val)
val = types.util.checkDtype('data', 'numeric', val);
if isa(val, 'types.untyped.DataStub')
if 1 == val.ndims
valsz = [val.dims 1];
else
valsz = val.dims;
end
elseif istable(val)
valsz = [height(val) 1];
elseif ischar(val)
valsz = [size(val, 1) 1];
else
valsz = size(val);
end
validshapes = {[Inf,Inf], [Inf]};
types.util.checkDims(valsz, validshapes);
end
function val = validate_data_unit(obj, val)
val = types.util.checkDtype('data_unit', 'char', val);
if isa(val, 'types.untyped.DataStub')
if 1 == val.ndims
valsz = [val.dims 1];
else
valsz = val.dims;
end
elseif istable(val)
valsz = [height(val) 1];
elseif ischar(val)
valsz = [size(val, 1) 1];
else
valsz = size(val);
end
validshapes = {[1]};
types.util.checkDims(valsz, validshapes);
end
function val = validate_feature_units(obj, val)
val = types.util.checkDtype('feature_units', 'char', val);
if isa(val, 'types.untyped.DataStub')
if 1 == val.ndims
valsz = [val.dims 1];
else
valsz = val.dims;
end
elseif istable(val)
valsz = [height(val) 1];
elseif ischar(val)
valsz = [size(val, 1) 1];
else
valsz = size(val);
end
validshapes = {[Inf]};
types.util.checkDims(valsz, validshapes);
end
function val = validate_features(obj, val)
val = types.util.checkDtype('features', 'char', val);
if isa(val, 'types.untyped.DataStub')
if 1 == val.ndims
valsz = [val.dims 1];
else
valsz = val.dims;
end
elseif istable(val)
valsz = [height(val) 1];
elseif ischar(val)
valsz = [size(val, 1) 1];
else
valsz = size(val);
end
validshapes = {[Inf]};
types.util.checkDims(valsz, validshapes);
end
%% EXPORT
function refs = export(obj, fid, fullpath, refs)
refs = [email protected](obj, fid, fullpath, refs);
if any(strcmp(refs, fullpath))
return;
end
if ~isempty(obj.feature_units)
if startsWith(class(obj.feature_units), 'types.untyped.')
refs = obj.feature_units.export(fid, [fullpath '/feature_units'], refs);
elseif ~isempty(obj.feature_units)
io.writeDataset(fid, [fullpath '/feature_units'], obj.feature_units, 'forceArray');
end
end
if startsWith(class(obj.features), 'types.untyped.')
refs = obj.features.export(fid, [fullpath '/features'], refs);
elseif ~isempty(obj.features)
io.writeDataset(fid, [fullpath '/features'], obj.features, 'forceArray');
end
end
end

end
60 changes: 60 additions & 0 deletions +types/+core/AnnotationSeries.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
classdef AnnotationSeries < types.core.TimeSeries & types.untyped.GroupClass
% ANNOTATIONSERIES Stores user annotations made during an experiment. The data[] field stores a text array, and timestamps are stored for each annotation (ie, interval=1). This is largely an alias to a standard TimeSeries storing a text array but that is identifiable as storing annotations in a machine-readable way.



methods
function obj = AnnotationSeries(varargin)
% ANNOTATIONSERIES Constructor for AnnotationSeries
varargin = [{'data_resolution' types.util.correctType(-1, 'single') 'data_unit' 'n/a'} varargin];
obj = [email protected](varargin{:});


p = inputParser;
p.KeepUnmatched = true;
p.PartialMatching = false;
p.StructExpand = false;
addParameter(p, 'data',[]);
addParameter(p, 'data_resolution',[]);
addParameter(p, 'data_unit',[]);
misc.parseSkipInvalidName(p, varargin);
obj.data = p.Results.data;
obj.data_resolution = p.Results.data_resolution;
obj.data_unit = p.Results.data_unit;
if strcmp(class(obj), 'types.core.AnnotationSeries')
cellStringArguments = convertContainedStringsToChars(varargin(1:2:end));
types.util.checkUnset(obj, unique(cellStringArguments));
end
end
%% SETTERS

%% VALIDATORS

function val = validate_data(obj, val)
val = types.util.checkDtype('data', 'char', val);
if isa(val, 'types.untyped.DataStub')
if 1 == val.ndims
valsz = [val.dims 1];
else
valsz = val.dims;
end
elseif istable(val)
valsz = [height(val) 1];
elseif ischar(val)
valsz = [size(val, 1) 1];
else
valsz = size(val);
end
validshapes = {[Inf]};
types.util.checkDims(valsz, validshapes);
end
%% EXPORT
function refs = export(obj, fid, fullpath, refs)
refs = [email protected](obj, fid, fullpath, refs);
if any(strcmp(refs, fullpath))
return;
end
end
end

end
50 changes: 50 additions & 0 deletions +types/+core/BehavioralEpochs.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
classdef BehavioralEpochs < types.core.NWBDataInterface & types.untyped.GroupClass
% BEHAVIORALEPOCHS TimeSeries for storing behavioral epochs. The objective of this and the other two Behavioral interfaces (e.g. BehavioralEvents and BehavioralTimeSeries) is to provide generic hooks for software tools/scripts. This allows a tool/script to take the output one specific interface (e.g., UnitTimes) and plot that data relative to another data modality (e.g., behavioral events) without having to define all possible modalities in advance. Declaring one of these interfaces means that one or more TimeSeries of the specified type is published. These TimeSeries should reside in a group having the same name as the interface. For example, if a BehavioralTimeSeries interface is declared, the module will have one or more TimeSeries defined in the module sub-group 'BehavioralTimeSeries'. BehavioralEpochs should use IntervalSeries. BehavioralEvents is used for irregular events. BehavioralTimeSeries is for continuous data.


% OPTIONAL PROPERTIES
properties
intervalseries; % (IntervalSeries) IntervalSeries object containing start and stop times of epochs.
end

methods
function obj = BehavioralEpochs(varargin)
% BEHAVIORALEPOCHS Constructor for BehavioralEpochs
obj = [email protected](varargin{:});
[obj.intervalseries, ivarargin] = types.util.parseConstrained(obj,'intervalseries', 'types.core.IntervalSeries', varargin{:});
varargin(ivarargin) = [];

p = inputParser;
p.KeepUnmatched = true;
p.PartialMatching = false;
p.StructExpand = false;
misc.parseSkipInvalidName(p, varargin);
if strcmp(class(obj), 'types.core.BehavioralEpochs')
cellStringArguments = convertContainedStringsToChars(varargin(1:2:end));
types.util.checkUnset(obj, unique(cellStringArguments));
end
end
%% SETTERS
function set.intervalseries(obj, val)
obj.intervalseries = obj.validate_intervalseries(val);
end
%% VALIDATORS

function val = validate_intervalseries(obj, val)
namedprops = struct();
constrained = {'types.core.IntervalSeries'};
types.util.checkSet('intervalseries', namedprops, constrained, val);
end
%% EXPORT
function refs = export(obj, fid, fullpath, refs)
refs = [email protected](obj, fid, fullpath, refs);
if any(strcmp(refs, fullpath))
return;
end
if ~isempty(obj.intervalseries)
refs = obj.intervalseries.export(fid, fullpath, refs);
end
end
end

end
50 changes: 50 additions & 0 deletions +types/+core/BehavioralEvents.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
classdef BehavioralEvents < types.core.NWBDataInterface & types.untyped.GroupClass
% BEHAVIORALEVENTS TimeSeries for storing behavioral events. See description of <a href="#BehavioralEpochs">BehavioralEpochs</a> for more details.


% OPTIONAL PROPERTIES
properties
timeseries; % (TimeSeries) TimeSeries object containing behavioral events.
end

methods
function obj = BehavioralEvents(varargin)
% BEHAVIORALEVENTS Constructor for BehavioralEvents
obj = [email protected](varargin{:});
[obj.timeseries, ivarargin] = types.util.parseConstrained(obj,'timeseries', 'types.core.TimeSeries', varargin{:});
varargin(ivarargin) = [];

p = inputParser;
p.KeepUnmatched = true;
p.PartialMatching = false;
p.StructExpand = false;
misc.parseSkipInvalidName(p, varargin);
if strcmp(class(obj), 'types.core.BehavioralEvents')
cellStringArguments = convertContainedStringsToChars(varargin(1:2:end));
types.util.checkUnset(obj, unique(cellStringArguments));
end
end
%% SETTERS
function set.timeseries(obj, val)
obj.timeseries = obj.validate_timeseries(val);
end
%% VALIDATORS

function val = validate_timeseries(obj, val)
namedprops = struct();
constrained = {'types.core.TimeSeries'};
types.util.checkSet('timeseries', namedprops, constrained, val);
end
%% EXPORT
function refs = export(obj, fid, fullpath, refs)
refs = [email protected](obj, fid, fullpath, refs);
if any(strcmp(refs, fullpath))
return;
end
if ~isempty(obj.timeseries)
refs = obj.timeseries.export(fid, fullpath, refs);
end
end
end

end
50 changes: 50 additions & 0 deletions +types/+core/BehavioralTimeSeries.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
classdef BehavioralTimeSeries < types.core.NWBDataInterface & types.untyped.GroupClass
% BEHAVIORALTIMESERIES TimeSeries for storing Behavoioral time series data. See description of <a href="#BehavioralEpochs">BehavioralEpochs</a> for more details.


% OPTIONAL PROPERTIES
properties
timeseries; % (TimeSeries) TimeSeries object containing continuous behavioral data.
end

methods
function obj = BehavioralTimeSeries(varargin)
% BEHAVIORALTIMESERIES Constructor for BehavioralTimeSeries
obj = [email protected](varargin{:});
[obj.timeseries, ivarargin] = types.util.parseConstrained(obj,'timeseries', 'types.core.TimeSeries', varargin{:});
varargin(ivarargin) = [];

p = inputParser;
p.KeepUnmatched = true;
p.PartialMatching = false;
p.StructExpand = false;
misc.parseSkipInvalidName(p, varargin);
if strcmp(class(obj), 'types.core.BehavioralTimeSeries')
cellStringArguments = convertContainedStringsToChars(varargin(1:2:end));
types.util.checkUnset(obj, unique(cellStringArguments));
end
end
%% SETTERS
function set.timeseries(obj, val)
obj.timeseries = obj.validate_timeseries(val);
end
%% VALIDATORS

function val = validate_timeseries(obj, val)
namedprops = struct();
constrained = {'types.core.TimeSeries'};
types.util.checkSet('timeseries', namedprops, constrained, val);
end
%% EXPORT
function refs = export(obj, fid, fullpath, refs)
refs = [email protected](obj, fid, fullpath, refs);
if any(strcmp(refs, fullpath))
return;
end
if ~isempty(obj.timeseries)
refs = obj.timeseries.export(fid, fullpath, refs);
end
end
end

end
Loading

0 comments on commit 5674971

Please sign in to comment.