-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for NWB schemas v2.8.0 (#630)
* Add nwb 2.8.0 schemas and regenerated types * Update requirements to use pynwb and nwbinspector from github@dev * ... * Fix typo of name for dataset in bands table in ecephys tutorial * debug unexpected pynwb version * Remove hdmf-zarr dependency, as it is not used * Fix: Make inherited read-only datasets in schema read-only properties in matnwb * Add debug flag for printing installed python packages in PynwbTutorialTest * Add more detailed device example to ecephys tutorial * Add more detailed device example to ophys tutorial
- Loading branch information
1 parent
7dfde02
commit 42e9995
Showing
34 changed files
with
4,453 additions
and
889 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pynwb | ||
hdf5plugin | ||
nwbinspector | ||
git+https://github.com/NeurodataWithoutBorders/nwbinspector.git@dev | ||
git+https://github.com/NeurodataWithoutBorders/pynwb.git@dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,11 @@ | |
|
||
% OPTIONAL PROPERTIES | ||
properties | ||
description; % (char) Description of the device (e.g., model, firmware version, processing software version, etc.) as free-form text. | ||
manufacturer; % (char) The name of the manufacturer of the device. | ||
description; % (char) Description of the device as free-form text. If there is any software/firmware associated with the device, the names and versions of those can be added to NWBFile.was_generated_by. | ||
manufacturer; % (char) The name of the manufacturer of the device, e.g., Imec, Plexon, Thorlabs. | ||
model_name; % (char) The model name of the device, e.g., Neuropixels 1.0, V-Probe, Bergamo III. | ||
model_number; % (char) The model number (or part/product number) of the device, e.g., PRB_1_4_0480_1, PLX-VP-32-15SE(75)-(260-80)(460-10)-300-(1)CON/32m-V, BERGAMO. | ||
serial_number; % (char) The serial number of the device. | ||
end | ||
|
||
methods | ||
|
@@ -20,9 +23,15 @@ | |
p.StructExpand = false; | ||
addParameter(p, 'description',[]); | ||
addParameter(p, 'manufacturer',[]); | ||
addParameter(p, 'model_name',[]); | ||
addParameter(p, 'model_number',[]); | ||
addParameter(p, 'serial_number',[]); | ||
misc.parseSkipInvalidName(p, varargin); | ||
obj.description = p.Results.description; | ||
obj.manufacturer = p.Results.manufacturer; | ||
obj.model_name = p.Results.model_name; | ||
obj.model_number = p.Results.model_number; | ||
obj.serial_number = p.Results.serial_number; | ||
if strcmp(class(obj), 'types.core.Device') | ||
cellStringArguments = convertContainedStringsToChars(varargin(1:2:end)); | ||
types.util.checkUnset(obj, unique(cellStringArguments)); | ||
|
@@ -35,6 +44,15 @@ | |
function set.manufacturer(obj, val) | ||
obj.manufacturer = obj.validate_manufacturer(val); | ||
end | ||
function set.model_name(obj, val) | ||
obj.model_name = obj.validate_model_name(val); | ||
end | ||
function set.model_number(obj, val) | ||
obj.model_number = obj.validate_model_number(val); | ||
end | ||
function set.serial_number(obj, val) | ||
obj.serial_number = obj.validate_serial_number(val); | ||
end | ||
%% VALIDATORS | ||
|
||
function val = validate_description(obj, val) | ||
|
@@ -73,6 +91,60 @@ | |
validshapes = {[1]}; | ||
types.util.checkDims(valsz, validshapes); | ||
end | ||
function val = validate_model_name(obj, val) | ||
val = types.util.checkDtype('model_name', '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_model_number(obj, val) | ||
val = types.util.checkDtype('model_number', '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_serial_number(obj, val) | ||
val = types.util.checkDtype('serial_number', '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 | ||
%% EXPORT | ||
function refs = export(obj, fid, fullpath, refs) | ||
refs = [email protected](obj, fid, fullpath, refs); | ||
|
@@ -85,6 +157,15 @@ | |
if ~isempty(obj.manufacturer) | ||
io.writeAttribute(fid, [fullpath '/manufacturer'], obj.manufacturer); | ||
end | ||
if ~isempty(obj.model_name) | ||
io.writeAttribute(fid, [fullpath '/model_name'], obj.model_name); | ||
end | ||
if ~isempty(obj.model_number) | ||
io.writeAttribute(fid, [fullpath '/model_number'], obj.model_number); | ||
end | ||
if ~isempty(obj.serial_number) | ||
io.writeAttribute(fid, [fullpath '/serial_number'], obj.serial_number); | ||
end | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,7 @@ | |
general_subject; % (Subject) Information about the animal or person from which the data was measured. | ||
general_surgery; % (char) Narrative description about surgery/surgeries, including date(s) and who performed surgery. | ||
general_virus; % (char) Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc. | ||
general_was_generated_by; % (char) Name and version of software package(s) used to generate data contained in this NWB File. For each software package or library, include the name of the software as the first value and the version as the second value. | ||
intervals; % (TimeIntervals) Optional additional table(s) for describing other experimental time intervals. | ||
intervals_epochs; % (TimeIntervals) Divisions in time marking experimental stages or sub-divisions of a single recording session. | ||
intervals_invalid_times; % (TimeIntervals) Time intervals that should be removed from analysis. | ||
|
@@ -64,7 +65,7 @@ | |
methods | ||
function obj = NWBFile(varargin) | ||
% NWBFILE Constructor for NWBFile | ||
varargin = [{'nwb_version' '2.7.0'} varargin]; | ||
varargin = [{'nwb_version' '2.8.0'} varargin]; | ||
obj = [email protected](varargin{:}); | ||
|
||
|
||
|
@@ -107,6 +108,7 @@ | |
addParameter(p, 'general_subject',[]); | ||
addParameter(p, 'general_surgery',[]); | ||
addParameter(p, 'general_virus',[]); | ||
addParameter(p, 'general_was_generated_by',[]); | ||
addParameter(p, 'identifier',[]); | ||
addParameter(p, 'intervals',types.untyped.Set()); | ||
addParameter(p, 'intervals_epochs',[]); | ||
|
@@ -157,6 +159,7 @@ | |
obj.general_subject = p.Results.general_subject; | ||
obj.general_surgery = p.Results.general_surgery; | ||
obj.general_virus = p.Results.general_virus; | ||
obj.general_was_generated_by = p.Results.general_was_generated_by; | ||
obj.identifier = p.Results.identifier; | ||
obj.intervals = p.Results.intervals; | ||
obj.intervals_epochs = p.Results.intervals_epochs; | ||
|
@@ -282,6 +285,9 @@ | |
function set.general_virus(obj, val) | ||
obj.general_virus = obj.validate_general_virus(val); | ||
end | ||
function set.general_was_generated_by(obj, val) | ||
obj.general_was_generated_by = obj.validate_general_was_generated_by(val); | ||
end | ||
function set.identifier(obj, val) | ||
obj.identifier = obj.validate_identifier(val); | ||
end | ||
|
@@ -727,6 +733,24 @@ | |
validshapes = {[1]}; | ||
types.util.checkDims(valsz, validshapes); | ||
end | ||
function val = validate_general_was_generated_by(obj, val) | ||
val = types.util.checkDtype('general_was_generated_by', '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 = {[2,Inf]}; | ||
types.util.checkDims(valsz, validshapes); | ||
end | ||
function val = validate_identifier(obj, val) | ||
val = types.util.checkDtype('identifier', 'char', val); | ||
if isa(val, 'types.untyped.DataStub') | ||
|
@@ -1041,6 +1065,14 @@ | |
io.writeDataset(fid, [fullpath '/general/virus'], obj.general_virus); | ||
end | ||
end | ||
io.writeGroup(fid, [fullpath '/general']); | ||
if ~isempty(obj.general_was_generated_by) | ||
if startsWith(class(obj.general_was_generated_by), 'types.untyped.') | ||
refs = obj.general_was_generated_by.export(fid, [fullpath '/general/was_generated_by'], refs); | ||
elseif ~isempty(obj.general_was_generated_by) | ||
io.writeDataset(fid, [fullpath '/general/was_generated_by'], obj.general_was_generated_by, 'forceArray'); | ||
end | ||
end | ||
if startsWith(class(obj.identifier), 'types.untyped.') | ||
refs = obj.identifier.export(fid, [fullpath '/identifier'], refs); | ||
elseif ~isempty(obj.identifier) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.