pybids
pybids copied to clipboard
Entities above dataset root are extracted
If I have a dataset whose name is (for reasons I can get into): .../sub-03/sourcedata/
, then all files inside that dataset will be responsive to a request for sub-03
, even if the file is .../sub-03/sourcedata/sub-01/anat/sub-01_T1.nii.gz
.
We should not be matching on anything but the relative path within the dataset.
I am looking into a way to fix that.
One option would be to store both the absolute path and the path relative to layout root in the BIDS*File
objects, and use the relative path for entities matching.
The other option would be to have a pointer to the layout in each of the BIDS*File object, and use self.layout.root to get relpath.
The changes would be in bids.models.BIDSFile.__init__
and in both bids.layout.parse_file_entities
and bids.index.BIDSLayoutIndexer._index_file
?
I would suggest that we maintain the root and root-relative path, rather than just path
. In almost all cases, internally we'll want to work with the root-relative path, and only expose the full path to the user at output.
That would break old databases, though, if people have saved their layouts to sqlite.
So if I understand, the database would store root-relative path, and when layout is loaded, the given root would be prepend to the path of the query results. As a plus, BIDS folder bound to a container at varying path would be able to use the pre-indexed layout making them faster. I would also make possible to share the sqlite files (eg. in a datalad in a predefined path like .pybids_layout/
).