Load a BIDS Dataset

Load a BIDS Dataset#

With ancpBIDS you don’t really load your dataset, but to make it available to ancpBIDS to create an in-memory graph. There are several ways to load a BIDS dataset just using a dataset path.

Basic Loading#

from ancpbids.pybids_compat import BIDSLayout
layout = BIDSLayout(dataset_path)

The output (layout object) contains both the loaded dataset and the schema.

Advance Loading#

You can also use load_dataset to load your dataset, it requires you to read the schema separatedly but you can combine it with DatasetOptions for more advance options.

from ancpbids import load_dataset
dataset = load_dataset(dataset_path)
schema = dataset.get_schema()
print(dataset)

#{'name': 'ds003483'}
  • lazy_loading [default: True]: If True, file contents will be loaded only when accessed, not during data initialization. This can significantly improve memory usage and loading performance for large datasets. If False, load_dataset will immediately load all metadata file contents into memory during dataset intialization

  • inter_artifact_datatype [default: False]: if True, it will determine the datatype of an Artifact, for example reading the directory path (/func/). It may have a negative performance.

  • ignore [default: False]: if True, if there’s a .bidsignore file is available, all matching files and folders won’t be added to the in-memory graph.

    from ancpbids import load_dataset, DatasetOptions dataset = load_dataset(dataset_path, DatasetOptions(ignore=False, infer_artifact_datatype=True)) schema = dataset.get_schema() print(dataset)

    #{‘name’: ‘ds003483’}

Next section#

Now that your dataset is loaded and mapped into a layout, you’re ready to start extracting useful information from it. In the next sections, we’ll show how to: