Skip to content

Set session and subject metadata through the NWB2 options of the Record Node - #2

Merged
oruebel merged 2 commits into
batch-writesfrom
engine-metadata
Nov 20, 2026
Merged

oruebel merged 2 commits into
batch-writesfrom
engine-metadata

Conversation

@oruebel

@oruebel oruebel commented Nov 10, 2026

Copy link
Copy Markdown

Context

This PR builds on open-ephys-plugins#6 and the batch-writes PR (#1). It addresses open-ephys-plugins#7.

GUI development applies record engine parameters per Record Node (open-ephys/plugin-GUI#710, 3c513e8). They appear in the options behind the gear button next to the recording-format selector, are saved with the signal chain, and are exposed in the HTTP API as engine_<engine ID>_<parameter ID>.

Changes

  • New NWB2 engine parameters (strings), after the existing Identifier Text (ID 0):

    ID Option NWB field
    1 Session description /session_description
    2 Experimenter(s), separated by ; /general/experimenter
    3 Institution /general/institution
    4 Lab /general/lab
    5-13 Subject ID, species, sex, age, date of birth, genotype, strain, weight, description /general/subject/*
    14 Metadata file (JSON) (the file below)
  • Metadata file: option 14 sets the path of the JSON metadata file (NeuroConv structure, as in Write NWB 2.11 files with AqNWB and read NWB files with AqNWB in the NWB File Source open-ephys-plugins/nwb-format#6). If it's empty, the plugin keeps looking for nwb_metadata.json next to the recording, as before. The file provides fields that have no option (e.g., keywords, protocol, surgery) and works with GUI v1.1.0, which doesn't apply the options.

  • Precedence: options that are set override the values in the metadata file; empty options don't.

  • Date of birth: AqNWB only writes date_of_birth with time and time zone (e.g., 2026-01-15T00:00:00Z) and reports other values on stderr only. The plugin now logs an error with the required format in the GUI log and leaves the field out. The README gives the format too.

  • The plugin logs a warning when an NWB file is created without the subject fields that DANDI requires (subject ID, species, sex, and age or date of birth).

  • README: the options come first, with a screenshot of the dialog, and their HTTP API names; then the metadata file. The options and the file are applied when an NWB file is created (at the first recording of each experiment). The gui-docs page is updated separately.

Testing

On GUI development (e6008f0), macOS, with the options set through PUT /api/processors/101/parameters/engine_NWB2_<id>:

  • Options only: the values are written. PyNWB reads the session description, experimenters (split at ;), institution, lab and subject, and the NWB Inspector's check_subject_exists passes.
  • nwb_metadata.json only, options empty: the JSON values are written, unchanged from before.
  • Both: the options that are set override the JSON values (session description, subject ID, sex). The other JSON values are kept.
  • Neither: the default session description, no subject, and the warning in the log.
  • Metadata file option: the file it names is used instead of nwb_metadata.json in the recording directory, and the options that are set still override it. A missing file or a relative path logs an error, and no file metadata is written.
  • Date of birth: 2026-01-01T00:00:00Z is written. 2026-01-01 logs the error and is left out (and the subject is reported as incomplete).

The Record Node registers all 15 options (engine_NWB2_0-14 in GET /api/processors/101/parameters). The README shows the options dialog; all labels fit (I shortened the age and date-of-birth labels, which were truncated).

Question

Should the plugin keep the metadata file now that the GUI has the options? It covers fields without an option and GUI v1.1.0, but it's a convention of this plugin, not of Open Ephys. Longer term, an "advanced" flag or groups for engine parameters (a collapsible section in the options dialog) would allow exposing more fields without cluttering the GUI. That would need a change to the plugin API, so I've only added the file option here.

🤖 Generated with Claude Code

oruebel and others added 2 commits November 10, 2026 11:49
…rd Node

Add record engine parameters (IDs 1-13; ID 0 remains the identifier) for
the session description, experimenter(s), institution, lab, and the
subject's ID, species, sex, age, date of birth, genotype, strain, weight
and description. GUI development (open-ephys/plugin-GUI#710, 3c513e8)
shows them in the Record Node's format options, saves them with the
signal chain and exposes them in the HTTP API (engine_NWB2_<id>).
Options that are set override the values in nwb_metadata.json; empty
options don't. Log a warning if the subject fields that DANDI requires
are missing when an NWB file is created.

Fixes open-ephys-plugins#7

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- New NWB2 option 14, "Metadata file (JSON)": the absolute path of the
  metadata file. If it is empty, nwb_metadata.json is searched next to the
  recording as before. A missing file or a relative path is logged as an error.
- AqNWB only writes date_of_birth as an ISO 8601 date and time with time zone
  and reports other values on stderr only. The plugin now logs an error in the
  GUI log and leaves the field out.
- Shorter age and date-of-birth labels, which didn't fit the options dialog.
- README: the options first, with a screenshot of the dialog, then the
  metadata file; both are applied when an NWB file is created.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant