Skip to content

Commit

Permalink
Merge branch 'master' into 559-update-link-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ehennestad committed Nov 28, 2024
2 parents 055b617 + 7dfde02 commit ee32dee
Show file tree
Hide file tree
Showing 20 changed files with 1,577 additions and 1,056 deletions.
2 changes: 1 addition & 1 deletion +file/Attribute.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
else
obj.value = [];
obj.readonly = false;
end
end

if isKey(source, 'dims')
obj.dimnames = source('dims');
Expand Down
19 changes: 19 additions & 0 deletions +file/Dataset.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
dtype;
isConstrainedSet;
required;
value;
readonly; %determines whether value can be changed or not
scalar;
shape;
dimnames;
Expand All @@ -22,12 +24,15 @@
obj.type = '';
obj.dtype = 'any';
obj.required = true;
obj.value = [];
obj.readonly = false;
obj.scalar = true;
obj.definesType = false;

obj.shape = {};
obj.dimnames = {};
obj.attributes = [];


if nargin < 1
return;
Expand All @@ -42,6 +47,20 @@
if isKey(source, nameKey)
obj.name = source(nameKey);
end

% Todo: same as for attribute, should consolidate
valueKey = 'value';
defaultKey = 'default_value';
if isKey(source, defaultKey)
obj.value = source(defaultKey);
obj.readonly = false;
elseif isKey(source, valueKey)
obj.value = source(valueKey);
obj.readonly = true;
else
obj.value = [];
obj.readonly = false;
end

typeKeys = {'neurodata_type_def', 'data_type_def'};
parentKeys = {'neurodata_type_inc', 'data_type_inc'};
Expand Down
12 changes: 9 additions & 3 deletions +file/fillClass.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,22 @@
optional = [optional {propertyName}];
end

if isa(prop, 'file.Attribute')
if isa(prop, 'file.Attribute') || isa(prop, 'file.Dataset')
if prop.readonly
readonly = [readonly {propertyName}];
end

if ~isempty(prop.value)
defaults = [defaults {propertyName}];
if isa(prop, 'file.Attribute')
defaults = [defaults {propertyName}];
else % file.Dataset
if isRequired || all(isPropertyRequired)
defaults = [defaults {propertyName}];
end
end
end

if ~isempty(prop.dependent)
if isa(prop, 'file.Attribute') && ~isempty(prop.dependent)
%extract prefix
parentName = strrep(propertyName, ['_' prop.name], '');
parent = classprops(parentName);
Expand Down
3 changes: 2 additions & 1 deletion +file/fillValidators.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
nm = propnames{i};
prop = props(nm);

if isa(prop, 'file.Attribute') && prop.readonly && ~isempty(prop.value)
if (isa(prop, 'file.Attribute') || isa(prop, 'file.Dataset')) ...
&& prop.readonly && ~isempty(prop.value)
% Need to add a validator for inherited and readonly properties. In
% the superclass these properties might not be read only and due to
% inheritance its not possible to change property attributes
Expand Down
3 changes: 2 additions & 1 deletion +tests/+unit/TutorialTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ function inspectTutorialFileWithNwbInspector(testCase)
results = py.list(py.nwbinspector.inspect_nwbfile(nwbfile_path=nwbFilename));
results = testCase.convertNwbInspectorResultsToStruct(results);
elseif testCase.NWBInspectorMode == "CLI"
[~, m] = system(sprintf('nwbinspector %s --levels importance', nwbFilename));
[s, m] = system(sprintf('nwbinspector %s --levels importance', nwbFilename));
testCase.assertEqual(s,0, 'Failed to run NWB Inspector using system command.')
results = testCase.parseNWBInspectorTextOutput(m);
end

Expand Down
2 changes: 1 addition & 1 deletion +tests/+util/getPythonPath.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function pythonPath = getPythonPath()
envPath = fullfile('+tests', 'env.mat');

if isfile(envPath)
if isfile(fullfile(misc.getMatnwbDir, envPath))
Env = load(envPath, '-mat');
if isfield(Env, 'pythonPath')
pythonPath = Env.pythonPath;
Expand Down
53 changes: 10 additions & 43 deletions +types/+core/IZeroClampSeries.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
methods
function obj = IZeroClampSeries(varargin)
% IZEROCLAMPSERIES Constructor for IZeroClampSeries
varargin = [{'stimulus_description' 'N/A'} varargin];
varargin = [{'bias_current' types.util.correctType(0, 'single') 'bridge_balance' types.util.correctType(0, 'single') 'capacitance_compensation' types.util.correctType(0, 'single') 'stimulus_description' 'N/A'} varargin];
obj = obj@types.core.CurrentClampSeries(varargin{:});


Expand All @@ -33,58 +33,25 @@
%% VALIDATORS

function val = validate_bias_current(obj, val)
val = types.util.checkDtype('bias_current', 'single', 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];
if isequal(val, 0)
val = 0;
else
valsz = size(val);
error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''bias_current'' property of class ''<a href="matlab:doc types.core.IZeroClampSeries">IZeroClampSeries</a>'' because it is read-only.')
end
validshapes = {[1]};
types.util.checkDims(valsz, validshapes);
end
function val = validate_bridge_balance(obj, val)
val = types.util.checkDtype('bridge_balance', 'single', 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];
if isequal(val, 0)
val = 0;
else
valsz = size(val);
error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''bridge_balance'' property of class ''<a href="matlab:doc types.core.IZeroClampSeries">IZeroClampSeries</a>'' because it is read-only.')
end
validshapes = {[1]};
types.util.checkDims(valsz, validshapes);
end
function val = validate_capacitance_compensation(obj, val)
val = types.util.checkDtype('capacitance_compensation', 'single', 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];
if isequal(val, 0)
val = 0;
else
valsz = size(val);
error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''capacitance_compensation'' property of class ''<a href="matlab:doc types.core.IZeroClampSeries">IZeroClampSeries</a>'' because it is read-only.')
end
validshapes = {[1]};
types.util.checkDims(valsz, validshapes);
end
function val = validate_stimulus_description(obj, val)
if isequal(val, 'N/A')
Expand Down
4 changes: 2 additions & 2 deletions +util/table2nwb.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

for col = T
if ~strcmp(col.Properties.VariableNames{1},'id')

if ~isempty(col.Properties.VariableDescriptions{1})
if ~isempty(col.Properties.VariableDescriptions) ...
&& ~isempty(col.Properties.VariableDescriptions{1})
description = col.Properties.VariableDescriptions{1};
else
description = 'no description provided';
Expand Down
Binary file modified tutorials/ecephys.mlx
Binary file not shown.
Loading

0 comments on commit ee32dee

Please sign in to comment.