INT-NIT / BEP032tools

Software tools supporting the BIDS Extension Proposal (BEP) dedicated to adding support for electrophysiological data recorded in animal models (BEP032)
MIT License
3 stars 9 forks source link

Use pybids for filename generation #111

Open Remi-Gau opened 2 years ago

Remi-Gau commented 2 years ago

Could be done this way and should be able to handle optional entities.

from bids import BIDSLayout

config_file = "config_pybids.json"
target_dir = "."
layout = BIDSLayout(target_dir, validate=False, config=config_file)

entities = {
    "subject": "01",
    "session": "1",
    "sample": "A",
    "run": 1,
    "task": "nox",
    "suffix": "ephys",
}

# Define the pattern to build out of the components passed in a dictionary
pattern = "sub-{subject}/[ses-{session}]/sub-{subject}[_ses-{session}]_sample-{sample}_task-{task}[_run-{run}]_{suffix}.nwb"

layout.build_path(entities, pattern, validate=False)
dumaatravaie commented 2 years ago

Looks good ..

Remi-Gau commented 2 years ago

FYI I am using a modified config for pybids that should start providing some support for ephys and microscopy data (it is not complete yet).

https://gin.g-node.org/RemiGau/example_ephys_bids_conversion/src/master/code/config_pybids.json