Skip to content

Get annotation descriptions from the stim name when reading snirf files #9571

@dsleiter

Description

@dsleiter

Describe the new feature or enhancement

When loading a SNIRF file via mne.io.read_raw_snirf, the descriptions for Annotations are currently extracted from the keys of the SNIRF stim indexed groups. According to the SNIRF file format spec, what is currently being extracted as the Annotation description is the index of the stim rather than a descriptive string.

group: a structure containing sub-fields (defined in the H5G object class). Arrays of groups, also known as the indexed-groups, are denoted with numbers at the end (e.g. /nirs/data1, /nirs/data2) starting with index 1. Array indices should be contiguious with no skipped values (an empty group with no sub-member is permitted).

A better field to get a description from is the stimulus group name field which is described as:

This is a string describing the jth stimulus condition.

The proposed change is to get Annotation descriptions from the stimulus name rather than the index.

Describe your proposed implementation

Update RawSNIRF.__init__ lines 362:369 to take the description field from the name field of the stim group rather than the stim group key.

Describe possible alternatives

The descriptions can be left as-is. Although the match between an Annotation description and a SNIRF stimulus name isn't perfect, it seems like an improvement over using the stimulus index as-is.

If the description is not changed, then tests for the MNE-NIRS SNIRF writer will need to be changed (see Additional comments below).

Additional comments

This is related to mne-tools/mne-nirs#326, where the MNE-NIRS SNIRF writer is being updated to be more consistent with the SNIRF spec.

MNE-NIRS currently has tests which use the MNE-Python SNIRF reader to make a round trip write/read test. Resolving this issue will ensure that the annotation descriptions remain the same after a round trip.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions