bids-standard / pybids-refactor

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

Error finding meta-data with hierarchy rule #28

Open adelavega opened 1 year ago

adelavega commented 1 year ago

In test test_get_tr

The following occurs:

E           KeyError: "Metadata term 'RepetitionTime' unavailable for file /home/zorro/repos/pybids/bids/tests/data/7t_trt/sub-01/ses-1/func/sub-01_ses-1_task-rest_acq-prefrontal_bold.nii.gz."

The meta-data for this file is at the bids root under: task-rest_acq-prefrontal_bold.json.

@erdalkaraca any insight?

adelavega commented 1 year ago
dataset = load_dataset('bids/tests/data/7t_trt/')
result = query(dataset, 'object', suffix='bold', subject='01')
result[0].get_metadata()
>> {}

The file that fails has the following entities:

{'sub': '01', 'ses': '2', 'task': 'rest', 'acq': 'prefrontal'}

Whereas acq = fullbrain does return meta-data.

The difference being there is a single meta-data file for both run 1 and 2 in the fullbrain scenario.

erdalkaraca commented 1 year ago

I think the BIDSMetadata should wrap the metadata returned by its _artifact:

    def get_metadata(self):
        """Return all metadata associated with the current file. """
        md_file = BIDSMetadata(self.path)
        md = self._artifact.get_metadata(include_entities=True)
        md_file.update(md)
        return md_file
adelavega commented 1 year ago

I don't think that's the issue here, it seems like a bug with how ancpbids is implementing the inheritance principle.