medio


Namemedio JSON
Version 0.4.2 PyPI version JSON
download
home_pagehttps://github.com/RSIP-Vision/medio
SummaryMedical images I/O Python package
upload_time2022-12-04 05:54:36
maintainer
docs_urlNone
authorRSIP Vision
requires_python>=3.7,<4.0
licenseApache-2.0
keywords medical-images io itk nibabel pydicom
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Python version](
https://img.shields.io/pypi/pyversions/medio.svg)](
https://img.shields.io/pypi/pyversions/medio.svg)
[![PyPI version](
https://badge.fury.io/py/medio.svg)](
https://badge.fury.io/py/medio)
# medio

**Medical images I/O python package**

This package unifies the io engines of itk, nibabel, and pydicom (including dicom-numpy) packages 
in a simple and comprehensive interface.

It includes conversion between the metadata conventions, reorientations, affine matrix computation 
for itk and pydicom and saving dicom series or file.

# Installation
First, make sure you have the latest pip version (better to close PyCharm or any other program that 
uses the environments):
```
(<env-name>) >pip install -U pip
```
Install *medio* with:
```
(<env-name>) >pip install -U medio
```
This will install the medio python package and its dependencies in your environment.

### Requirements
The dependencies are:
- python (at least 3.6)
- numpy
- itk
- nibabel
- pydicom
- dicom-numpy

A conda environment .yml file is in the project's root.
Some dicom images may require installation of additional packages, gdcm for example.

# Usage
There are 3 main functions in medio: `read_img`, `save_img` and `save_dir`.
```python
from medio import read_img, save_img
# read a dicom series from a folder
array, metadata = read_img('data/dicom-folder/', desired_ornt='IAR')
# do your stuff and save in any format
save_img('ct.nii.gz', array, metadata, backend='nib')
```

# Documentation
## Reading and Saving Images

### read_img
`medio.read_img(input_path, desired_ornt=None, backend=None, dtype=None, header=False, 
channels_axis=-1, coord_sys='itk', **kwargs)`
- `input_path`: *path-like*<br>
  Path for the data to be read (str or pathlib.Path object for example). It can be a file or a 
  folder (in the case of a dicom series). It is the only required parameter.
  If the input path is a folder, it should contain a single dicom series. 
  If there is more than a single series, the optional parameter `series` can help. 
- Returns: *array, metadata*<br>
  array of type *numpy.ndarray* and metadata of type *medio.MetaData*. The first is a numpy array 
  of the image, and the second is a metadata object of the image (see [MetaData](#metadata) class 
  documentation).

Optional parameters:
- `desired_ornt`: *orientation string or None*<br>
  The desired orientation of the returned image array, e.g. 'RAI'. If None, no reorientation is 
  performed.
  The desired orientation is in the standard defined by `coord_sys` (itk by default). 
  See also [Orientation](#orientation)).<br>
  If `desired_ornt` is the same as the original image's orientation, no reorientation is performed.
- `backend`: *'nib', 'itk', 'pydicom', 'pdcm', or None*<br>
  The backend IO engine to use: 'nib' (nibabel), 'itk' or 'pydicom' (also 'pdcm'). If None, the 
  backend is chosen automatically: 'nib' for nifti files (e.g. '.nii' or '.nii.gz' suffix), 
  otherwise 'itk'.
- `dtype`: *numpy data-type or None*<br>
  If not None, equivalent to `array.astype(dtype)` on the returned image array.
- `header`: *bool*<br>
  If True, the returned metadata includes also a `metadata.header` attribute that stores the raw 
  metadata of the file as a dictionary.<br>
  This is not implemented for series of files (folder `input_path`), and not used during saving.
- `channels_axis`: *int or None*<br>
  If not None and the image has more than a single channel / component (e.g. RGB or RGBA), the 
  channels axis is `channels_axis`. If None, the backend's original convention is used.
- `coord_sys`: *'itk', 'nib', or None*<br>
  The coordinate system (or convention) of the `desired_ornt` parameter and the returned metadata.
  None means that the backend will determine `coord_sys`, but it can lead to a backend-dependent 
  array and metadata.

`**kwargs` are additional per-backend optional parameters:
- 'itk' backend:
  - `pixel_type=itk.SS`: *itk pixel-type or None*<br>
    Itk pixel type of the image file/folder. The default value is int16 (`itk.SS` - Signed Short). 
    Other common pixel types are: `itk.UC` - uint8, `itk.US` - uint16.<br>
    You can use the function `itk.ctype` in order to convert C-types to itk types. For example:<br>
    `itk.ctype('unsigned short') == itk.US`
  - `fallback_only=True`: *bool*<br>
    If True, the pixel type is automatically found and if failed then `pixel_type` is used 
    (`pixel_type` must not be None in this case).<br>
    Note: if `itk.imread(input_path)` fails, using `fallback_only=True` will result in a slightly 
    inferior performance. If you know what is pixel-type of the image beforehand, you can set it 
    with `pixel_type` and use `fallback_only=False`.
  - `series=None`: *str, int or None*<br>
    If `input_path` is a directory that contains multiple dicom series, selecting a specific one is 
    possible with the `series` argument. It can be the exact series instance UID (str), an int 
    between 0 and n-1, where n is the number of series in the directory, or None.<br>
    If `series` is None and there are multiple series in the directory, a detailed error message 
    is raised.

- 'pydicom' backend
  - `globber='*'`: *str*<br>
    Relevant for a directory - glob pattern for selecting the series files (all the files in the 
    directory by default).
  - `allow_default_affine=False`: *bool*<br>
    Relevant for a multiframe dicom file - if True and the dicom misses some physical tags for the 
    affine calculation, use a default affine value.
  - `series=None`: *str, int or None*<br>
    The counterpart of `series` in itk backend, see the explanation above.

### save_img
`medio.save_img(filename, np_image, metadata, use_original_ornt=True, backend=None, dtype=None, 
channels_axis=None, mkdir=False, parents=False, **kwargs)`
- `filename`: *path-like*<br>
  The file to be saved, including the format suffix.
- `np_image`: *numpy.ndarray*<br>
  The image array.
- `metadata`: *medio.MetaData*<br>
  The corresponding metadata, from `medio.read_img` for example. In the absence of a known 
  metadata, a default one can be constructed with `medio.MetaData(np.eye(4))`.

Optional parameters:
- `use_original_ornt`: *bool*<br> 
  Whether to save in the original orientation stored in `metadata.orig_ornt` or not.
- `backend`: *'nib', 'itk' or None*<br>
  The backend to use: 'nib' or 'itk'. If None, 'nib' is chosen for nifti files and 'itk' otherwise.
- `dtype`: *numpy data-type or None*<br>
  If not None, equivalent to passing `np_image.astype(dtype)`. Note that not every dtype is 
  supported in saving, so make sure what is the dtype of the image array you want to save.
- `channels_axis`: *int or None*<br>
  If not None, the image has channels (e.g. RGB) along the axis `channels_axis` of `np_image`.
- `mkdir`: *bool*<br>
  If True, creates the directory of `filename`.
- `parents`: *bool*<br>
  To be used with `mkdir=True`. If True, creates also the parent directories. 

'itk' backend optional parameters (`**kwargs`):
- `allow_dcm_reorient=False`: *bool*<br>
  When saving a dicom file ('.dcm' or '.dicom' suffix) the image orientation should be right-handed.
  If it is left-handed, the image can be reoriented to a right-handed orientation by setting this 
  parameter to True, which flips the last axis direction.
- `compression=False`: *bool*<br>
  Whether to use compression in itk writer. Using a '.nii.gz' suffix in `filename` also compresses
  the image.

### save_dir
`medio.save_dir(dirname, np_image, metadata, use_original_ornt=True, dtype=None, channels_axis=None,
parents=False, exist_ok=False, allow_dcm_reorient=False, **kwargs)`

Save a 3d numpy array `np_image` as a dicom series of 2d slices in the directory `dirname` (itk 
backend).

- `dirname`: *path-like*<br>
  The directory to save the files in (str or pathlib.Path). If it exists, it must be empty (unless 
  `exist_ok` is True).

The other parameters: `np_image`, `metadata`, `use_original_ornt`, `dtype`, `channels_axis`, 
`parents` and `allow_dcm_reorient` are equivalent to those of [save_img](#save_img).

Additional optional parameters (`**kwargs`):
- `exist_ok`: *bool*<br>
  If True, non-empty existing directory will not raise an error.
- `pattern='IM{}.dcm'`: *str*<br>
  Pattern for the filenames to save, including a placeholder ('`{}`') for the slice number.
  For example, one can use: `pattern={:03d}`.
- `metadata_dict=None`: *dict or None*<br>
  Dictionary of metadata for adding tags or overriding the default values. For example, 
  `metadata_dict={'0008|0060': 'US'}` will override the default 'CT' modality and set it to 'US' 
  (ultrasound).

## Metadata Objects
### Affine
`medio.Affine`

The affine of an image is a transformation between the index space of the array to the physical 3d 
space. The Affine class is a subclass of numpy.ndarray with some special properties (attributes): 
`spacing`, `origin`, and `direction`, which can be accessed and set. The method `index2coord` maps 
the indices to the physical space, `clone` clones the affine.

This class includes also some static methods for affine construction from its components (spacing, 
origin and direction) and also the inverse methods for getting the spacing, origin and direction 
matrix from a general affine matrix.

For a mathematical explanation about the affine matrix see 
[NiBabel's affine documentation](
https://nipy.org/nibabel/coordinate_systems.html#the-affine-matrix-as-a-transformation-between-spaces).

Some usage examples:
```python
>>> import numpy as np
>>> from medio import Affine
>>> affine1 = Affine(np.eye(4))
>>> affine2 = Affine(direction=np.eye(3), spacing=[0.33, 1, 0.33], origin=[-90.3, 10, 1.44])
>>> index = [4, 0, 9]
>>> coord = affine2.index2coord(index)
>>> print(coord)
[-88.98  10.     4.41]
```

### MetaData
`medio.MetaData`

Together with the image's numpy array, the MetaData object is a necessary component for the I/O 
functions.

A MetaData object 'metadata' is mainly comprised of:
- `metadata.affine`: the affine (of class Affine)
- `metadata.coord_sys`: coordinate system ('itk' or 'nib') 
- `metadata.orig_ornt`: the original orientation of the image (used for saving)
- `metadata.header`: a dictionary that includes additional metadata properties when `header=True` 
  in `read_img`, otherwise None

Other properties of the metadata are derived from the affine:
- `metadata.spacing`: voxels spacing (a reference to `metadata.affine.spacing`) 
- `metadata.ornt`: the current image orientation (depends on the coordinate system `coord_sys`)

All these properties can be viewed easily in the console:
```python
>>> import medio
>>> array, metadata = medio.read_img('avg152T1_LR_nifti.nii.gz', header=False)
>>> print(metadata)
Affine:
[[  -2.    0.    0.   90.]
 [   0.    2.    0. -126.]
 [   0.    0.    2.  -72.]
 [   0.    0.    0.    1.]]
Spacing: [2. 2. 2.]
Coordinate system: nib
Orientation: LAS
Original orientation: LAS
Header: None
```
The MetaData method `metadata.is_right_handed_ornt()` checks for a right handed orientation 
according to the determinant of the direction matrix (`metadata.affine.direction`). This method can 
be useful before saving a dicom file or series, which should have a right-handed orientation.

The method `clone` clones the metadata object, `convert` converts the metadata in-place to the 
given coordinate system.

#### Orientation
The orientation of a 3d image is string of length 3 that is derived from its affine and coordinate 
system (the convention). It denotes along which physical axis we move when we increase a single 
index out of `i, j, k` in the expression `np_image[i, j, k]`.

For example, 'RAS' orientation in itk:
- **R**ight to Left, **A**nterior to Posterior, **S**uperior to Inferior

'RAS' in nib - also 'RAS+':
- Left to **R**ight, Posterior to **A**nterior, Inferior to **S**uperior

Note that the conventions are opposite. For stability reasons, we use itk convention by default 
for `read_img`'s argument `desired_ornt`, although one can choose otherwise with the parameter 
`coord_sys`.

For further discussion see 
[NiBabel's image orientation documentation](
https://nipy.org/nibabel/image_orientation.html#image-voxel-orientation).

## Array and Metadata Operations
Some operations on an image affect also its metadata, for example resizing, rotations and cropping.

The class MedImg (`medio.medimg.medimg.MedImg`) holds an image array with its metadata, and 
supports some of these operations through the indexing syntax:
```python
>>> from medio.medimg.medimg import MedImg
>>> mimg = MedImg(np_image, metadata)
>>> new_mimg = mimg[:, 4:-4, ::3]
>>> print(new_mimg.metadata)
```
Ellipsis ('...') syntax is also supported. This indexing allows cropping and basic down-sampling, 
along with correct metadata update.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/RSIP-Vision/medio",
    "name": "medio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "medical-images,IO,itk,nibabel,pydicom",
    "author": "RSIP Vision",
    "author_email": "info@rsipvision.com",
    "download_url": "https://files.pythonhosted.org/packages/d6/ba/7130615b247a79446d02e4005fa46daf49c9dc30245fc8ec3bba41cafbce/medio-0.4.2.tar.gz",
    "platform": null,
    "description": "[![Python version](\nhttps://img.shields.io/pypi/pyversions/medio.svg)](\nhttps://img.shields.io/pypi/pyversions/medio.svg)\n[![PyPI version](\nhttps://badge.fury.io/py/medio.svg)](\nhttps://badge.fury.io/py/medio)\n# medio\n\n**Medical images I/O python package**\n\nThis package unifies the io engines of itk, nibabel, and pydicom (including dicom-numpy) packages \nin a simple and comprehensive interface.\n\nIt includes conversion between the metadata conventions, reorientations, affine matrix computation \nfor itk and pydicom and saving dicom series or file.\n\n# Installation\nFirst, make sure you have the latest pip version (better to close PyCharm or any other program that \nuses the environments):\n```\n(<env-name>) >pip install -U pip\n```\nInstall *medio* with:\n```\n(<env-name>) >pip install -U medio\n```\nThis will install the medio python package and its dependencies in your environment.\n\n### Requirements\nThe dependencies are:\n- python (at least 3.6)\n- numpy\n- itk\n- nibabel\n- pydicom\n- dicom-numpy\n\nA conda environment .yml file is in the project's root.\nSome dicom images may require installation of additional packages, gdcm for example.\n\n# Usage\nThere are 3 main functions in medio: `read_img`, `save_img` and `save_dir`.\n```python\nfrom medio import read_img, save_img\n# read a dicom series from a folder\narray, metadata = read_img('data/dicom-folder/', desired_ornt='IAR')\n# do your stuff and save in any format\nsave_img('ct.nii.gz', array, metadata, backend='nib')\n```\n\n# Documentation\n## Reading and Saving Images\n\n### read_img\n`medio.read_img(input_path, desired_ornt=None, backend=None, dtype=None, header=False, \nchannels_axis=-1, coord_sys='itk', **kwargs)`\n- `input_path`: *path-like*<br>\n  Path for the data to be read (str or pathlib.Path object for example). It can be a file or a \n  folder (in the case of a dicom series). It is the only required parameter.\n  If the input path is a folder, it should contain a single dicom series. \n  If there is more than a single series, the optional parameter `series` can help. \n- Returns: *array, metadata*<br>\n  array of type *numpy.ndarray* and metadata of type *medio.MetaData*. The first is a numpy array \n  of the image, and the second is a metadata object of the image (see [MetaData](#metadata) class \n  documentation).\n\nOptional parameters:\n- `desired_ornt`: *orientation string or None*<br>\n  The desired orientation of the returned image array, e.g. 'RAI'. If None, no reorientation is \n  performed.\n  The desired orientation is in the standard defined by `coord_sys` (itk by default). \n  See also [Orientation](#orientation)).<br>\n  If `desired_ornt` is the same as the original image's orientation, no reorientation is performed.\n- `backend`: *'nib', 'itk', 'pydicom', 'pdcm', or None*<br>\n  The backend IO engine to use: 'nib' (nibabel), 'itk' or 'pydicom' (also 'pdcm'). If None, the \n  backend is chosen automatically: 'nib' for nifti files (e.g. '.nii' or '.nii.gz' suffix), \n  otherwise 'itk'.\n- `dtype`: *numpy data-type or None*<br>\n  If not None, equivalent to `array.astype(dtype)` on the returned image array.\n- `header`: *bool*<br>\n  If True, the returned metadata includes also a `metadata.header` attribute that stores the raw \n  metadata of the file as a dictionary.<br>\n  This is not implemented for series of files (folder `input_path`), and not used during saving.\n- `channels_axis`: *int or None*<br>\n  If not None and the image has more than a single channel / component (e.g. RGB or RGBA), the \n  channels axis is `channels_axis`. If None, the backend's original convention is used.\n- `coord_sys`: *'itk', 'nib', or None*<br>\n  The coordinate system (or convention) of the `desired_ornt` parameter and the returned metadata.\n  None means that the backend will determine `coord_sys`, but it can lead to a backend-dependent \n  array and metadata.\n\n`**kwargs` are additional per-backend optional parameters:\n- 'itk' backend:\n  - `pixel_type=itk.SS`: *itk pixel-type or None*<br>\n    Itk pixel type of the image file/folder. The default value is int16 (`itk.SS` - Signed Short). \n    Other common pixel types are: `itk.UC` - uint8, `itk.US` - uint16.<br>\n    You can use the function `itk.ctype` in order to convert C-types to itk types. For example:<br>\n    `itk.ctype('unsigned short') == itk.US`\n  - `fallback_only=True`: *bool*<br>\n    If True, the pixel type is automatically found and if failed then `pixel_type` is used \n    (`pixel_type` must not be None in this case).<br>\n    Note: if `itk.imread(input_path)` fails, using `fallback_only=True` will result in a slightly \n    inferior performance. If you know what is pixel-type of the image beforehand, you can set it \n    with `pixel_type` and use `fallback_only=False`.\n  - `series=None`: *str, int or None*<br>\n    If `input_path` is a directory that contains multiple dicom series, selecting a specific one is \n    possible with the `series` argument. It can be the exact series instance UID (str), an int \n    between 0 and n-1, where n is the number of series in the directory, or None.<br>\n    If `series` is None and there are multiple series in the directory, a detailed error message \n    is raised.\n\n- 'pydicom' backend\n  - `globber='*'`: *str*<br>\n    Relevant for a directory - glob pattern for selecting the series files (all the files in the \n    directory by default).\n  - `allow_default_affine=False`: *bool*<br>\n    Relevant for a multiframe dicom file - if True and the dicom misses some physical tags for the \n    affine calculation, use a default affine value.\n  - `series=None`: *str, int or None*<br>\n    The counterpart of `series` in itk backend, see the explanation above.\n\n### save_img\n`medio.save_img(filename, np_image, metadata, use_original_ornt=True, backend=None, dtype=None, \nchannels_axis=None, mkdir=False, parents=False, **kwargs)`\n- `filename`: *path-like*<br>\n  The file to be saved, including the format suffix.\n- `np_image`: *numpy.ndarray*<br>\n  The image array.\n- `metadata`: *medio.MetaData*<br>\n  The corresponding metadata, from `medio.read_img` for example. In the absence of a known \n  metadata, a default one can be constructed with `medio.MetaData(np.eye(4))`.\n\nOptional parameters:\n- `use_original_ornt`: *bool*<br> \n  Whether to save in the original orientation stored in `metadata.orig_ornt` or not.\n- `backend`: *'nib', 'itk' or None*<br>\n  The backend to use: 'nib' or 'itk'. If None, 'nib' is chosen for nifti files and 'itk' otherwise.\n- `dtype`: *numpy data-type or None*<br>\n  If not None, equivalent to passing `np_image.astype(dtype)`. Note that not every dtype is \n  supported in saving, so make sure what is the dtype of the image array you want to save.\n- `channels_axis`: *int or None*<br>\n  If not None, the image has channels (e.g. RGB) along the axis `channels_axis` of `np_image`.\n- `mkdir`: *bool*<br>\n  If True, creates the directory of `filename`.\n- `parents`: *bool*<br>\n  To be used with `mkdir=True`. If True, creates also the parent directories. \n\n'itk' backend optional parameters (`**kwargs`):\n- `allow_dcm_reorient=False`: *bool*<br>\n  When saving a dicom file ('.dcm' or '.dicom' suffix) the image orientation should be right-handed.\n  If it is left-handed, the image can be reoriented to a right-handed orientation by setting this \n  parameter to True, which flips the last axis direction.\n- `compression=False`: *bool*<br>\n  Whether to use compression in itk writer. Using a '.nii.gz' suffix in `filename` also compresses\n  the image.\n\n### save_dir\n`medio.save_dir(dirname, np_image, metadata, use_original_ornt=True, dtype=None, channels_axis=None,\nparents=False, exist_ok=False, allow_dcm_reorient=False, **kwargs)`\n\nSave a 3d numpy array `np_image` as a dicom series of 2d slices in the directory `dirname` (itk \nbackend).\n\n- `dirname`: *path-like*<br>\n  The directory to save the files in (str or pathlib.Path). If it exists, it must be empty (unless \n  `exist_ok` is True).\n\nThe other parameters: `np_image`, `metadata`, `use_original_ornt`, `dtype`, `channels_axis`, \n`parents` and `allow_dcm_reorient` are equivalent to those of [save_img](#save_img).\n\nAdditional optional parameters (`**kwargs`):\n- `exist_ok`: *bool*<br>\n  If True, non-empty existing directory will not raise an error.\n- `pattern='IM{}.dcm'`: *str*<br>\n  Pattern for the filenames to save, including a placeholder ('`{}`') for the slice number.\n  For example, one can use: `pattern={:03d}`.\n- `metadata_dict=None`: *dict or None*<br>\n  Dictionary of metadata for adding tags or overriding the default values. For example, \n  `metadata_dict={'0008|0060': 'US'}` will override the default 'CT' modality and set it to 'US' \n  (ultrasound).\n\n## Metadata Objects\n### Affine\n`medio.Affine`\n\nThe affine of an image is a transformation between the index space of the array to the physical 3d \nspace. The Affine class is a subclass of numpy.ndarray with some special properties (attributes): \n`spacing`, `origin`, and `direction`, which can be accessed and set. The method `index2coord` maps \nthe indices to the physical space, `clone` clones the affine.\n\nThis class includes also some static methods for affine construction from its components (spacing, \norigin and direction) and also the inverse methods for getting the spacing, origin and direction \nmatrix from a general affine matrix.\n\nFor a mathematical explanation about the affine matrix see \n[NiBabel's affine documentation](\nhttps://nipy.org/nibabel/coordinate_systems.html#the-affine-matrix-as-a-transformation-between-spaces).\n\nSome usage examples:\n```python\n>>> import numpy as np\n>>> from medio import Affine\n>>> affine1 = Affine(np.eye(4))\n>>> affine2 = Affine(direction=np.eye(3), spacing=[0.33, 1, 0.33], origin=[-90.3, 10, 1.44])\n>>> index = [4, 0, 9]\n>>> coord = affine2.index2coord(index)\n>>> print(coord)\n[-88.98  10.     4.41]\n```\n\n### MetaData\n`medio.MetaData`\n\nTogether with the image's numpy array, the MetaData object is a necessary component for the I/O \nfunctions.\n\nA MetaData object 'metadata' is mainly comprised of:\n- `metadata.affine`: the affine (of class Affine)\n- `metadata.coord_sys`: coordinate system ('itk' or 'nib') \n- `metadata.orig_ornt`: the original orientation of the image (used for saving)\n- `metadata.header`: a dictionary that includes additional metadata properties when `header=True` \n  in `read_img`, otherwise None\n\nOther properties of the metadata are derived from the affine:\n- `metadata.spacing`: voxels spacing (a reference to `metadata.affine.spacing`) \n- `metadata.ornt`: the current image orientation (depends on the coordinate system `coord_sys`)\n\nAll these properties can be viewed easily in the console:\n```python\n>>> import medio\n>>> array, metadata = medio.read_img('avg152T1_LR_nifti.nii.gz', header=False)\n>>> print(metadata)\nAffine:\n[[  -2.    0.    0.   90.]\n [   0.    2.    0. -126.]\n [   0.    0.    2.  -72.]\n [   0.    0.    0.    1.]]\nSpacing: [2. 2. 2.]\nCoordinate system: nib\nOrientation: LAS\nOriginal orientation: LAS\nHeader: None\n```\nThe MetaData method `metadata.is_right_handed_ornt()` checks for a right handed orientation \naccording to the determinant of the direction matrix (`metadata.affine.direction`). This method can \nbe useful before saving a dicom file or series, which should have a right-handed orientation.\n\nThe method `clone` clones the metadata object, `convert` converts the metadata in-place to the \ngiven coordinate system.\n\n#### Orientation\nThe orientation of a 3d image is string of length 3 that is derived from its affine and coordinate \nsystem (the convention). It denotes along which physical axis we move when we increase a single \nindex out of `i, j, k` in the expression `np_image[i, j, k]`.\n\nFor example, 'RAS' orientation in itk:\n- **R**ight to Left, **A**nterior to Posterior, **S**uperior to Inferior\n\n'RAS' in nib - also 'RAS+':\n- Left to **R**ight, Posterior to **A**nterior, Inferior to **S**uperior\n\nNote that the conventions are opposite. For stability reasons, we use itk convention by default \nfor `read_img`'s argument `desired_ornt`, although one can choose otherwise with the parameter \n`coord_sys`.\n\nFor further discussion see \n[NiBabel's image orientation documentation](\nhttps://nipy.org/nibabel/image_orientation.html#image-voxel-orientation).\n\n## Array and Metadata Operations\nSome operations on an image affect also its metadata, for example resizing, rotations and cropping.\n\nThe class MedImg (`medio.medimg.medimg.MedImg`) holds an image array with its metadata, and \nsupports some of these operations through the indexing syntax:\n```python\n>>> from medio.medimg.medimg import MedImg\n>>> mimg = MedImg(np_image, metadata)\n>>> new_mimg = mimg[:, 4:-4, ::3]\n>>> print(new_mimg.metadata)\n```\nEllipsis ('...') syntax is also supported. This indexing allows cropping and basic down-sampling, \nalong with correct metadata update.\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Medical images I/O Python package",
    "version": "0.4.2",
    "split_keywords": [
        "medical-images",
        "io",
        "itk",
        "nibabel",
        "pydicom"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3402a0b7c5621e5be6cfb7ecac16d2f5",
                "sha256": "bd5da638284fe74f636470f93bd7f1b3e85f5a82845c6f30deb416ab2589e483"
            },
            "downloads": -1,
            "filename": "medio-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3402a0b7c5621e5be6cfb7ecac16d2f5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 34548,
            "upload_time": "2022-12-04T05:54:33",
            "upload_time_iso_8601": "2022-12-04T05:54:33.871246Z",
            "url": "https://files.pythonhosted.org/packages/36/cc/e223037a34d44ead4fb41288609dff6cb73c745a1e47a283f47881e4c62c/medio-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "716fc2ade7e7c057bf4d140668dbc8fd",
                "sha256": "a62054ccaea20240d3864d04e4bff03c8abf1a3189419d8a2db3432821678669"
            },
            "downloads": -1,
            "filename": "medio-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "716fc2ade7e7c057bf4d140668dbc8fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 30764,
            "upload_time": "2022-12-04T05:54:36",
            "upload_time_iso_8601": "2022-12-04T05:54:36.293567Z",
            "url": "https://files.pythonhosted.org/packages/d6/ba/7130615b247a79446d02e4005fa46daf49c9dc30245fc8ec3bba41cafbce/medio-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-04 05:54:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "RSIP-Vision",
    "github_project": "medio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "medio"
}
        
Elapsed time: 0.29095s