bids-standard / pybids

Python tools for querying and manipulating BIDS datasets.
https://bids-standard.github.io/pybids/
MIT License
225 stars 122 forks source link

Inherited metadata overrides immediate metadata for multi-echo data with same-named single-echo #1044

Open tsalo opened 9 months ago

tsalo commented 9 months ago

I have a unique case stemming from a modified version of ds002156. I basically took the first echo from a multi-echo run and removed the echo entity to simulate a single-echo run.

sub-23638_ses-03_task-rest_run-1_bold.json
sub-23638_ses-03_task-rest_run-1_bold.nii.gz
sub-23638_ses-03_task-rest_run-1_echo-1_bold.json
sub-23638_ses-03_task-rest_run-1_echo-1_bold.nii.gz
sub-23638_ses-03_task-rest_run-1_echo-2_bold.json
sub-23638_ses-03_task-rest_run-1_echo-2_bold.nii.gz
sub-23638_ses-03_task-rest_run-1_echo-3_bold.json
sub-23638_ses-03_task-rest_run-1_echo-3_bold.nii.gz
sub-23638_ses-03_task-rest_run-1_echo-4_bold.json
sub-23638_ses-03_task-rest_run-1_echo-4_bold.nii.gz

If I do layout.get_metadata("/path/to/dset/sub-23638/ses-03/sub-23638_ses-03_task-rest_run-1_echo-2_bold.nii.gz"), I get 0.015 for the EchoTime, even though the second echo's EchoTime is 0.0286.

I can reproduce this by modifying the synthetic test dataset.

While it's a rare case, and dataset curators should 100% use an acq entity to distinguish multi-echo and single-echo runs, AFAIK this organization doesn't violate BIDS rules.

effigies commented 2 weeks ago

Ugh. I was going to quickly fix this, but the implementation of the inheritance principle is wildly complicated, and definitely not conformant with the spec...