SkillAgentSearch skills...

NeSVoR

NeSVoR is a package for GPU-accelerated slice-to-volume reconstruction.

Install / Use

/learn @daviddmc/NeSVoR

README

NeSVoR: Neural Slice-to-Volume Reconstruction

<p align="left"> <a href="https://github.com/daviddmc/NeSVoR/releases" alt="releases"> <img src="https://img.shields.io/github/v/release/daviddmc/NeSVoR?display_name=tag" /> </a> <a href="https://hub.docker.com/r/junshenxu/nesvor/tags" alt="docker"> <img src="https://img.shields.io/docker/v/junshenxu/nesvor?label=docker%20image%20version" /> </a> <a href='https://nesvor.readthedocs.io/en/latest/?badge=latest'> <img src='https://readthedocs.org/projects/nesvor/badge/?version=latest' alt='Documentation Status' /> </a> </p>

NeSVoR is a package for GPU-accelerated slice-to-volume reconstruction (both rigid and deformable).

This package is the accumulation of the following works:

[1] SVoRT: Iterative Transformer for Slice-to-Volume Registration in Fetal Brain MRI (Springer | Arxiv)

[2] NeSVoR: Implicit Neural Representation for Slice-to-Volume Reconstruction in MRI (IEEE | TechRxiv)

<p align="center"> <img src="./docs/_static/images/recon.gif" align="center" width="600"> </p> <p align="center"><p align="center"> <!-- toc --> <!-- tocstop -->

Overview

Methods

NeSVoR is a deep learning package for solving slice-to-volume reconstruction problems (i.e., reconstructing a 3D isotropic high-resolution volume from a set of motion-corrupted low-resolution slices) with application to fetal/neonatal MRI, which provides

<!--### Slice-to-Volume Registration Transformers (SVoRT)--> <p align="center"> <img src="./docs/_static/images/SVoRT_network.png" align="center" width="600"> </p> <p align="center">Figure 1. SVoRT: an iterative Transformer for slice-to-volume registration. (a) The k-th iteration of SVoRT. (b) The detailed network architecture of the SVT module.<p align="center"> <!--### Neural Slice-to-Volume Reconstruction (NeSVoR)--> <p align="center"> <img src="./docs/_static/images/NeSVoR.png" align="center" width="900"> </p> <p align="center">Figure 2. NeSVoR: A) The forward imaging model in NeSVoR. B) The architecture of the implicit neural network in NeSVoR.<p align="center">

Pipeline

To make our reconstruction tools more handy, we incorporate several preprocessing and downstream analysis tools in this package. The next figure shows our overall reconstruction pipeline.

<p align="center"> <img src="./docs/_static/images/pipeline.png" align="center" width="900"> </p> <p align="center">Figure 3. The reconstruction pipeline.<p align="center">

Documentation

The full documentation is available at Read the Docs.

Installation

Docker Image

We recommend to use our docker image to run nesvor.

Install Docker and NVIDIA Container Toolkit

You may follow this guide to install Docker and NVIDIA Container Toolkit

Download NeSVoR Image

docker pull junshenxu/nesvor

Note: our latest image was built with CUDA 11.7.

Run NeSVoR with Docker

You may run a container in an interactive way.

docker run -it --gpus all --ipc=host junshenxu/nesvor
nesvor -h

You may also run the nesvor command directly as follows.

docker run --rm --gpus all --ipc=host \
    -v <path-to-inputs>:/incoming:ro -v <path-to-outputs>:/outgoing:rw \
    junshenxu/nesvor \
    nesvor reconstruct \
    --input-stacks /incoming/stack-1.nii.gz ... /incoming/stack-N.nii.gz \
    --thicknesses <thick-1> ... <thick-N> \
    --output-volume /outgoing/volume.nii.gz

From Source

Check out our documentation if you want to install NeSVoR from source.

Quick Start

Fetal Brain Reconstruction

This example reconstruct a 3D fetal brain from mutiple stacks of 2D images in the following steps:

  1. Segment fetal brain from each image using a CNN (--segmentation).
  2. Correct bias field in each stack using the N4 algorithm (--bias-field-correction).
  3. Register slices using SVoRT (--registration svort).
  4. Reconstruct a 3D volume using NeSVoR.
nesvor reconstruct \
    --input-stacks stack-1.nii.gz ... stack-N.nii.gz \
    --thicknesses <thick-1> ... <thick-N> \
    --output-volume volume.nii.gz \
    --output-resolution 0.8 \
    --registration svort \
    --segmentation \
    --bias-field-correction

Neonatal Brain Reconstruction

This example reconstruct a 3D neonatal brain from mutiple stacks of 2D images in the following steps:

  1. Removal background (air) with Otsu thresholding (--otsu-thresholding).
  2. Correct bias field in each stack using the N4 algorithm (--bias-field-correction).
  3. Register slices using SVoRT (--registration svort).
  4. Reconstruct a 3D volume using NeSVoR.
nesvor reconstruct \
    --input-stacks stack-1.nii.gz ... stack-N.nii.gz \
    --thicknesses <thick-1> ... <thick-N> \
    --output-volume volume.nii.gz \
    --output-resolution 0.8 \
    --registration svort \
    --otsu-thresholding \
    --bias-field-correction

Fetal Body/Uterus Reconstruction

This is an example for deformable NeSVoR which consists of the following steps:

  1. Create an ROI based on the intersection of all input stacks (--stacks-intersection).
  2. Perform stack-to-stack registration (--registration stack).
  3. Reconstruct a 3D volume using Deformable NeSVoR (--deformable).
nesvor reconstruct \
    --input-stacks stack-1.nii.gz ... stack-N.nii.gz \
    --thicknesses <thick-1> ... <thick-N> \
    --output-volume volume.nii.gz \
    --output-resolution 1.0 \
    --stacks-intersection \
    --registration stack \
    --deformable \
    --weight-transformation 1 \
    --weight-deform 0.1 \
    --weight-image 0.1 \
    --single-precision \
    --log2-hashmap-size 22 \
    --batch-size 8192

Usage

This section provides the basic usage of the commands in NeSVoR. Please refer to our document for details. NeSVoR currently supports the following commands:

  • nesvor reconstruct: reconstruct a 3D volume (i.e., train a NeSVoR model) from either multiple stacks of slices (NIfTI) or a set of motion-corrected slices (the output of register). It can also perform multiple preprocessing steps, including brain segmentation, bias field correction, and registration.
  • nesvor register: register stacks of slices using a pretrained SVoRT model or stack-to-stack registration.
  • svr: a classical slice-to-volume registration/reconstruciton method.
  • nesvor sample-volume: sample a volume from a trained NeSVoR model.
  • nesvor sample-slices: simulate slices from a trained NeSVoR model.
  • nesvor segment-stack: 2D fetal brain segmentation/masking in input stacks.
  • nesvor correct-bias-field: bias field correction using the N4 algorihtm.
  • nesvor assess: quality and motion assessment of input stacks.
<!-- - [`nesvor segment-volume`](#3d-brain-segmentation): 3D fetal brain segmentation in reconstructed volumes. -->

run nesvor <command> -h for a full list of parameters of a command.

Reconstruction

Reconstruct from Mutiple Stacks of Slices

The reconstruct command can be used to reconstruct a 3D volume from N stacks of 2D slices (in NIfTI format, i.e. .nii or .nii.gz). A basic usage of reconstruct is as follows, where mask-i.nii.gz is the ROI mask of the i-th input stack.

nesvor reconstruct \
    --input-stacks stack-1.nii.gz ... stack-N.nii.gz \
    --stack-masks mask-1.nii.gz ... mask-N.nii.gz \
    --output-volume volume.nii.gz

A more elaborate example could be

nesvor reconstruct \
    --input-stacks stack-1.nii.gz ... stack-N.nii.gz \
    --stack-masks mask-1.nii.gz ... mask-N.nii.gz \
    --thicknesses <thick-1> ... <thick-N> \
    --output-volume volume.nii.gz \
    --output-resolution 0.8 \
    --output-model model.pt \
    --weight-image 1.0 \
    --image-regularization edge \
    --delta 0.2 \
    --n-iter 5000 \
    --level-scale 1.38 \
    --coarsest-resolution 16.0 \
    --finest-resolution 0.5 \
    --n-levels-bias 0
View on GitHub
GitHub Stars102
CategoryEducation
Updated15d ago
Forks23

Languages

Python

Security Score

100/100

Audited on Mar 18, 2026

No findings