gll89的个人博客分享 http://blog.sciencenet.cn/u/gll89

博文

DICOM & its operation with python

已有 1750 次阅读 2019-5-7 13:20 |个人分类:Python|系统分类:科研笔记

  1. we define the standard DICOM patient-based coordinate system: x, y and z axes.

    If Anatomical Orientation Type is absent, the x-axis is increasing to the left hand side of the patient. The y-axis is increasing to the posterior side of the patient. The z-axis is increasing toward the head of the patient.

    In a way, it's funny to call this the 'patient-based' coordinate system

  2. The (i, j), columns, rows in DICOM 

    By voxel coordinates, we mean coordinates of form (r,c,s)(r,c,s) - the row, column and slice indices 


  3. Packages

    (1) NiBabel:   pip install nibabel

         This package provides read +/- write access to some common medical and neuroimaging file formats, including: ANALYZE (plain, SPM99, SPM2 and later), GIFTINIfTI1NIfTI2MINC1MINC2MGH and ECAT as well as Philips PAR/REC. We can read and write FreeSurfer geometry, annotation and morphometry files. There is some very limited support for DICOM. NiBabel is the successor of PyNIfTI

         To deal with DICOM files, NiBabel use excellent PyDICOM as its back-end for reading DICOM.

          https://nipy.org/nibabel/

    (2) Pydicom:  pip install -U pydicom

           https://pydicom.github.io/pydicom/stable/base_element.html#dataset

    (3) DICOM-Numpy: pip install dicom_numpy

          This python module provides a set of utilities for extracting data contained in DICOM files into Numpy ndarrays. It is a higher-level library that builds on the excellent lower-level pydicom library.

          The DICOM standard stores MR, CT, and PET scans as a series of images saved in a separate files. A common task is to combine all of the images that make up a single 3D image into a single scan.   The function that performs this task is combine_slices. Since this library builds on pydicom, combine_slices takes an list of pydicom datasets

    Example:

import dicom
import dicom_numpy
def extract_voxel_data(list_of_dicom_files):
    datasets = [dicom.read_file(f) for f in list_of_dicom_files]
    try:
        voxel_ndarray, ijk_to_xyz = dicom_numpy.combine_slices(datasets)
    except dicom_numpy.DicomImportException as e:
        # invalid DICOM data
        raise
    return voxel_ndarray

        https://dicom-numpy.readthedocs.io/en/latest/


4. Display 3D images

    (1) mpl_toolkits.mplot3D.Axes3D

         安装matplotlib后,即可使用

         https://terbium.io/2017/12/matplotlib-3d/



https://blog.sciencenet.cn/blog-1969089-1177617.html

上一篇:[转载][Python] 异常try-except-else,try-finally,raise
下一篇:[转载]__getitem__ in python
收藏 IP: 60.191.2.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-23 23:56

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部