Skip to content

Conversation

@neuromechanist
Copy link
Member

@neuromechanist neuromechanist commented Dec 8, 2025

Summary

Fix multiple validation errors for EMG coordsystem and electrode files.

Changes

1. Fix SIDECAR_WITHOUT_DATAFILE for coordsystem files (errors.yaml)

Changed selector from:

- suffix != "coordsystem" || modality != "emg"

To:

- suffix != "coordsystem"

Reason: Coordsystem files can be shared via the inheritance principle and may not have direct data files. This applies to all modalities, not just EMG. The simpler selector excludes all coordsystem files from this check. Also, it seems that when in root, the error comes up before modality is checked, therefore, the error is being raised.

2. Allow root-level EMG coordsystem files (channels.yaml)

  • Added subject: optional to coordsystem__emg rule
  • Added new coordsystem__emg_root rule with datatypes: [] for root-level placement

Reason: EMG datasets can place coordsystem files at root level (no subject entity) to share coordinate system definitions across all subjects via inheritance.

3. Conditional uniqueness for EMG electrodes (emg.yaml)

Split EMGElectrodes into two rules:

  • EMGElectrodes: When no group column exists, electrode name must be unique
  • EMGElectrodes__grouped: When group column exists, the combination of (name, group) must be unique

Uses selectors !columns.group and columns.group to determine which rule applies.

Reason: EMG datasets with bilateral recordings (left/right arm) may have the same electrode names (e.g., E0-E15) repeated across different groups. The uniqueness constraint should be conditional on whether grouping is used.

4. Update test for optional subject (test_render_text.py)

Added handling for patterns with optional subject entity in filename template rendering test.

Reason: Subject is required for coordsystem files in other modalities (EEG, MEG, NIRS, iEEG), but optional for EMG to allow root-level placement. When the schema renders filename templates, the output shows [sub-<label>] for optional subject patterns. The test parses this rendered text without modality context, so it cannot distinguish EMG patterns from other modalities. We skip [sub-<label>] patterns in the test since they represent valid EMG coordsystem files.

Valid coordsystem patterns now supported

  • space-leftForearm_coordsystem.json (root level, with space entity)
  • sub-01/emg/sub-01_coordsystem.json (subject level)
  • sub-01/emg/sub-01_space-hand_coordsystem.json (subject level with space)

Related

  • Affects emg_TwoWristbands and emg_MultiBodyParts examples in bids-examples

@neuromechanist neuromechanist changed the title Fix SIDECAR_WITHOUT_DATAFILE for EMG coordsystem files Fix multiple validation errors for EMG coordsystem and electrode files Dec 8, 2025
@neuromechanist neuromechanist added bug Something isn't working EMG labels Dec 8, 2025
@neuromechanist neuromechanist force-pushed the fix-emg-coordsystem-validation branch 5 times, most recently from 6148cc8 to 74f819b Compare December 9, 2025 01:10
- Exclude coordsystem files from SIDECAR_WITHOUT_DATAFILE error
- Add subject: optional to coordsystem__emg for root-level placement
- Add coordsystem__emg_root rule for root-level files
- Add conditional uniqueness for EMG electrodes based on group column
- Update test for optional subject patterns
@neuromechanist neuromechanist force-pushed the fix-emg-coordsystem-validation branch from efde93f to 37f5f38 Compare December 9, 2025 01:22
@neuromechanist
Copy link
Member Author

@drammock, @effigies,

While testing EMG datasets on NEMAR (like nm000104, and nm000105), I noticed a couple of issues. I tested the validation using the latest pull,
deno run -A jsr:@bids/validator --schema https://bids-specification.readthedocs.io/en/latest/schema.json path/to/dataset (see the issues above)

These fixes seem to eliminate the issues, you can double check via:
deno run -A jsr:@bids/validator --schema https://bids-specification--2279.org.readthedocs.build/en/2279/schema.json path/to/dataset with the latest push to the datasets (they can be all cloned using datalad)

@drammock
Copy link
Contributor

drammock commented Dec 9, 2025

it looks like you're using the current stable version of the validator (deno run -A jsr:@bids/validator). If I run current main version of the validator (/path/to/bids/validator/local-run) then I don't get errors, only warnings.

Here's my output for nm000104:

Details
$ /opt/bids/validator/local-run --schema https://bids-specification.readthedocs.io/en/latest/schema.json nm000104/

	[WARNING] UNKNOWN_BIDS_VERSION The BIDSVersion field of 'dataset_description.json' does not match a known release.
The BIDS Schema used for validation may be out of date.

		/dataset_description.json

	Please visit https://neurostars.org/search?q=UNKNOWN_BIDS_VERSION for existing conversations about this issue.

	[WARNING] JSON_KEY_RECOMMENDED A JSON file is missing a key listed as recommended.
		SourceDatasets
		/dataset_description.json - Field description: Used to specify the locations and relevant attributes of all source datasets (BIDS or not).
