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

[Bug]: Error when recreating a table from saved nwb file #668

Closed
2 tasks done
NeuroGuth opened this issue Feb 14, 2025 · 1 comment · Fixed by #669
Closed
2 tasks done

[Bug]: Error when recreating a table from saved nwb file #668

NeuroGuth opened this issue Feb 14, 2025 · 1 comment · Fixed by #669
Labels
category: bug errors in the code or code behavior topic: matnwb-api related to improving the matnwb api

Comments

@NeuroGuth
Copy link

What happened?

Hi,

I just followed the tutorial and then exported the nwb file. When I try to recreate the table from "nwb.general_extracellular_ephys_electrodes" I get the following error.

Best

Tim

Steps to Reproduce

>> nwb = NwbFile( ...
    'session_description', 'mouse in open exploration',...
    'identifier', 'Mouse5_Day3', ...
    'session_start_time', datetime(2018, 4, 25, 2, 30, 3, 'TimeZone', 'local'), ...
    'timestamps_reference_time', datetime(2018, 4, 25, 3, 0, 45, 'TimeZone', 'local'), ...
    'general_experimenter', 'Last Name, First Name', ... % optional
    'general_session_id', 'session_1234', ... % optional
    'general_institution', 'University of My Institution', ... % optional
    'general_related_publications', {'DOI:10.1016/j.neuron.2016.12.011'}); % optional
>> device = types.core.Device(...
    'description', 'A 12-channel array with 4 shanks and 3 channels per shank', ...
    'manufacturer', 'Array Technologies', ...
    'model_number', 'PRB_1_4_0480_123', ...
    'model_name', 'Neurovoxels 0.99', ...
    'serial_number', '1234567890' ...
);

% Add device to nwb object
nwb.general_devices.set('array', device);
>> numShanks = 4;
numChannelsPerShank = 3;
numChannels = numShanks * numChannelsPerShank;

electrodesDynamicTable = types.hdmf_common.DynamicTable(...
    'colnames', {'location', 'group', 'group_name', 'label'}, ...
    'description', 'all electrodes');

for iShank = 1:numShanks
    shankGroupName = sprintf('shank%d', iShank);
    electrodeGroup = types.core.ElectrodeGroup( ...
        'description', sprintf('electrode group for %s', shankGroupName), ...
        'location', 'brain area', ...
        'device', types.untyped.SoftLink(device) ...
    );
    
    nwb.general_extracellular_ephys.set(shankGroupName, electrodeGroup);
    for iElectrode = 1:numChannelsPerShank
        electrodesDynamicTable.addRow( ...
            'location', 'unknown', ...
            'group', types.untyped.ObjectView(electrodeGroup), ...
            'group_name', shankGroupName, ...
            'label', sprintf('%s-electrode%d', shankGroupName, iElectrode));
    end
end
electrodesDynamicTable.toTable() % Display the table

ans =

  12x5 table

    id     location                 group                group_name            label        
    __    ___________    ____________________________    __________    _____________________

     0    {'unknown'}    1x1 types.untyped.ObjectView    {'shank1'}    {'shank1-electrode1'}
     1    {'unknown'}    1x1 types.untyped.ObjectView    {'shank1'}    {'shank1-electrode2'}
     2    {'unknown'}    1x1 types.untyped.ObjectView    {'shank1'}    {'shank1-electrode3'}
     3    {'unknown'}    1x1 types.untyped.ObjectView    {'shank2'}    {'shank2-electrode1'}
     4    {'unknown'}    1x1 types.untyped.ObjectView    {'shank2'}    {'shank2-electrode2'}
     5    {'unknown'}    1x1 types.untyped.ObjectView    {'shank2'}    {'shank2-electrode3'}
     6    {'unknown'}    1x1 types.untyped.ObjectView    {'shank3'}    {'shank3-electrode1'}
     7    {'unknown'}    1x1 types.untyped.ObjectView    {'shank3'}    {'shank3-electrode2'}
     8    {'unknown'}    1x1 types.untyped.ObjectView    {'shank3'}    {'shank3-electrode3'}
     9    {'unknown'}    1x1 types.untyped.ObjectView    {'shank4'}    {'shank4-electrode1'}
    10    {'unknown'}    1x1 types.untyped.ObjectView    {'shank4'}    {'shank4-electrode2'}
    11    {'unknown'}    1x1 types.untyped.ObjectView    {'shank4'}    {'shank4-electrode3'}

>> nwb.general_extracellular_ephys_electrodes = electrodesDynamicTable;
>> nwbExport(nwb, 'test.nwb');
Warning: Namespace is missing:
  core
  hdmf-common 
> In io.spec.validateEmbeddedSpecifications>checkMissingNamespaces (line 33)
In io.spec.validateEmbeddedSpecifications (line 18)
In NwbFile/embedSpecifications (line 174)
In NwbFile/export (line 77)
In nwbExport (line 52) 
>> test = nwbRead('test.nwb');
>> test.general_extracellular_ephys_electrodes.toTable
Error using horzcat
Dimensions of arrays being concatenated are not consistent.

Error in types.util.dynamictable.nwbToTable (line 89)
matlabTable = matlabTable(:, [{'id'}, columns]);
                              ^^^^^^
Error in types.hdmf_common.DynamicTable/toTable (line 145)
        table = types.util.dynamictable.nwbToTable(obj, varargin{:});
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
>>

Error Message

Error using horzcat
Dimensions of arrays being concatenated are not consistent.

Error in types.util.dynamictable.nwbToTable (line 89)
matlabTable = matlabTable(:, [{'id'}, columns]);
                              ^^^^^^
Error in types.hdmf_common.DynamicTable/toTable (line 145)
        table = types.util.dynamictable.nwbToTable(obj, varargin{:});
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Operating System

Windows

Matlab Version

'24.2.0.2871072 (R2024b) Update 5'

Code of Conduct

@ehennestad ehennestad added category: bug errors in the code or code behavior topic: matnwb-api related to improving the matnwb api labels Feb 15, 2025
@ehennestad
Copy link
Collaborator

Thanks for reporting this, it should be fixed now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug errors in the code or code behavior topic: matnwb-api related to improving the matnwb api
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants