Skip to main content

Pytorch toolbox for Hyperelastic Susceptibility Artifact Correction

Project description

PyHySCO

This is a package for Echo-Planar MRI susceptibility artifact correction implemented in PyTorch.

Installation

Python package dependencies are listed in requirements.txt. It is suggested to run the python file tests/test_all.py to ensure all tests are passing and the code is setup properly.

Usage

Command Line Correction

The program can be run directly from a terminal or command line by using the python command to run the file pyhysco.py. Supplying the following required parameters:

  • file_1: file path of first image (stored as nii.gz) with phase encoding direction opposite of file_2
  • file_2: file path of second image (stored as nii.gz) with phase encoding direction opposite of file_1
  • ped: phase-encoding dimension (1, 2, or 3)

Use the help flag (--help) to see optional parameters available.

Minimal Usage:

python pyhysco.py --file_1 <image1> --file_2 <image2> --ped <phase encoding direction>

Example:

python pyhysco.py --file_1 image1.nii.gz --file_2 image2.nii.gz --ped 1 --output_dir results/ --max_iter 25

Write a Correction Script

A user-written script can be used to call the methods of the program.

Example:

from EPI_MRI.EPIMRIDistortionCorrection import *
from optimization.GaussNewton import *
import torch

device = 'cuda:0' if torch.cuda.is_available() else 'cpu'

# load the image and domain information
# change this function call to be the filepath for your data
data = DataObject('../data/156334_v.nii.gz', '../data/156334_-v.nii.gz', 1, device=device,dtype=torch.float32)

loss_func = EPIMRIDistortionCorrection(data, 300, 1e-4, regularizer=myLaplacian3D, PC = JacobiCG)
# initialize the field map
B0 = loss_func.initialize(blur_result=True)
# set-up the optimizer
# change path to be where you want logfile and corrected images to be stored
opt = GaussNewton(loss_func, max_iter=500, verbose=True, path='results/gnpcg-Jac/')
# optimize!
opt.run_correction(B0)
# save field map and corrected images
opt.apply_correction()
# see plot of corrected images
opt.visualize()

Examples and Further Documentation

There are a set of examples in the examples directory. Full API documentation is in the docs directory. See also Instructions.md for an overview of the correction process.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyHySCO-0.0.2.tar.gz (63.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyHySCO-0.0.2-py3-none-any.whl (61.3 kB view details)

Uploaded Python 3

File details

Details for the file PyHySCO-0.0.2.tar.gz.

File metadata

  • Download URL: PyHySCO-0.0.2.tar.gz
  • Upload date:
  • Size: 63.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.3

File hashes

Hashes for PyHySCO-0.0.2.tar.gz
Algorithm Hash digest
SHA256 aa7f8ae63a77da5a586f6b49b133861a7bcf46839a3fb1a14a219df3a28ad1c8
MD5 e89f462c0745886d1bcd8dc6f20d1d9a
BLAKE2b-256 e362511db3e8575e2f8774acf89f1152a395b865b814bb4d0aa9be7353351cb0

See more details on using hashes here.

File details

Details for the file PyHySCO-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: PyHySCO-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 61.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.3

File hashes

Hashes for PyHySCO-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 75abc5601a0bd635e24b4555f7062b65e24d8f088fe74501148c615d88a85e24
MD5 fb4ef470fa6f89414141aa4f480f8d60
BLAKE2b-256 a084ab9c5ba8cb8e5b6af552e7d73b15442b0c3c092a4d72b0449d512760a99f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page