Skip to content

Fetpype

About

Fetpype is a library that aims at facilitating the analysis of fetal brain MRI by integrating the variety of tools commonly used in processing pipelines. Starting from clinical acquisition of fetal brain MRI (T2-weighted fast spin echo sequences), it performs pre-processing, reconstruction, segmentation and surface extraction.

Fetpype diagram

The tool

Fetpype aims at integrating a variety of existing tools, available as docker containers into a single, easy to use interface. It relies on three main components:

  • Standardized data formatting following the BIDS (Brain Imaging Data Structure) convention.
  • Integration of containerized methods using Docker or Singularity.
  • Chaining of data calls using Nipype, a library for robust integration of heterogeneous neuroimaging pipelines.
  • Simple yaml configuration files generated using Hydra.

BIDS, containers, Nipype and hydra

This package is actively under deployment in a public GitHub repository. If you have any question, trouble with the code or desire included a new feature feel free to open an issue there! If you find a typo, or want to include your new method in fetpype, you can submit a pull request (details on how to include your method in fetpype can be found here).

Quick start guide

Installation

Clone the latest version of the fetpype repository

git clone https://github.com/fetpype/fetpype

Within your desired python environment, install fetpype

pip install -e .

Running your first pipeline

Data formatting

Start with a BIDS-formatted dataset containing multiple stacks of low-resolution T2-weighted fetal brain MRI. A BIDS formatted folder should look as follows

sub-01
    [ses-01]
        anat
            sub-01_[ses-01]_run-1_T2w.nii.gz
            sub-01_[ses-01]_run-2_T2w.nii.gz
            ...
            sub-01_[ses-01]_run-N_T2w.nii.gz
sub-myname
    [ses-01]
        anat
            sub-myname_[ses-01]_run-1_T2w.nii.gz
            sub-myname_[ses-01]_run-2_T2w.nii.gz
            sub-myname_[ses-01]_run-6_T2w.nii.gz
            sub-myname_[ses-01]_run-7_T2w.nii.gz
    [ses-02]
            sub-myname_[ses-01]_run-1_T2w.nii.gz
            sub-myname_[ses-01]_run-2_T2w.nii.gz
            sub-myname_[ses-01]_run-3_T2w.nii.gz

Here, [ses-XX] is an optional tag/folder level. The anat folder will contain the different runs, which are the different stacks acquired for a given subject. More information about BIDS formatting is available here.

Choose what you will run

The pipeline that will be run is defined by a structure of config files. A default pipeline, featuring pre-processing (mask extraction, denoising, cropping and masks), reconstruction (using NeSVoR1) and segmentation (using BOUNTI2) is defined by the following config file.

It starts by a master config located at configs/default_docker.yaml with the following structure

defaults:
  - preprocessing/default # Default preprocessing
  - reconstruction/nesvor # NeSVoR reconstruction -- You can choose between svrtk, nifymic or nesvor
  - segmentation/bounti   # BOUNTI segmentation     
  - _self_
container: "docker"       # Running on docker (other option is singularity)
reconstruction:           # Generic reconstruction arguments
  output_resolution: 0.8  # Target resolution for reconstruction
save_graph: True
This config defines a pipeline that will run the default preprocessing step (defined in configs/preprocessing/default.yaml), the NeSVoR reconstruction pipeline (defined in configs/reconstruction/nesvor.yaml) followed by the BOUNTI segmentation pipeline (defined in configs/preprocessing/bounti.yaml). Hydra will go in the corresponding folder and load the files to create a global config defined in a nested manner. Changing the pipeline that you want to run is as easy as changing the reconstruction pipeline from nesvor to niftymic.

The details of the configs, the attributes and methods implemented is available in this page.

Singularity

Fetpype also supports running pipelines using Singularity containers. To run your pipeline with Singularity, ensure that you have Singularity installed and available. Currently, singularity images need to be built manually and saved to a folder. You can indicate the folder in the .yaml file in the "singularity_path" field (see configs/default_sg.yaml for an example). The list of images and their name that are needed to run the pipeline is as follows:

  • nesvor.sif for the NeSVoR pipeline (junshenxu/nesvor:v0.5.0)
  • niftymic.sif for the NiftyMIC pipeline (from renbem/niftymic:latest)
  • svrtk.sif for the SVRTK pipeline (from fetalsvrtk/svrtk:general_auto_amd)
  • bounti.sif for the BOUNTI pipeline (from fetalsvrtk/segmentation:general_auto_amd)
  • fetpype_utils.sif for the utils pipeline (from gerardmartijuan/fetpype_utils:latest)

Just run it!

Once you chose the pipeline that you are going to run, you can then run it by calling

fetpype_run --data <THE_PATH_TO_YOUR_DATA> --out <THE_PATH_TO_YOUR_DATA>/derivatives/fetpype

Additional options are available when calling fetpype_run --help. Then just wait and see your results!

While you're waiting for the results

Feel free to explore how fetpype works and what it can do!


Contributors

Acknowledgements

Fetpype was funded by ERA-NET NEURON in the context of the MULTIFACT project. It received funding under different national agencies:

  • Swiss National Science Foundation — grant 31NE30_203977;
  • Spain's Ministry of Science, Innovation and Universities — grant MCIN/AEI/10.13039/501100011033/
  • French National Research Agency — grant ANR-21-NEU2-0005;

This project was also supported by the SulcalGRIDS project (ANR-19-CE45-0014) and the SNSF project no. 215641.


  1. Junshen Xu and others. NeSVoR: implicit neural representation for slice-to-volume reconstruction in MRI. IEEE Transactions on Medical Imaging, 2023. 

  2. Alena U Uus and others. BOUNTI: brain volumetry and automated parcellation for 3d fetal mri. bioRxiv, 2023.