NeurodataWithoutBorders / matnwb

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

[Bug]: NWBFile.stimulus_templates should accept Images type #494

Closed rly closed 1 year ago

rly commented 1 year ago

What happened?

NWB schema 2.6.0 allows both TimeSeries and Images to be added to the /stimulus_templates group of an NWB file. https://github.com/NeurodataWithoutBorders/nwb-schema/blob/19c4bbb36effb1454253072f70ebf2c83f2ea095/core/nwb.file.yaml#L134-L145

However, when an Images object is added, validation fails. This is because the generated code in matnwb/+types/+core/NWBFile.m says:

    function val = validate_stimulus_templates(obj, val)
        constrained = {'types.core.TimeSeries'};
        types.util.checkSet('stimulus_templates', struct(), constrained, val);
    end

Image of a stack trace from the user image1

Similarly, the /acquisition, /analysis, and /scratch groups all allow multiple data types. The generated validator code does not seem to allow for that, but it should.

Steps to Reproduce

nwb = NwbFile( ...
    'session_description', 'mouse in open exploration',...
    'identifier', ['Mouse5_Day3'], ...
    'session_start_time', datetime(2018, 4, 25, 2, 30, 3));
nwb.stimulus_templates.set("Test", types.core.Images());

Error Message

see above

Operating System

macOS

Matlab Version

unknown

Code of Conduct