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 ...
随机推荐
- Openssl smime命令
一.简介 S/MIME工具,用于处理S/MIME邮件,它能加密.解密.签名和验证S/MIME消息 二.语法 openssl smime [-encrypt] [-decrypt] [-sign] [- ...
- Win10系统SQL数据库安装
Win10系统MySQL数据库安装 1. 安装文件下载 下载地址: https://downloads.mysql.com/archives/community/ 下载版本: mysql-8.0.15 ...
- Redis初学笔记
1.官网概述 Redis is an open source (BSD licensed), in-memory data structure store, used as database, cac ...
- 白盒测试实践-任务进度-Day03
所使用静态代码检查工具 阿里巴巴Java开发代码检测IDE插件 小组成员 华同学.郭同学.覃同学.刘同学.穆同学.沈同学 任务进度 经过前期的学习和会议筹备,今天我们小组召开了代码评审会议.以下是今天 ...
- Perl 学习笔记-模块
1.Perl模块介绍 2个来源, 一个是随Perl发行版本一同打包, 只要安装了Perl就可以使用; 另一种是需要从CPAN上下载,自己安装. 寻找模块之前, 先检查系统上是否已经安装过了, ...
- Servlet 学习总结-1
JavaWeb应用程序中所有的请求-响应都是由Servlet来完成的.Servlet是Java Web的核心程序,所有的网址(请求-响应)都交给Servlet来处理. Servlet在Web应用中被映 ...
- Linq集合操作之Intersect,Except,Union源码分析
Linq集合操作之Intersect,Except,Union源码分析 linq的集合运算 常见的集合运算有哪些? 这三个扩展方法在我们实际使用中用的还是非常多的,而且这里还涉及到了“复杂度” 无算法 ...
- Linq特取操作之ElementAt,Single,Last,First源码分析
Linq特取操作之ElementAt,Single,Last,First源码分析 一:linq的特取操作 First/FirstOrDefault, Last/LastOrDefault, Eleme ...
- IntelliJ OpenCV 开发环境搭建
Windows下的IntelliJ + OpenCV开发环境搭建 基于IntelliJ IDEA 15 和 OpenCV 3.1.0 1. 在OpenCV官网下载OpenCV安装程序,双击解压到目标目 ...
- Windows解决多版本python执行pip3时出错AttributeError: module 'enum' has no attribute 'IntFlag'?
摘要: 本机装有python2.7和python3.6,执行pip和pip2时没有问题,执行pip3时提示: C:\Users\>pip3 Traceback (most recent call ...