Workflows

Snakebids workflows are constructed the same way as any other Snakemake workflows, but with a few additions that make it easier to work with BIDS datasets.

To get access to these additions, the base Snakefile for a snakebids workflow should begin with the following boilerplate:

import snakebids
from snakebids import bids

configfile: 'config/snakebids.yml'

#writes inputs_config.yml and updates config dict
config = snakebids.generate_inputs_config(config)

#this adds constraints to the bids naming
wildcard_constraints:  **snakebids.get_wildcard_constraints(config)

Snakebids workflow features

The bids() function generates a properly-formatted BIDS filename with the specified entities, as documented in more detail elsewhere in this documentation.

The "input_path" member of the config dictionary is generated by snakebids and contains a list of matched files for every input type. Often, the first rule to be invoked will use one or more entries in config["input_path"] as the input file specification.

The "input_zip_lists" member of the config dictionary is used with the bids function to fill the wildcards with corresponding values from input files. The usage pattern is as follows:

expand(
    bids(
        root="results",
        datatype="func",
        suffix="bold.nii.gz",
        acq={acq},
        task={task},
        run={run},
        **config["subj_wildcards"]
    ),
    zip,
    **config["input_zip_lists"]["bold"]
)

The "input_wildcards" member of the config dictionary is generated by snakebids and contains a dictionary mapping the wildcards for each input type to snakemake-formatted wildcards, for convenient use in the bids function.