pydicom读取dicom文件报错
之前采用pydicom读取dicom文件一切都很正常,不过最近读取一批数据的时候,会报错
读取代码
file = pydicom.read_file(filepath)
data = file.pixel_array
问题就出在pixel_array这个属性上,报错如下
OSError Traceback (most recent call last)
c:\python35\lib\site-packages\pydicom\pixel_data_handlers\pillow_handler.py in get_pixeldata(dicom_dataset)
fio = io.BytesIO(pixel_data)
--> decompressed_image = Image.open(fio)
except IOError as e: c:\python35\lib\site-packages\PIL\Image.py in open(fp, mode)
raise IOError("cannot identify image file %r"
-> % (filename if filename else fp)) OSError: cannot identify image file <_io.BytesIO object at 0x000002418FC85CA8> During handling of the above exception, another exception occurred: NotImplementedError Traceback (most recent call last)
<ipython-input--c00f3f09682d> in <module>()
----> file.pixel_array c:\python35\lib\site-packages\pydicom\dataset.py in pixel_array(self)
The Pixel Data (7FE0,) as a NumPy ndarray.
"""
--> self.convert_pixel_data()
return self._pixel_array c:\python35\lib\site-packages\pydicom\dataset.py in convert_pixel_data(self)
) --> raise last_exception def decompress(self): c:\python35\lib\site-packages\pydicom\dataset.py in convert_pixel_data(self)
try:
# Use the handler to get a 1D numpy array of the pixel data
--> arr = handler.get_pixeldata(self)
self._pixel_array = reshape_pixel_array(self, arr) c:\python35\lib\site-packages\pydicom\pixel_data_handlers\pillow_handler.py in get_pixeldata(dicom_dataset)
decompressed_image = Image.open(fio)
except IOError as e:
--> raise NotImplementedError(e.strerror)
UncompressedPixelData.extend(decompressed_image.tobytes())
except Exception: NotImplementedError: None
看到一篇博客https://blog.csdn.net/inter_peng/article/details/74370306与我的问题类似,都出在dicom文件格式上面,这种压缩格式用pydicom读取不出来,采用SimpleITK可以解决
file = sitk.ReadImage(filepath)
data = sitk.GetArrayFromImage(file)
pydicom读取dicom文件报错的更多相关文章
- python3 读取dbf文件报错 UnicodeDecodeError: 'gbk' codec can't decode
在读取dbf文件时由于编码问题报错:UnicodeDecodeError: 'gbk' codec can't decode byte 0xb5 in position 49: incomplete ...
- 解决Requests中文乱码【有用】,读取htm文件 读取txt文件报错:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 0
打开这个网址https://blog.csdn.net/chaowanghn/article/details/54889835 python在open读取txt文件时,出现UnicodeDecodeE ...
- python中读取json文件报错,TypeError:the Json object must be str, bytes or bytearray,not ‘TextIOWrapper’
利用python中的json读取json文件时,因为错误使用了相应的方法导致报错:TypeError:the Json object must be str, bytes or bytearray,n ...
- 【Python】读取cvs文件报错:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 6: invalid start byte
现在有文件data.csv 文件编码格式为:ANSI data.csv 1|1|1|北京市 2|1|2|天津市 3|1|3|上海市 4|1|4|重庆市 5|1|5|石家庄市 6|2|5|唐山市 7|3 ...
- 读取xml文件报错:Invalid byte 2 of 2-byte UTF-8 sequence。
程序读取xml文件后,系统报“Invalid byte 2 of 2-byte UTF-8 sequence”错误,如何解决呢? 1.程序解析xml的时候,出现Invalid byte 2 of 2- ...
- python读取xml文件报错ValueError: multi-byte encodings are not supported
1.在使用python对xml文件进行读取时,提示ValueError: multi-byte encodings are not supported 很多贴子上说把xml的编码格式改为,就可以正常执 ...
- .net 读取Excel文件报错
错误内容 Microsoft Office Excel 不能访问文件“D:\WWWRoot\Website\Test\Excels\Test1.xls”. 可能的原因有: 1 文件名称或路径不存在. ...
- [解决问题] pandas读取csv文件报错OSError解决方案
python用padans.csv_read函数出现OSError: Initializing from file failed 问题:文件路径中存在中文 解决办法:修改文件路径名为全英文包括文件名
- python读取文件报错:pandas.errors.ParserError: iterator should return strings, not bytes (did you open the file in text mode?)
python 读取csv文件报错问题 import csv with open('E:/Selenium2script/DDT模块/test.csv','rb') as f: readers = cs ...
随机推荐
- 无网络安装mysql步骤
1. 先安装Microsoft Visual C++ 2010 运行环境,运行vcredist_x86.exe文件: 2. 安装MySql数据库,运行mysql-installer-community ...
- 处理事件冒泡,阻止默认事件工具类,兼容IE
//处理事件冒泡,阻止默认事件工具类,兼容IEvar eventUtil={ // 添加句柄 addHandler:function(element,type,handler){ if(element ...
- [Jenkins] 全局变量
http://www.360doc.com/content/14/1110/10/7811581_423993429.shtml https://wiki.jenkins.io/display/JEN ...
- javascript总结37:DOM:innerText 和 innerHTML
innerText 和 innerHTML 作用: 给双标签的元素设置内容/获取双标签里面的内容 不同点: innerText 只是用于获取文本或设置文本 innerHTML 不仅可以用于设置/获取文 ...
- CodeForces 682C Alyona and the Tree (树上DFS)
题意:给定一棵树,每个叶子有一个权值,每条边也有一个权值,现在让你删最少的结点,使得从任何结点出发到另一个结点的边上权值和都小于两个结点的权值. 析:很明显是DFS,不过要想找出最少的结点可能不太容易 ...
- 编写高质量代码改善C#程序的157个建议——建议90:不要为抽象类提供公开的构造方法
建议90:不要为抽象类提供公开的构造方法 首先,抽象类可以有构造方法.即使没有为抽象类指定构造方法,编译器也会为我们生成一个默认的protected的构造方法.下面是一个标准的最简单的抽象类: abs ...
- javascript事件坐标
clientX 鼠标在页面显示区域的坐标 screenX鼠标在显示屏幕上的坐标 layerX 鼠标相对于“触发事件的元素的层级关系中离该元素最近的,设置了position的父元素”的边界的位置,从bo ...
- c# MSMQ 消息队列
转 消息队列 http://www.cnblogs.com/anbylau2130/p/3469512.html
- SPARK_sql加载,hive以及jdbc使用
sql加载 格式 或者下面这种直接json加载 或者下面这种spark的text加载 以及rdd的加载 上述记得配置文件加入.mastrt("local")或者spark://m ...
- C#中使用Redis学习二 在.NET4.5中使用redis hash操作
上一篇>> 摘要 上一篇讲述了安装redis客户端和服务器端,也大体地介绍了一下redis.本篇着重讲解.NET4.0 和 .NET4.5中如何使用redis和C# redis操作哈希表. ...