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]: No enforcement of untyped groups (electrodes table and bands table) #624

Open
2 tasks done
ehennestad opened this issue Nov 14, 2024 · 0 comments
Open
2 tasks done
Labels
category: bug errors in the code or code behavior priority: medium non-critical problem and/or affecting only a small set of NWB users topic: nwb-file relates to how an exported nwb file is structured

Comments

@ehennestad
Copy link
Collaborator

ehennestad commented Nov 14, 2024

What happened?

MatNWB does not check if electrodes dynamic tables or band dynamic tables have the required datasets included according to how they are defined in the nwb schemas.

The following code should produce errors because the names of columns (colnames) in the dynamic table does not match the schema definition, but the code runs fine and the electrodes table can be exported to an NWB file without problem

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


numShanks = 4;
numChannelsPerShank = 3;

ElectrodesDynamicTable = types.hdmf_common.DynamicTable(...
    'colnames', {'x_location', 'x_group', 'x_group_name', 'x_label'}, ...
    'description', 'all electrodes');

Device = types.core.Device(...
    'description', 'the best array', ...
    'manufacturer', 'Probe Company 9000' ...
);
nwb.general_devices.set('array', Device);
for iShank = 1:numShanks
    shankGroupName = sprintf('shank%d', iShank);
    EGroup = types.core.ElectrodeGroup( ...
        'description', sprintf('electrode group for %s', shankGroupName), ...
        'location', 'brain area', ...
        'device', types.untyped.SoftLink(Device) ...
    );
    
    nwb.general_extracellular_ephys.set(shankGroupName, EGroup);
    for iElectrode = 1:numChannelsPerShank
        ElectrodesDynamicTable.addRow( ...
            'x_location', 'unknown', ...
            'x_group', types.untyped.ObjectView(EGroup), ...
            'x_group_name', shankGroupName, ...
            'x_label', sprintf('%s-electrode%d', shankGroupName, iElectrode));
    end
end

nwb.general_extracellular_ephys_electrodes = ElectrodesDynamicTable;

nwbExport(nwb, 'ecephys_tutorial.nwb')

Error Message

No response

Operating System

macOS

Matlab Version

R2023b

Code of Conduct

@ehennestad ehennestad added category: bug errors in the code or code behavior priority: medium non-critical problem and/or affecting only a small set of NWB users topic: nwb-file relates to how an exported nwb file is structured labels Nov 16, 2024
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 priority: medium non-critical problem and/or affecting only a small set of NWB users topic: nwb-file relates to how an exported nwb file is structured
Projects
None yet
Development

No branches or pull requests

1 participant