nf-bids API Documentation

website·Indexed 29 days ago

https://nf-neuro.github.io

Groovy API reference for nf-bids version 0.3.0, providing tools for BIDS (Brain Imaging Data Structure) dataset management, including BidsDataset models, BidsConfigValidator, BidsCsvParser, and various set handlers for file grouping and channel operations.

Tokens
121.5K
Snippets
558
Records
928
Agent score
74%

What's inside nf-bids

  1. Overview of BIDS Parsing and Dataset Normalization

    The BIDS parsing process converts a BIDS directory on disk into an in-memory BidsDataset model using a three-step pipeline:

    1. LibBidsShWrapper executes the external libBIDSsh_parse_bids_to_table shell function to generate a TSV output.
    2. BidsCsvParser converts the TSV rows into a list of BidsFile objects.
    3. BidsParser assembles these files into a BidsDataset and loads metadata from participants.tsv.
  2. Overview of MAGeT-Brain segmentation subworkflow

    The magetbrain subworkflow performs multi-atlas segmentation by propagating atlas labels to subjects via an intermediate template library. This approach leverages neuroanatomical variability to improve segmentation accuracy through a four-step pipeline:

    1. Register every atlas to every template.
    2. Register every template to every subject.
    3. Chain transforms to resample atlas labels into subject space via all possible atlas-template-subject paths.
    4. Perform a majority vote across all candidate labels per subject to produce the final segmentation.
  3. Overview of nf-neuro test data infrastructure

    nf-neuro provides a system to host and distribute test data for contributors, consisting of three main components: a webserver hosting data packages versioned with DVC, a Nextflow subworkflow (LOAD_TEST_DATA) for downloading and caching data, and the Test Data Explorer VS Code extension for browsing and inspecting data packages.
  4. Overview of the tractometry subworkflow

    The tractometry subworkflow processes tractograms and associated data to clean, resample, and extract meaningful statistics. It performs the following sequence of operations:

    1. Invalid Streamline Removal: Cleans bundles by removing invalid streamlines.
    2. Fixel-Based Apparent Fiber Density: Computes mean apparent fiber density (AFD) and mean radial fODF (radfODF) maps along a bundle using FODF data.
    3. Centroid Processing: Resamples existing centroids or computes new centroids from cleaned bundles if they are missing.
    4. Label Map Generation: Creates a Nifti label image representing bundle coverage, segmented from head (0) to tail (-nb_pts). Each voxel is assigned the label of its nearest centroid point.
    5. Streamline Uniformization: Normalizes labeled tractograms for consistency.
    6. Statistical Analysis: Computes streamline length distributions, endpoint-based metrics, global and lesion-specific volume measurements, and mean/standard deviation of diffusion metrics per bundle.
  5. Overview of nf-bids Plugin Core and DSL Extensions

    The nfneuro.plugin package contains the core entry points for the nf-bids plugin. Key classes include BidsPlugin (the PF4J plugin entry point), BidsExtension (which provides the DSL extensions Channel.fromBIDS(), groupTupleBy, joinBy, and combineBy), BidsFactory, and BidsObserver for lifecycle monitoring.
  6. Overview of the TractoFlow pipeline subworkflow

    The tractoflow subworkflow implements the TractoFlow pipeline to process raw diffusion and T1 weighted images. It is designed to reduce acquisition biases, align anatomical and diffusion spaces, compute DTI and fODF metrics, and generate whole brain tractograms.
  7. Overview of the preproc_dwi subworkflow

    The preproc_dwi subworkflow preprocesses DWI images to prepare them for diffusion profile extraction (e.g., via DTI, fODF, or MAP-MRI). The pipeline transforms raw DWI data into a denoised, susceptibility-corrected, eddy-current and motion-corrected, normalized, cropped, and resampled image.

    Required Inputs:

    • A DWI image (ch_dwi)
    • Corresponding b-value (bval) and b-vector (bvec) files.

    Optional Inputs:

    • Reversed DWI image with corresponding bval/bvec files (ch_rev_dwi)
    • Reversed phase encoded b=0 image (ch_rev_b0)
    • Topup configuration file.
  8. Uniformize streamline endpoints using bundle\uniformize

    The bundle\uniformize module streamlines the endpoints of fiber bundles according to a defined axis or a reference centroid. This process is primarily used for tractometry or the creation of anatomical models. It utilizes the scilpy Python dMRI processing toolbox.
  9. Perform brain tissue segmentation with freesurferseg

    The freesurferseg module performs brain tissue segmentation using FreeSurfer aparc and wmparc output files. It generates masks for White Matter (WM), Grey Matter (GM), and Cerebrospinal Fluid (CSF). A binary lesion mask can be provided to correct the white matter mask.
  10. Understand nf-neuro Modules and Subworkflows architecture

    nf-neuro pipelines are constructed using a modular architecture consisting of two primary components: Modules and Subworkflows. This structure ensures code reusability, maintainability, and scalability.

    • Modules: These are single, reusable Nextflow processes designed for a specific task (e.g., brain extraction or filtering). They are located in the /modules/nf-neuro/ directory.
    • Subworkflows: These are chains of modules that form higher-level workflows. They define the connectivity and logic required to achieve a broader goal, such as a complete preprocessing pipeline. They are located in the /subworkflows/nf-neuro/ directory.