NeurodataWithoutBorders / matnwb

A Matlab interface for reading and writing NWB files
BSD 2-Clause "Simplified" License
50 stars 32 forks source link

getRow does not work with an expandable table #328

Closed cechava closed 2 years ago

cechava commented 2 years ago

using getRow with an expandable table that has been loaded-in produces an error.

The following code generates and saves to file an expandable table

col1_exp = types.hdmf_common.VectorData( ...
    'description', 'column #1', ...
    'data', types.untyped.DataPipe('data', [1; 2], ...  # data must be numerical
        'maxSize', [Inf, 1], ...
        'axis', 1 ...
    ) ...
);
col2_exp = types.hdmf_common.VectorData('description', 'column #2',...
    'data',types.untyped.DataPipe('data', [10; 20], ...  #data must be numerical
        'maxSize', [Inf, 1], ...
        'axis', 1 ...
    ) ...
);
col3_exp = types.hdmf_common.VectorData('description', 'column #3',...
    'data',types.untyped.DataPipe('data', [100; 200], ...  #data must be numerical
        'maxSize', [Inf, 1], ...
        'axis', 1 ...
    ) ...
);
ids_exp = types.hdmf_common.ElementIdentifiers('data', ...
    types.untyped.DataPipe('data', [0;1], ...  # data must be numerical
        'maxSize', [Inf, 1], ...
        'axis', 1 ...
        )...
    );

table_exp = types.core.TimeIntervals(...
    'description', 'test expandable dynamic table',...
    'colnames', {'start_time','stop_time','values'},...
    'start_time',col1_exp,'stop_time',col2_exp,'values',col3_exp,...
    'id', ids_exp);

file=NwbFile(...
    'session_start_time','2020-01-01 00:00:00',...
    'identifier','ident1',...
    'session_description','DataPipeTutorial');
file.intervals_trials =table_exp;
nwbExport(file, 'test_expandable.nwb');

The following code loads the expandable table and attempts to get the first row

in_file = nwbRead('test_expandable.nwb');
in_file.intervals_trials.getRow(1)

The following error is produced:

Unrecognized method, property, or field 'dims' for class
'types.untyped.DataPipe'.

Error in types.util.dynamictable.getRow>select (line 63)
        rank = length(Vector.data.dims);

Error in types.util.dynamictable.getRow (line 44)
    row{i} = select(DynamicTable, indexNames, ind);

Error in types.hdmf_common.DynamicTable/getRow (line 121)
        row = types.util.dynamictable.getRow(obj, id, varargin{:});
bendichter commented 2 years ago

@cechava good find! Can you fix this? It should be something like https://github.com/NeurodataWithoutBorders/matnwb/pull/329

cechava commented 2 years ago

working on it now. Looks like the issue is with the changes introduced to support nested VectorIndices.

Trying to fix without breaking anything else

cechava commented 2 years ago

fixed with #330