fw-bids-utils
Overview
fw-bids-utils is a Python package that holds helper methods used across the
fw-bids suite. This library provides common functionality for working with BIDS
(Brain Imaging Data Structure) datasets in the Flywheel ecosystem. While care
should be taken to add methods to the appropriate fw-bids subsuite as needs
arise, this module contains methods that should be maintained in a common repo.
An example of a common method is the classifications class. Changes to
classifications will impact import_bids as well as curate_bids.
Installation
Using pip
pip install fw-bids-utils
From source
git clone https://github.com/flywheel-io/fw-bids-utils.git
cd fw-bids-utils
pip install -e .
Dependencies
This package requires Python 3.11+ and includes the following dependencies:
- flywheel-gear-toolkit
- jsonschema
- rtstatlib
- fw-meta For development, additional dependencies are available in requirements-dev.txt:
- pytest
- pytest-cov
- pytest-mock
Modules
classifications
Contains utilities for BIDS classification mapping:
determine_modality: Determine which modality a file belongs to based on the parent directory's namesearch_classifications: Robust search on a filename to determine classifications
validate
Provides validation utilities for BIDS datasets:
validate_bids: Validate a BIDS dataset using the bids-validatorvalidate_project_label: Validate that a project label exists and is unique
helpers
General helper functions:
- String processing with
process_string_templateandformat_value - Dictionary utilities like
dict_lookup,dict_set, anddict_match - Project and session ID helpers
Usage Examples
Working with BIDS Classifications
from fw_bids_utils.classifications import determine_modality, search_classifications
# Determine the modality from a filename
modality = determine_modality("sub-01_T1w")
# Result: "anat"
# Get classification information
classification = search_classifications("anat", "T1w")
# Result: {"Measurement": "T1", "Intent": "Structural"}
Validating BIDS Datasets
from fw_bids_utils.validate import validate_bids
# Validate a BIDS dataset
is_valid = validate_bids("/path/to/bids/dataset")
Using Helpers
from fw_bids_utils.helpers import process_string_template
context = {
"subject": {"code": "01"},
"session": {"label": "session1"},
"file": {"info": {"BIDS": {"Modality": "T1w"}}}
}
# Process a template string
filename = process_string_template(
"sub-<subject.code>_ses-<session.label>_{file.info.BIDS.Modality}.nii.gz",
context
)
# Result: "sub-01_ses-session1_T1w.nii.gz"
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project
is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for fw-bids-utils 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fw_bids_utils-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / fw_bids_utils-0.1.1-py3-none-any.whl
| Download URL | fw_bids_utils-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc2c9bee6ff14c90fa4e56588f40118e7be00c5012541a3555f4164c8f536748
|
|
BLAKE2b-256 checksum How to use checksums |
729c712109b841111835dae082fd7cfdf9190970eeab0cfacbbbf24de8856468
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.25.0_alpha20260805","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|