khanlab / khanlab/snakebids

ConfigError: Multiple path templates for 't1w' component using generate_inputs

Open
#469 13 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
23
Forks
16
PR merge metrics
No merged PRs in 30d

Description

Description:

Hi,

I'm trying to use generate_inputs() to load my BIDS data with the following code:

```
inputs = generate_inputs(
bids_dir=bids_dir,
pybids_inputs=config["pybids_inputs"],
validate=False,
)
```
Here is the relevant portion of my config:

```
pybids_inputs:
t1w:
filters:
suffix: "T1w"
extension: ".nii.gz"
datatype: "anat"
invalid_filters: "allow"
wildcards:
- subject
- session
- acquisition
- run
- desc
- part
- mt
```
However, I encountered the following error when running snakemake -np:
```
ConfigError in file /home/bic/eyang/Documents/workflows/pipelines/ironfist/Snakefile, line 44:
Multiple path templates for one component. Use --filter_t1w to narrow your search or --wildcards_t1w to make the template more generic.
component = 't1w'
path_templates = [
'/data_/mica3/BIDS_brainscores/rawdata/sub-{subject}/ses-{session}/anat/sub-{subject}_ses-{session}_acq-{acq}_run-{run}_T1w.nii.gz',
'/data_/mica3/BIDS_brainscores/rawdata/sub-{subject}/ses-{session}/anat/sub-{subject}_ses-{session}_acq-{acq}_T1w.nii.gz',
'/data_/mica3/BIDS_brainscores/rawdata/sub-{subject}/anat/sub-{subject}_T1w.nii.gz',
'/data_/mica3/BIDS_brainscores/rawdata/sub-{subject}/ses-{session}/anat/sub-{subject}_ses-{session}_acq-{acq}_part-{part}_T1w.nii.gz'
]
```
Environment:

```
$ conda list snakebids
# Name Version
snakebids 0.14.0
```
Directory structure:

```
├── bids_validator_output.txt
├── CITATION.cff
├── dataset_description.json
├── participants_7t2bids.tsv
├── participants.json
├── participants.tsv
├── README
├── sub-10058
│   └── anat
│   ├── sub-10058_desc-iron.nii.gz
│   ├── sub-10058_desc-MTR.nii.gz
│   └── sub-10058_T1w.nii.gz
├── sub-mpn20250310
│   ├── ses-v1
│   │   ├── anat
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_mt-off_MTR.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_mt-off_MTR.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_mt-off_part-phase_MTR.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_mt-off_part-phase_MTR.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_mt-on_MTR.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_mt-on_MTR.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_mt-on_part-phase_MTR.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_mt-on_part-phase_MTR.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_part-phase_T1w.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_part-phase_T1w.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_T1w.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-mtw_T1w.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-neuromelaninMTw_run-1_T1w.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-neuromelaninMTw_run-1_T1w.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-neuromelaninMTw_run-2_T1w.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-neuromelaninMTw_run-2_T1w.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-neuromelaninMTw_run-3_T1w.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-neuromelaninMTw_run-3_T1w.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-neuromelaninMTw_run-4_T1w.json
│   │   │   └── sub-mpn20250310_ses-v1_acq-neuromelaninMTw_run-4_T1w.nii.gz
│   │   ├── dwi
│   │   ├── fmap
│   │   │   ├── sub-mpn20250310_ses-v1_acq-anat_TB1TFL.json
│   │   │   ├── sub-mpn20250310_ses-v1_acq-anat_TB1TFL.nii.gz
│   │   │   ├── sub-mpn20250310_ses-v1_acq-sfam_TB1TFL.json
│   │   │   └── sub-mpn20250310_ses-v1_acq-sfam_TB1TFL.nii.gz
│   │   └── func
│   └── sub-mpn20250310_sessions.tsv
└── sub-mx250204
└── anat
├── sub-mx250204_FLAIR.nii.gz
└── sub-mx250204_T1w.nii.gz
```
Question:

Given the file heterogeneity, what is the correct way to specify filters or wildcards to avoid this Multiple path templates error for t1w? Is there a best practice to handle mixed file patterns like this?

Thanks in advance!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the generate_inputs configuration and Snakefile line 44, using the reported Snakebids 0.14.0 behavior as the reproduction case. Compare how the listed filters and wildcards produce the four T1w path templates across the mixed BIDS files. Done means the supported configuration or its limitation is clearly established and the multiple-template error has a documented resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.