如何提取/查看多帧DICOM文件的所有帧? [英] How to extract/view all frames of a multi-frame DICOM file?

查看:1838
本文介绍了如何提取/查看多帧DICOM文件的所有帧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用以下代码查看dicom文件:

I know I can view a dicom file using following code:

import dicom
from dicom.contrib.pydicom_PIL import show_PIL

f = "CT-MONO2-8-abdo.dcm"
ds = dicom.read_file(f, force=True)
show_PIL(ds)

但是,如何从多帧DICOM文件中提取和查看所有帧?我尝试使用上面的代码但出现以下错误:

However, how can I extract and view all frames from a multi-frame DICOM file? I tried using above code but got following error:

File "/home/auser/.local/lib/python3.5/site-packages/dicom/dataset.py", line 399, in _get_pixel_array
  raise NotImplementedError("Pixel Data is compressed in a format pydicom does not yet handle. Cannot return array")
NotImplementedError: Pixel Data is compressed in a format pydicom does not yet handle. Cannot return array

我曾尝试使用位于 http://www.barre.nom.fr/medical/samples/ 。像素大小等可用于这些文件。

I had tried with some multi-frame files located at http://www.barre.nom.fr/medical/samples/. The pixel size etc are available for these files.

如何提取和/或查看多帧DICOM文件的不同帧?

How can I extract and/or view different frames of a multi-frame DICOM file?

编辑:以下命令使用gdcm在Linux上运行以将这些转换为未压缩文件:

Following command using gdcm works on Linux to convert these to uncompressed file:

$ gdcmconv --raw compressed.dcm uncompressed.dcm

(我使用了 http:// www。提取后的barre.nom.fr/medical/samples/files/US-PAL-8-10x-echo.gz 文件。

这是通过上面的python代码读取,但只显示第一帧。如何提取和查看其他框架?

This is then read by python code above but that shows only first frame. How can I extract and view other frames?

推荐答案

pydicom支持读取像素数据。请参阅文档。

pydicom supports reading pixel data. Refer this documentation.


pydicom在解释DICOM数据时往往懒惰。例如,
默认情况下它不对像素数据做任何事情,除了在原始
字节中读取:

pydicom tends to be "lazy" in interpreting DICOM data. For example, by default it doesn’t do anything with pixel data except read in the raw bytes:

import dicom
ds=dicom.read_file("MR_small.dcm")
ds.PixelData
'\x89\x03\xfb\x03\xcb\x04\xeb\x04\xf9\x02\x94\x01\x7f ...
...


关于pixel_array

About pixel_array


Dataset的一个名为pixel_array的属性提供更有用的像素
未压缩图像的数据。 NumPy数字包必须在您的系统上安装
才能使用此属性,因为pixel_array
返回NumPy数组:

A property of Dataset called pixel_array provides more useful pixel data for uncompressed images. The NumPy numerical package must be installed on your system to use this property, because pixel_array returns a NumPy array:

import dicom
ds=dicom.read_file("MR_small.dcm")
ds.pixel_array
array([[ 905, 1019, 1227, ...,  302,  304,  328],
       [ 628,  770,  907, ...,  298,  331,  355],
       [ 498,  566,  706, ...,  280,  285,  320],
       ...,
       [ 334,  400,  431, ..., 1094, 1068, 1083],
       [ 339,  377,  413, ..., 1318, 1346, 1336],
       [ 378,  374,  422, ..., 1369, 1129,  862]], dtype=int16)
ds.pixel_array.shape
(64, 64)


文档还解释了如何在 http://pydicom.readthedocs.io/en/stable/viewing_images.html

正如错误消息中所解释的那样(以及评论中的@kritzel_sw)pydicom会这样做ot还支持源图像的传输语法。在尝试提取帧之前,使用其他工具更改传输语法。

As explained in error message (and by @kritzel_sw in comment) the pydicom does not support the Transfer Syntax of source image yet. Change the Transfer Syntax using some other tool before attempting to extract the frames.

另一个有用的Rony博客 http://dicomiseasy.blogspot.in/2012/08/chapter-12-pixel-data.html

Another helpful blog of Rony http://dicomiseasy.blogspot.in/2012/08/chapter-12-pixel-data.html

同时查看 Stack Overflow问题;它是旧版本,但可能会有所帮助。

Also check this Stack Overflow question; it is about old version but may be helpful.

这篇关于如何提取/查看多帧DICOM文件的所有帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