nf-SurgeryFlow is a Nextflow pipeline for processing neuroimaging data. This pipeline includes various preprocessing, reconstruction, tracking, and segmentation steps.
nf-SurgeryFlow is an end-to-end tractography pipeline dedicated to clinicians in a pre-surgical setting. It performs preprocessing, T1 segmentation, DTI and fODF metrics computations, tractography, virtual dissection and an optional Nifti to DICOM conversion.
![nf-surgeryflow-schema(/nf-surgeryflow-schema.png)]
To install nf-SurgeryFlow, you need to have Nextflow and Docker installed. Follow these steps:
-
Install Nextflow:
curl -s https://get.nextflow.io | bash -
Install Docker: Follow the instructions on the Docker website.
-
Clone the repository:
git clone https://github.com/yourusername/nf-surgeryflow.git cd nf-surgeryflow
This pipeline is still under developpement, therefore has not been tested under all circomstances. Here are the main elements to know to be able to run it:
- Some modules use Freesurfer tools, which require pointing to a valid Freesurfer license. This license should be provided by the user and passed through when calling nf-surgeryflow. Refer to this page.
- BundleSeg uses an atlas-based virtual dissection method, therefore needs a white matter bundles atlas. You can use yours or use this one
- We highly recommend using <-profile docker> or <-profile apptainer>, , as it controls the version of the software used and avoids the installation of all the required softwares.
Note
If you are new to Nextflow and nf-core, please refer to this page on how to set-up Nextflow.
nf-surgeryflow takes the following inputs, passing the /path/to/root at the --input flag:
" --input=/path/to/[root] Input directory containing your subjects"
""
" [root]"
" ├-- S1"
" | ├-- *dwi.nii.gz"
" | ├-- *dwi.bval"
" | ├-- *dwi.bvec"
" | ├-- *t1.nii.gz"
" | ├-- *b0.nii.gz (optional)"
" | ├-- *rev_dwi.nii.gz (optional)"
" | ├-- *rev_dwi.bval (optional)"
" | ├-- *rev_dwi.bvec (optional)"
" | ├-- *rev_b0.nii.gz (optional)"
" | └-- *lesion.nii.gz (optional)" [WIP]
" └-- S2"
" ├-- *dwi.nii.gz"
" ├-- *dwi.bval"
" ├-- *dwi.bvec"
" ├-- *t1.nii.gz"
" ├-- *b0.nii.gz (optional)"
" ├-- *rev_dwi.nii.gz (optional)"
" ├-- *rev_dwi.bval (optional)"
" ├-- *rev_dwi.bvec (optional)"
" ├-- *rev_b0.nii.gz (optional)"
" └-- *lesion.nii.gz (optional)" [WIP]Configurations profiles
-profile docker: Each process will be run using docker containers (Recommended).-profile apptaineror-profile singularity: Each process will be run using apptainer/singularity images.-profile use-gpu: Some processes use GPU acceleration [WIP]-profile dicom: Convert output back to DICOM [WIP]
Processing profiles
-profile standard: Base tracking configuration for pre-surgical evaluation-profile tumour: Base tracking configuration for tumour evaluation-profile tractoflow: Revert processing to standard tractoflow pipeline [WIP]
Using either -profile docker or -profile apptainer is highly recommended, as it controls the version of the software used and avoids the installation of all the required softwares.
To run the pipeline, use the following command:
nextflow run main.nf --input /path/to/input --atlas /path/to/atlas --fs_license /path/to/license.txt -profile standard,[<docker|apptainer>]Processing steps Diffusion processes
- Preliminary DWI brain extraction (FSL)
- Denoise DWI (Mrtrix3)
- Gibbs correction (Mrtrix3)
- Topup (FSL)
- Eddy (FSL)
- Extract B0 (Scilpy)
- DWI brain extraction (FSL)
- N4 DWI (ANTs)
- Crop DWI (Scilpy)
- Resample DWI (Scilpy)
- Resample B0 (Scilpy)
- extract SH fitted to DWI (Scilpy)
T1 processes
- Denoise T1 (Scilpy)
- N4 T1 (ANTs)
- Resample T1 (Scilpy)
- T1 brain extraction (Freesurfer)
- Crop T1 (Scilpy)
- Registration on diffusion (Freesurfer)
- Tissue segmentation (Freesurfer)
Metrics processes
- Extract DTI shells (Scilpy)
- DTI metrics (Scilpy)
- Extract fODF shells (Scilpy)
- Compute fiber response function (Scilpy)
- Mean fiber response function (Scilpy)
- fODF metrics (scilpy)
- PFT maps (Scilpy)
- Seeding and tracking masks (Scilpy)
- Tracking (local or PFT) (Scilpy)
Bundle segmentation
- Register atlas in diffusion space (ANTs)
- Bundle segmentation and clean (Scilpy)
- Filter_Bundles (Scilpy)
- Bundles_On_Anat (Scilpy)
Nifti to DICOM [WIP]
- Affine matrix conversion (Freesurfer)
- NIFTI to DICOM conversion (nii2dcm)