NeurodataWithoutBorders / matnwb

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

[Bug]: #516

Closed jc192015 closed 11 months ago

jc192015 commented 11 months ago

What happened?

Failed to create a TimeIntervals table. I am wondering if there is something with the installed MatNWB (2.6.0). Thank you in advance for your time.

Steps to Reproduce

trialTypeStr = {'HitR';
    'HitL';
    'ErrR';
    'ErrL';
    'NoLickR';
    'NoLickL';
    'LickEarly';
    'StimTrials'};

keyNames = {'PoleInTime',    'PoleOutTime',    'CueTime' ,   'GoodTrials',    'Photostimulatio…'};

trialIds = [1:213];

trials_epoch = types.core.TimeIntervals(...
      'colnames', [trialTypeStr; keyNames .';...
        {'start_time'; 'stop_time'; 'acquisition'; 'timeseries'}],...
    'description', 'trial data and properties', ...
    'id', types.hdmf_common.ElementIdentifiers('data', trialIds));

Error Message

Error using assert
Special column `id` of DynamicTable needs to match the detected height of 0. Found 213 IDs.

Error in types.util.dynamictable.checkConfig (line 65)
    assert(tableHeight == getVectorHeight(DynamicTable.id), ...

Error in types.core.TimeIntervals (line 45)
            types.util.dynamictable.checkConfig(obj);

Operating System

Windows

Matlab Version

R2023a

Code of Conduct

lawrence-mbf commented 11 months ago

Hi @jc192015 did you base this code off of one of our tutorials? The validation for the shape of the TimeIntervals table assumes that all columns defined by colname are populated with the same number of rows as id is. This is the meat of the error itself.

If you wish to add all 213 rows you need to set them all at once or use addRow in a loop per row.

jc192015 commented 11 months ago

P {margin-top:0;margin-bottom:0;}

lawrence-mbf commented 11 months ago

Continued in #527