MedPy2


NameMedPy2 JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryMedical image processing in Python
upload_time2024-03-03 10:32:26
maintainer
docs_urlNone
author
requires_python
licenseLICENSE.txt
keywords medical image processing dicom itk insight tool kit mri ct us graph cut max-flow min-cut
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # MedPy

[GitHub](https://github.com/loli/medpy/) | [Documentation](http://loli.github.io/medpy/) | [Tutorials](http://loli.github.io/medpy/) | [Issue tracker](https://github.com/loli/medpy/issues) | [Contact](oskar.maier@gmail.com)

**MedPy** is a library and script collection for medical image processing in Python, providing basic functionalities for **reading**, **writing** and **manipulating** large images of **arbitrary dimensionality**.
Its main contributions are n-dimensional versions of popular **image filters**, a collection of **image feature extractors**, ready to be used with [scikit-learn](http://scikit-learn.org), and an exhaustive n-dimensional **graph-cut** package.

* [Installation](#installation)
* [Getting started with the library](#getting-started-with-the-library)
* [Getting started with the scripts](#getting-started-with-the-scripts)
* [Read/write support for medical image formats](#read-write-support-for-medical-image-formats)
* [Requirements](#requirements)
* [License](#license)

## Installation

```bash
sudo apt-get install libboost-python-dev build-essential
pip3 install medpy
```

**MedPy** requires **Python 3** and officially supports Ubuntu as well as other Debian derivatives.
For installation instructions on other operating systems see the [documentation](http://loli.github.io/medpy/).
While the library itself is written purely in Python, the **graph-cut** extension comes in C++ and has it's own requirements. More details can be found in the [documentation](http://loli.github.io/medpy/).

### Using Python 2

**Python 2** is no longer supported. But you can still use the older releases.

```bash
pip install medpy==0.3.0
```

## Getting started with the library

If you already have a medical image whose format is support (see the [documentation](http://loli.github.io/medpy/>) for details), then good.
Otherwise, navigate to http://www.nitrc.org/projects/inia19, click on the *Download Now* button, unpack and look for the *inia19-t1.nii* file. Open it in your favorite medical image viewer (I personally fancy [itksnap](http://www.itksnap.org)) and beware: the INIA19 primate brain atlas.

Load the image

```python
from medpy.io import load
image_data, image_header = load('/path/to/image.xxx')
```

The data is stored in a numpy ndarray, the header is an object containing additional metadata, such as the voxel-spacing. Now lets take a look at some of the image metadata

```python
image_data.shape
```

`(168, 206, 128)`

```python
image_data.dtype
```

`dtype(float32)`

And the header gives us

```python
image_header.get_voxel_spacing()
```

`(0.5, 0.5, 0.5)`

```python
image_header.get_offset()
```

`(0.0, 0.0, 0.0)`

Now lets apply one of the **MedPy** filter, more exactly the [Otsu thresholding](https://en.wikipedia.org/wiki/Otsu%27s_method), which can be used for automatic background removal

```python
from medpy.filter import otsu
threshold = otsu(image_data)
output_data = image_data > threshold
```

And save the binary image, marking the foreground

```python
from medpy.io import save
save(output_data, '/path/to/otsu.xxx', image_header)
```

After taking a look at it, you might want to dive deeper with the tutorials found in the [documentation](http://loli.github.io/medpy/).

## Getting started with the scripts

**MedPy** comes with a range of read-to-use commandline scripts, which are all prefixed by `medpy_`.
To try these examples, first get an image as described in the previous section. Now call

```bash
medpy_info.py /path/to/image.xxx
```

will give you some details about the image. With

```bash
medpy_diff.py /path/to/image1.xxx /path/to/image2.xxx
```

you can compare two image. And

```bash
medpy_anisotropic_diffusion.py /path/to/image.xxx /path/to/output.xxx
```

lets you apply an edge preserving anisotropic diffusion filter. For a list of all scripts, see the [documentation](http://loli.github.io/medpy/).

## Read/write support for medical image formats

MedPy relies on SimpleITK, which enables the power of ITK for image loading and saving.
The supported image file formats should include at least the following. Note that not all might be supported by your machine.

**Medical formats:**

* ITK MetaImage (.mha/.raw, .mhd)
* Neuroimaging Informatics Technology Initiative (NIfTI) (.nia, .nii, .nii.gz, .hdr, .img, .img.gz)
* Analyze (plain, SPM99, SPM2) (.hdr/.img, .img.gz)
* Digital Imaging and Communications in Medicine (DICOM) (.dcm, .dicom)
* Digital Imaging and Communications in Medicine (DICOM) series (<directory>/)
* Nearly Raw Raster Data (Nrrd) (.nrrd, .nhdr) 
* Medical Imaging NetCDF (MINC) (.mnc, .MNC)
* Guys Image Processing Lab (GIPL) (.gipl, .gipl.gz)

**Microscopy formats:**

* Medical Research Council (MRC) (.mrc, .rec)
* Bio-Rad (.pic, .PIC)
* LSM (Zeiss) microscopy images (.tif, .TIF, .tiff, .TIFF, .lsm, .LSM)
* Stimulate / Signal Data (SDT) (.sdt)

**Visualization formats:**

* VTK images (.vtk)

**Other formats:**

* Portable Network Graphics (PNG) (.png, .PNG)
* Joint Photographic Experts Group (JPEG) (.jpg, .JPG, .jpeg, .JPEG)
* Tagged Image File Format (TIFF) (.tif, .TIF, .tiff, .TIFF)
* Windows bitmap (.bmp, .BMP)
* Hierarchical Data Format (HDF5) (.h5 , .hdf5 , .he5)
* MSX-DOS Screen-x (.ge4, .ge5)

## Requirements

MedPy comes with a number of dependencies and optional functionality that can require you to install additional packages.

### Main dependencies

* [scipy](http://www.scipy.org)
* [numpy](http://www.numpy.org)
* [SimpleITK](https://simpleitk.readthedocs.io)

### Optional functionalities

* compilation with `max-flow/min-cut` (enables the GraphCut functionalities)

## License

MedPy is distributed under the GNU General Public License, a version of which can be found in the LICENSE.txt file.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "MedPy2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "medical image processing dicom itk insight tool kit MRI CT US graph cut max-flow min-cut",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a7/6f/bb888da780af24afbe93bb46f5b5efb59887ff689f4a7f8d287551e0c89c/MedPy2-0.0.2.tar.gz",
    "platform": null,
    "description": "# MedPy\n\n[GitHub](https://github.com/loli/medpy/) | [Documentation](http://loli.github.io/medpy/) | [Tutorials](http://loli.github.io/medpy/) | [Issue tracker](https://github.com/loli/medpy/issues) | [Contact](oskar.maier@gmail.com)\n\n**MedPy** is a library and script collection for medical image processing in Python, providing basic functionalities for **reading**, **writing** and **manipulating** large images of **arbitrary dimensionality**.\nIts main contributions are n-dimensional versions of popular **image filters**, a collection of **image feature extractors**, ready to be used with [scikit-learn](http://scikit-learn.org), and an exhaustive n-dimensional **graph-cut** package.\n\n* [Installation](#installation)\n* [Getting started with the library](#getting-started-with-the-library)\n* [Getting started with the scripts](#getting-started-with-the-scripts)\n* [Read/write support for medical image formats](#read-write-support-for-medical-image-formats)\n* [Requirements](#requirements)\n* [License](#license)\n\n## Installation\n\n```bash\nsudo apt-get install libboost-python-dev build-essential\npip3 install medpy\n```\n\n**MedPy** requires **Python 3** and officially supports Ubuntu as well as other Debian derivatives.\nFor installation instructions on other operating systems see the [documentation](http://loli.github.io/medpy/).\nWhile the library itself is written purely in Python, the **graph-cut** extension comes in C++ and has it's own requirements. More details can be found in the [documentation](http://loli.github.io/medpy/).\n\n### Using Python 2\n\n**Python 2** is no longer supported. But you can still use the older releases.\n\n```bash\npip install medpy==0.3.0\n```\n\n## Getting started with the library\n\nIf you already have a medical image whose format is support (see the [documentation](http://loli.github.io/medpy/>) for details), then good.\nOtherwise, navigate to http://www.nitrc.org/projects/inia19, click on the *Download Now* button, unpack and look for the *inia19-t1.nii* file. Open it in your favorite medical image viewer (I personally fancy [itksnap](http://www.itksnap.org)) and beware: the INIA19 primate brain atlas.\n\nLoad the image\n\n```python\nfrom medpy.io import load\nimage_data, image_header = load('/path/to/image.xxx')\n```\n\nThe data is stored in a numpy ndarray, the header is an object containing additional metadata, such as the voxel-spacing. Now lets take a look at some of the image metadata\n\n```python\nimage_data.shape\n```\n\n`(168, 206, 128)`\n\n```python\nimage_data.dtype\n```\n\n`dtype(float32)`\n\nAnd the header gives us\n\n```python\nimage_header.get_voxel_spacing()\n```\n\n`(0.5, 0.5, 0.5)`\n\n```python\nimage_header.get_offset()\n```\n\n`(0.0, 0.0, 0.0)`\n\nNow lets apply one of the **MedPy** filter, more exactly the [Otsu thresholding](https://en.wikipedia.org/wiki/Otsu%27s_method), which can be used for automatic background removal\n\n```python\nfrom medpy.filter import otsu\nthreshold = otsu(image_data)\noutput_data = image_data > threshold\n```\n\nAnd save the binary image, marking the foreground\n\n```python\nfrom medpy.io import save\nsave(output_data, '/path/to/otsu.xxx', image_header)\n```\n\nAfter taking a look at it, you might want to dive deeper with the tutorials found in the [documentation](http://loli.github.io/medpy/).\n\n## Getting started with the scripts\n\n**MedPy** comes with a range of read-to-use commandline scripts, which are all prefixed by `medpy_`.\nTo try these examples, first get an image as described in the previous section. Now call\n\n```bash\nmedpy_info.py /path/to/image.xxx\n```\n\nwill give you some details about the image. With\n\n```bash\nmedpy_diff.py /path/to/image1.xxx /path/to/image2.xxx\n```\n\nyou can compare two image. And\n\n```bash\nmedpy_anisotropic_diffusion.py /path/to/image.xxx /path/to/output.xxx\n```\n\nlets you apply an edge preserving anisotropic diffusion filter. For a list of all scripts, see the [documentation](http://loli.github.io/medpy/).\n\n## Read/write support for medical image formats\n\nMedPy relies on SimpleITK, which enables the power of ITK for image loading and saving.\nThe supported image file formats should include at least the following. Note that not all might be supported by your machine.\n\n**Medical formats:**\n\n* ITK MetaImage (.mha/.raw, .mhd)\n* Neuroimaging Informatics Technology Initiative (NIfTI) (.nia, .nii, .nii.gz, .hdr, .img, .img.gz)\n* Analyze (plain, SPM99, SPM2) (.hdr/.img, .img.gz)\n* Digital Imaging and Communications in Medicine (DICOM) (.dcm, .dicom)\n* Digital Imaging and Communications in Medicine (DICOM) series (<directory>/)\n* Nearly Raw Raster Data (Nrrd) (.nrrd, .nhdr) \n* Medical Imaging NetCDF (MINC) (.mnc, .MNC)\n* Guys Image Processing Lab (GIPL) (.gipl, .gipl.gz)\n\n**Microscopy formats:**\n\n* Medical Research Council (MRC) (.mrc, .rec)\n* Bio-Rad (.pic, .PIC)\n* LSM (Zeiss) microscopy images (.tif, .TIF, .tiff, .TIFF, .lsm, .LSM)\n* Stimulate / Signal Data (SDT) (.sdt)\n\n**Visualization formats:**\n\n* VTK images (.vtk)\n\n**Other formats:**\n\n* Portable Network Graphics (PNG) (.png, .PNG)\n* Joint Photographic Experts Group (JPEG) (.jpg, .JPG, .jpeg, .JPEG)\n* Tagged Image File Format (TIFF) (.tif, .TIF, .tiff, .TIFF)\n* Windows bitmap (.bmp, .BMP)\n* Hierarchical Data Format (HDF5) (.h5 , .hdf5 , .he5)\n* MSX-DOS Screen-x (.ge4, .ge5)\n\n## Requirements\n\nMedPy comes with a number of dependencies and optional functionality that can require you to install additional packages.\n\n### Main dependencies\n\n* [scipy](http://www.scipy.org)\n* [numpy](http://www.numpy.org)\n* [SimpleITK](https://simpleitk.readthedocs.io)\n\n### Optional functionalities\n\n* compilation with `max-flow/min-cut` (enables the GraphCut functionalities)\n\n## License\n\nMedPy is distributed under the GNU General Public License, a version of which can be found in the LICENSE.txt file.\n",
    "bugtrack_url": null,
    "license": "LICENSE.txt",
    "summary": "Medical image processing in Python",
    "version": "0.0.2",
    "project_urls": null,
    "split_keywords": [
        "medical",
        "image",
        "processing",
        "dicom",
        "itk",
        "insight",
        "tool",
        "kit",
        "mri",
        "ct",
        "us",
        "graph",
        "cut",
        "max-flow",
        "min-cut"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7961bf7af129c59a92e8b55c16176c35440d0bb2503ba9582992b92a90486fc5",
                "md5": "36c434b3c3db140f959194a95c4692a8",
                "sha256": "6ee3b2998a3eecd2e689c3fa555333798c5e1852b7e5f0ae63f14ee9ea3aa5a6"
            },
            "downloads": -1,
            "filename": "MedPy2-0.0.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "36c434b3c3db140f959194a95c4692a8",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 214311,
            "upload_time": "2024-03-03T10:32:21",
            "upload_time_iso_8601": "2024-03-03T10:32:21.038208Z",
            "url": "https://files.pythonhosted.org/packages/79/61/bf7af129c59a92e8b55c16176c35440d0bb2503ba9582992b92a90486fc5/MedPy2-0.0.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "95ababddec1449eb5661cd7b73fdc71a5b8e07da758de6295a3c1b2d69804f4c",
                "md5": "382a701bd00b58e70a31a5ea337f08b0",
                "sha256": "574de436db020090f6595724aa9469882cff434985bd54680ceebfcc2595e72a"
            },
            "downloads": -1,
            "filename": "MedPy2-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "382a701bd00b58e70a31a5ea337f08b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 214308,
            "upload_time": "2024-03-03T10:32:23",
            "upload_time_iso_8601": "2024-03-03T10:32:23.746366Z",
            "url": "https://files.pythonhosted.org/packages/95/ab/abddec1449eb5661cd7b73fdc71a5b8e07da758de6295a3c1b2d69804f4c/MedPy2-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a76fbb888da780af24afbe93bb46f5b5efb59887ff689f4a7f8d287551e0c89c",
                "md5": "18a77ece227dc9194f4f7e17e1a47fea",
                "sha256": "59f6c097d9f4f45b782690687ebd614d0eeaf7c75897bbfbc2c09dc380a4251a"
            },
            "downloads": -1,
            "filename": "MedPy2-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "18a77ece227dc9194f4f7e17e1a47fea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 148067,
            "upload_time": "2024-03-03T10:32:26",
            "upload_time_iso_8601": "2024-03-03T10:32:26.883154Z",
            "url": "https://files.pythonhosted.org/packages/a7/6f/bb888da780af24afbe93bb46f5b5efb59887ff689f4a7f8d287551e0c89c/MedPy2-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-03 10:32:26",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "medpy2"
}
        
Elapsed time: 2.88975s