Valid keys in each object include `"URL"`, `"DOI"` (see
[URI](SPEC_ROOT/common-principles.md#uniform-resource-indicator)), and
`"Version"` with
[string](https://www.w3schools.com/js/js_json_datatypes.asp)
values.


	Please visit https://neurostars.org/search?q=JSON_KEY_RECOMMENDED for existing conversations about this issue.

	[WARNING] SIDECAR_KEY_RECOMMENDED A data file's JSON sidecar is missing a key listed as recommended.
		Description
		/participants.tsv - Field description: Free-form natural language description.

		/sub-46697259/ses-1608223848/emg/sub-46697259_ses-1608223848_task-typing_channels.tsv - Field description: Free-form natural language description.


		4539 more files with the same issue

		SoftwareVersions
		/sub-46697259/ses-1608223848/emg/sub-46697259_ses-1608223848_task-typing_emg.bdf - Field description: Manufacturer's designation of software version of the equipment that produced
the measurements.

		/sub-46697259/ses-1608174768/emg/sub-46697259_ses-1608174768_task-typing_emg.bdf - Field description: Manufacturer's designation of software version of the equipment that produced
the measurements.


		1133 more files with the same issue

		DeviceSerialNumber
		/sub-46697259/ses-1608223848/emg/sub-46697259_ses-1608223848_task-typing_emg.bdf - Field description: The serial number of the equipment that produced the measurements.
A pseudonym can also be used to prevent the equipment from being
identifiable, so long as each pseudonym is unique within the dataset.

		/sub-46697259/ses-1608174768/emg/sub-46697259_ses-1608174768_task-typing_emg.bdf - Field description: The serial number of the equipment that produced the measurements.
A pseudonym can also be used to prevent the equipment from being
identifiable, so long as each pseudonym is unique within the dataset.


		1133 more files with the same issue

		ElectrodeManufacturer
		/sub-46697259/ses-1608223848/emg/sub-46697259_ses-1608223848_task-typing_emg.bdf - Field description: Can be used if all electrodes are of the same manufacturer
(for example, `"AD-TECH"`, `"DIXI"`).
If electrodes of different manufacturers are used,
please use the corresponding table in the `_electrodes.tsv` file.

		/sub-46697259/ses-1608174768/emg/sub-46697259_ses-1608174768_task-typing_emg.bdf - Field description: Can be used if all electrodes are of the same manufacturer
(for example, `"AD-TECH"`, `"DIXI"`).
If electrodes of different manufacturers are used,
please use the corresponding table in the `_electrodes.tsv` file.


		1133 more files with the same issue

		ElectrodeManufacturersModelName
		/sub-46697259/ses-1608223848/emg/sub-46697259_ses-1608223848_task-typing_emg.bdf - Field description: If different electrode types are used,
please use the corresponding table in the `_electrodes.tsv` file.

		/sub-46697259/ses-1608174768/emg/sub-46697259_ses-1608174768_task-typing_emg.bdf - Field description: If different electrode types are used,
please use the corresponding table in the `_electrodes.tsv` file.


		1133 more files with the same issue

		Instructions
		/sub-46697259/ses-1608223848/emg/sub-46697259_ses-1608223848_task-typing_emg.bdf - Field description: Text of the instructions given to participants before the recording.

		/sub-46697259/ses-1608174768/emg/sub-46697259_ses-1608174768_task-typing_emg.bdf - Field description: Text of the instructions given to participants before the recording.


		1133 more files with the same issue

		InstitutionalDepartmentName
		/sub-46697259/ses-1608223848/emg/sub-46697259_ses-1608223848_task-typing_emg.bdf - Field description: The department in the institution in charge of the equipment that produced
the measurements.

		/sub-46697259/ses-1608174768/emg/sub-46697259_ses-1608174768_task-typing_emg.bdf - Field description: The department in the institution in charge of the equipment that produced
the measurements.


		1133 more files with the same issue

		StimulusPresentation
		/sub-46697259/ses-1608223848/emg/sub-46697259_ses-1608223848_task-typing_events.tsv - Field description: Object containing key-value pairs related to the software used to present
the stimuli during the experiment.

		/sub-46697259/ses-1608174768/emg/sub-46697259_ses-1608174768_task-typing_events.tsv - Field description: Object containing key-value pairs related to the software used to present
the stimuli during the experiment.


		1133 more files with the same issue

	Please visit https://neurostars.org/search?q=SIDECAR_KEY_RECOMMENDED for existing conversations about this issue.


          Summary:                              Available Tasks:        Available Modalities:
          5682 Files, 242 MB                    typing                  emg                  
          108 - Subjects 1135 - Sessions                                                     

	If you have any questions, please post on https://neurostars.org/tags/bids.

Here's my output for nm000105:

Details
$ /opt/bids/validator/local-run --schema https://bids-specification.readthedocs.io/en/latest/schema.json nm000105/

	[WARNING] UNKNOWN_BIDS_VERSION The BIDSVersion field of 'dataset_description.json' does not match a known release.
The BIDS Schema used for validation may be out of date.

		/dataset_description.json

	Please visit https://neurostars.org/search?q=UNKNOWN_BIDS_VERSION for existing conversations about this issue.

	[WARNING] JSON_KEY_RECOMMENDED A JSON file is missing a key listed as recommended.
		SourceDatasets
		/dataset_description.json - Field description: Used to specify the locations and relevant attributes of all source datasets (BIDS or not).
Valid keys in each object include `"URL"`, `"DOI"` (see
[URI](SPEC_ROOT/common-principles.md#uniform-resource-indicator)), and
`"Version"` with
[string](https://www.w3schools.com/js/js_json_datatypes.asp)
values.


	Please visit https://neurostars.org/search?q=JSON_KEY_RECOMMENDED for existing conversations about this issue.

	[WARNING] SIDECAR_KEY_RECOMMENDED A data file's JSON sidecar is missing a key listed as recommended.
		Description
		/participants.tsv - Field description: Free-form natural language description.

		/sub-011/ses-000/emg/sub-011_ses-000_task-discretegestures_emg.bdf - Field description: Free-form natural language description.


		399 more files with the same issue

		ElectrodeManufacturer
		/sub-011/ses-000/emg/sub-011_ses-000_task-discretegestures_emg.bdf - Field description: Can be used if all electrodes are of the same manufacturer
(for example, `"AD-TECH"`, `"DIXI"`).
If electrodes of different manufacturers are used,
please use the corresponding table in the `_electrodes.tsv` file.

		/sub-066/ses-000/emg/sub-066_ses-000_task-discretegestures_emg.bdf - Field description: Can be used if all electrodes are of the same manufacturer
(for example, `"AD-TECH"`, `"DIXI"`).
If electrodes of different manufacturers are used,
please use the corresponding table in the `_electrodes.tsv` file.


		98 more files with the same issue

		ElectrodeManufacturersModelName
		/sub-011/ses-000/emg/sub-011_ses-000_task-discretegestures_emg.bdf - Field description: If different electrode types are used,
please use the corresponding table in the `_electrodes.tsv` file.

		/sub-066/ses-000/emg/sub-066_ses-000_task-discretegestures_emg.bdf - Field description: If different electrode types are used,
please use the corresponding table in the `_electrodes.tsv` file.


		98 more files with the same issue

		StimulusPresentation
		/sub-011/ses-000/emg/sub-011_ses-000_task-discretegestures_events.tsv - Field description: Object containing key-value pairs related to the software used to present
the stimuli during the experiment.

		/sub-066/ses-000/emg/sub-066_ses-000_task-discretegestures_events.tsv - Field description: Object containing key-value pairs related to the software used to present
the stimuli during the experiment.


		98 more files with the same issue

	Please visit https://neurostars.org/search?q=SIDECAR_KEY_RECOMMENDED for existing conversations about this issue.


          Summary:                           Available Tasks:        Available Modalities:
          506 Files, 5.39 MB                 discretegestures        emg                  
          100 - Subjects 1 - Sessions                                                     

	If you have any questions, please post on https://neurostars.org/tags/bids.

@drammock
Copy link
Contributor

drammock commented Dec 9, 2025

  1. Fix SIDECAR_WITHOUT_DATAFILE for coordsystem files
  2. Allow root-level EMG coordsystem files
  3. Conditional uniqueness for EMG electrodes
  4. Update test for optional subject

I think all of these were addressed in bids-standard/bids-validator#268

The fact that e.g., EMGTwoWristbands already has a root-level coordsys.json, and all CIs passed on bids-standard/bids-examples#480, indicates that these issues were already addressed. Also, emg_TwoHDsEMG dataset tests the non-uniqueness of electrode names across groups case, and some of the other datasets like emg_CustomBipolarFace don't have group at all and they still validate fine on main

Copy link
Collaborator

@effigies effigies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @drammock. @neuromechanist I think you may have needed to reload your validator with deno cache --reload jsr:@bids/validator. (You can also add --reload to your deno run command.)

- extension == ".json"
- suffix != "coordsystem" || modality != "emg"
#EMG allows multiple coordsys files per data file (distinguished via `space` entity)
- suffix != "coordsystem"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably correct, but these selectors are not actually used by the validator. The SIDECAR_WITHOUT_DATAFILE error is a separate check after walking the whole dataset, so the context isn't available for selecting, at least in the JS implementation.

- emg
entities:
$ref: rules.files.raw.channels.coordsystem__eeg.entities
subject: optional
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subject is always optional for TSV or JSON files, due to the inheritance principle.

Comment on lines +39 to +53
initial_columns:
- name__electrodes
- x
- y
columns:
name__electrodes: required
x: required
y: required
z: optional
coordinate_system: recommended
type__electrodes: recommended
material: recommended
impedance: recommended
group__emg: recommended
index_columns: [name__electrodes]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional index and initial columns were implemented in bids-standard/bids-validator#243.

@neuromechanist
Copy link
Member Author

Thanks very much, @drammock and @effigies. Yes, I was ignorant to the fact that the fixes may not have been released on the validator either 🙈.

I'll close this, as all have been already addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working EMG

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants