pyrobex package

Submodules

pyrobex.cli module

pyrobex.cli

console script for pyrobex

this is a silly script because it provides a python script interface to a bash script, but it’s slightly easier to deploy because of setup.py and it allows easy testing of the pyrobex package

Author: Jacob Reinhold (jcreinhold@gmail.com) Created on: May 6, 2021

pyrobex.cli.arg_parser() ArgumentParser[source]
pyrobex.cli.check_args(args: Namespace) None[source]
pyrobex.cli.main(args: Optional[Union[Namespace, List[str]]] = None) int[source]

Console script for pyrobex.

pyrobex.cli.setup_log(verbosity: int) None[source]

get logger with appropriate logging level and message

pyrobex.errors module

pyrobex.errors

pyrobex-specific errors

Author: Jacob Reinhold (jcreinhold@gmail.com) Created on: May 5, 2021

exception pyrobex.errors.PyRobexError[source]

Bases: Exception

pyrobex.io module

pyrobex.io

load an image with either antspy or nibabel

Author: Jacob Reinhold (jcreinhold@gmail.com) Created on: May 6, 2021

class pyrobex.io.NiftiImage(data: numpy.ndarray, header=None, affine: Optional[numpy.ndarray] = None, extra: Optional[dict] = None)[source]

Bases: object

Helper class to work with nibabel and antspy images

get_fdata() numpy.ndarray[source]
classmethod load(filename: str) Union[NI, ants.ANTsImage][source]
to_filename(filename: str) None[source]
to_nibabel() nibabel.Nifti1Image[source]

pyrobex.robex module

pyrobex.robex

main python wrapper functions for robex

Author: Jacob Reinhold (jcreinhold@gmail.com) Created on: May 5, 2021

pyrobex.robex.robex(image: NiftiImage, seed: int = 0) Tuple[NiftiImage, NiftiImage][source]

Takes a NIfTI image from nibabel or antspy and performs ROBEX brain extraction on the image volume

Parameters
  • image (NiftiImage) – a nibabel NIfTI image, e.g., nib.Nifti1Image, or an antspy image

  • seed (int) – random seed for reproducibility

Returns

depending on the input,

returns a nibabel NIfTI image or an antspy image of the extracted brain

mask (NiftiImage): depending on the input,

returns a nibabel NIfTI image or an antspy image of a binary mask of the brain

Return type

stripped (NiftiImage)

Raises

PyRobexError – when ROBEX is not found or fails

pyrobex.robex.robex_mask(image: NiftiImage, seed: int = 0) NiftiImage[source]

Takes a NIfTI image from nibabel or antspy and performs ROBEX brain extraction on the image volume and returns only the mask

Parameters
  • image (NiftiImage) – a nibabel NIfTI image, e.g., nib.Nifti1Image, or an antspy image

  • seed (int) – random seed for reproducibility

Returns

depending on the input,

returns a nibabel NIfTI image or an antspy image of a binary mask of the brain

Return type

mask (NiftiImage)

Raises

PyRobexError – when ROBEX is not found or fails

pyrobex.robex.robex_stripped(image: NiftiImage, seed: int = 0) NiftiImage[source]

Takes a NIfTI image from nibabel or antspy and performs ROBEX brain extraction on the image volume and returns only the extracted brain image

Parameters
  • image (NiftiImage) – a nibabel NIfTI image, e.g., nib.Nifti1Image, or an antspy image

  • seed (int) – random seed for reproducibility

Returns

depending on the input,

returns a nibabel NIfTI image or an antspy image of the extracted brain

Return type

stripped (NiftiImage)

Raises

PyRobexError – when ROBEX is not found or fails

Module contents

Top-level package for pyrobex.