matnwb
matnwb copied to clipboard
[Bug]: DataStub errors out if trying to retrieve data with empty indices
What happened?
I ran the convertTrials tutorial (branch: 515-fix-convert-trials-tutorial) and tried to run the following:
Steps to Reproduce
nwbIn = nwbRead(nwbFilePath);
nwbIn.intervals_trials.toTable()
Error Message
Error using hdf5lib2
The HDF5 library encountered an error and produced the following stack trace information:
H5Sselect_elements elements not specified
Error in H5S.select_elements (line 43)
H5ML.hdf5lib2('H5Sselect_elements', space_id, op, h5_coord);
Error in types.untyped.DataStub/load_mat_style (line 52)
H5S.select_elements(readSpaceId, 'H5S_SELECT_SET', ...
Error in indexing (line 169)
data = obj.load_mat_style(CurrentSubRef.subs{:});
Error in types.util.dynamictable.getRow>select (line 170)
selected = Vector.data(selectInd{:});
Error in types.util.dynamictable.getRow>select (line 205)
selected{iRange} = select(DynamicTable,...
Error in types.util.dynamictable.getRow (line 49)
row{i} = select(DynamicTable, indexNames, ind);
Error in types.hdmf_common.DynamicTable/getRow (line 120)
row = types.util.dynamictable.getRow(obj, id, varargin{:});
Error in types.util.dynamictable.nwbToTable (line 81)
matlabTable = [matlabTable DynamicTable.getRow( ...
Error in types.hdmf_common.DynamicTable/toTable (line 124)
table = types.util.dynamictable.nwbToTable(obj, varargin{:});
Operating System
macOS
Matlab Version
R2023b
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
- [X] Have you ensured this bug was not already reported?
The error occurs because some of the rows in timeseries_index of the intervals_trials are empty, i.e does not point to any timeseries.
In MATLAB, it is possible to use empty indices, and this could be implemented for DataStub as well.
e.g.
a = struct
a =
struct with no fields.
K>> a([])
ans =
0×0 empty struct array with no fields.
@bendichter @lawrence-mbf I added a proposed fix and it works in the specific case where this error happens. It is not a very general fix, and there may be better ways to solve this?