Incorrect metadata may be returned in non-compliant datasets that have two valid sidecars for a single target in the same directory
See original GitHub issuepybids version: 0.9.4
I have corresponding jsons and niftis in a BIDS folder from heudiconv, but nifti.get_metadata often returns a value that is the opposite of what the json contains.
In [54]: json.get_dict()['PhaseEncodingDirection']
Out[54]: 'j'
In [55]: nii.get_metadata()['PhaseEncodingDirection']
Out[55]: 'j-'
I know this was a problem discussed in https://github.com/bids-standard/pybids/issues/40 but there are not much information about what was the problem and how it was fixed. The fact that the whole BIDS folder get scanned at the beginning and is mashed up in SQLAlchemy, which is very obscure for me, makes it very difficult to debug.
Is there a simple explanation of how things are loaded in pybids from jsons/filenames… ? What takes precedence? And how this kind of gross mismatch can occur?
Many BIDS-Apps rely on pybids to load parameters for preprocessing, and this could cause huge problems.
Thanks a lot.
Issue Analytics
- State:
- Created 4 years ago
- Comments:15
task-
is non-optional for sbref: https://bids-specification.readthedocs.io/en/stable/04-modality-specific-files/01-magnetic-resonance-imaging-data.html#task-including-resting-state-imaging-dataI meant directory. If a given file has 5 defined entities, then the natural place to look for a sidecar first is a JSON file that has exactly the same name other than the extension (i.e., it shares the same 5 entities). But if the exact matching sidecar is missing, and there’s another valid JSON file that shares 4 of the same defined entities (and values) as the target file (and has no unique ones itself), then the assumption is that that’s the sidecar to use for the target. What the rule precludes is having multiple sidecar files in the same directory whose entities either perfectly match the target file’s entities, or form a strict subset.