Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addRow function appending to wrong dimension of multidimensional matrices #364

Closed
cechava opened this issue Dec 14, 2021 · 1 comment · Fixed by #387
Closed

addRow function appending to wrong dimension of multidimensional matrices #364

cechava opened this issue Dec 14, 2021 · 1 comment · Fixed by #387
Assignees

Comments

@cechava
Copy link
Collaborator

cechava commented Dec 14, 2021

Given MATLAB's rows-last mode of input-output with NWB files, the .addRow method of DynamicTable objects should append to last dimension of multi-dimensional columns.

An example:

file= NwbFile( ...
    'session_start_time', '2021-01-01 00:00:00', ...
    'identifier', 'ident1', ...
    'session_description', 'test' ...
    );

colnames = {'start_time', 'stop_time', 'randomvalues'};
multi_dim_table1 = types.core.TimeIntervals(...
    'description', 'test dynamic table column',...
    'colnames', colnames);
            
for i = 1:100
    multi_dim_table1.addRow(...
        'start_time', i,...
        'stop_time', i+1,...
        'randomvalues',rand(1,3,2),...
        'id', i-1);
end
file.intervals.set('multi', multi_dim_table1);
nwbExport(file, 'test_multi_addRow.nwb');

The code above produces a 100x3x2 array for the 'randomvalues' column which is encoded into file as 3x2x100 (see below).

Screen Shot 2021-12-14 at 11 52 31 AM

The correct behavior would append each 3x2 matrix to the last dimension to produce a 3x2x100 array that is encoded into file as a 100x3x2 array.

This modification would resolve the concerns brought up in the discussion of issue #360

@cechava
Copy link
Collaborator Author

cechava commented Dec 14, 2021

Upon further thought, going down this path will also mean modifying the checkConfig utility functions to ensure that:

  1. length of row ID's matches the length of the last dimension of multidimensional columns

  2. when checking for equal length of columns, the length of the last dimension of multidimensional columns should be considered instead of the first.

Probably there should also be some special handling of ragged multidimensional columns since it would be the last dimension that the a VectorIndex column would be intending to modify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants