Closed ageorgou closed 4 years ago
Spoke too soon - the pynwb docs say that a list of optical channels is allowed.
Whatever the initial intention, this is being addressed so we won't need to change anything on our side. The latest matnwb commits support multiple channels per imaging plane, and the schema itself will be changed in NeurodataWithoutBorders/nwb-schema#395. Closing!
It turns out that I had misunderstood, and matnwb still doesn't read files with two optical channels in the same imaging plane. The reason is quite complex, however, and we can't do anything about it right now:
The schema supplied with matnwb can be updated as desired. However, when reading an NWB file, it uses the namespaces stored inside it, overwriting the originally-supplied schema. These come from pynwb, and they still contain the old version of the schema (even though pynwb allows multiple channels!). It is possible to avoid storing the files when writing, or avoid reading them in matnwb, but then this causes other errors because the various namespaces are out of sync.
For now, I think we should stick with the workaround of creating separate planes for each optical channel, and keep this issue open. @alessandrofelder has a version of the code reverted to multiple channels per plane on the branchfix-optical-channels
. When things are ready in pynwb and nwb-schema, we can apply that again.
pynwb and matnwb should now support multiple channels per imaging plane (NeurodataWithoutBorders/pynwb#1146, NeurodataWithoutBorders/matnwb#188), but not verified yet.
Related to #6, but it seems this was always an error (in NWB2, at least)!
When adding an imaging plane, we create one or two associated optical channels, for green and/or red, according to what data is available. However, the schema for the imaging plane makes it look like there should only be one channel.
pynwb
doesn't warn about this, but the MATLAB API gives an error and fails to load the file, which is how we started suspecting this was wrong.We can work around this by creating different imaging planes e.g. "Zstack_0027_red" and "Zstack_0027_green", which also involves various other changes throughout the code.
May be worth double-checking that this is indeed an error, and possibly adding a relevant test in
pynwb
.