服务器之家

服务器之家 > 正文

python 读取DICOM头文件的实例

时间:2021-02-19 00:06     来源/作者:sunyao_123

用dicompyler软件打开dicom图像,头文件如图所示:

python 读取DICOM头文件的实例

当然也可以直接读取:

python" id="highlighter_110877">
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
ds = dicom.read_file('h:\data\data\\21662\\2.16.840.1.113662.2.0.105002416.1489146183.701\ct\\ct#0#21662#e7ab693d.dcm')
print ds
>>
(0008, 0008) image type       cs: ['original', 'secondary', 'axial']
(0008, 0016) sop class uid      ui: ct image storage
(0008, 0018) sop instance uid     ui: 2.16.840.1.113662.2.0.105002416.1489146183.501.0
(0008, 0020) study date       da: '20170310'
(0008, 0021) series date       da: '20170310'
(0008, 0023) content date      da: '20060505'
(0008, 0030) study time       tm: '1942'
(0008, 0031) series time       tm: '1942'
(0008, 0033) content time      tm: ''
(0008, 0050) accession number     sh: '63071'
(0008, 0060) modality       cs: 'ct'
(0008, 0070) manufacturer      lo: 'nomos'
(0008, 0090) referring physician's name   pn: ''
(0008, 1010) station name      sh: ''
(0008, 1090) manufacturer's model name   lo: 'corvus 6.4'
(0010, 0010) patient's name      pn: '*m32-2^chenjun^^^'
(0010, 0020) patient id       lo: '21662'
(0010, 0030) patient's birth date    da: ''
(0010, 0040) patient's sex      cs: ''
(0018, 0050) slice thickness      ds: '4.75'
(0018, 0060) kvp         ds: '0'
(0018, 1020) software version(s)     lo: 'corvus 6.4'
(0018, 5100) patient position     cs: 'hfs'
(0020, 000d) study instance uid     ui: 2.16.840.1.113662.2.0.105002416.1489146183.701
(0020, 000e) series instance uid     ui: 2.16.840.1.113662.2.0.105002416.1489146183.501
(0020, 0010) study id       sh: '63071'
(0020, 0011) series number      is: '0'
(0020, 0012) acquisition number     is: '0'
(0020, 0013) instance number      is: '0'
(0020, 0020) patient orientation     cs: ['l', 'p']
(0020, 0032) image position (patient)   ds: ['0.73437356948853', '0', '3.25']
(0020, 0037) image orientation (patient)   ds: ['1', '0', '0', '0', '1', '0']
(0020, 0052) frame of reference uid    ui: 2.16.840.1.113662.2.0.105002416.1489146183.601
(0020, 0060) laterality       cs: ''
(0020, 1040) position reference indicator  lo: ''
(0020, 1041) slice location      ds: '3.25'
(0028, 0002) samples per pixel     us: 1
(0028, 0004) photometric interpretation   cs: 'monochrome2'
(0028, 0010) rows        us: 330
(0028, 0011) columns        us: 339
(0028, 0030) pixel spacing      ds: ['0.734375', '0.734375']
(0028, 0100) bits allocated      us: 16
(0028, 0101) bits stored       us: 12
(0028, 0102) high bit       us: 11
(0028, 0103) pixel representation    us: 0
(0028, 1052) rescale intercept     ds: '-1024'
(0028, 1053) rescale slope      ds: '1'
(7fe0, 0010) pixel data

发现一套图的第一张和最后一张的slice thickness往往和中间层的值是不同的。

?
1
2
3
path = 'h:\data\data\\21662\\2.16.840.1.113662.2.0.105002416.1489146183.701\ct\\a.dcm'
slices = dicom.read_file(path)
spacing = slices.pixelspacing

读取头文件信息方法:

slices.上图头文件中的name列。

这时要注意的是,name大小写不变,去掉空格,去掉符号,比如括号。

举例:

?
1
2
3
origin = slices.softwareversions
print origin
>>corvus 6.4
?
1
2
3
spacing = slices[1].pixelspacing
print spacing
>>['0.734375', '0.734375']

以上这篇python 读取dicom头文件的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/sunyao_123/article/details/73655897

标签:

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
yue是什么意思 网络流行语yue了是什么梗
yue是什么意思 网络流行语yue了是什么梗 2020-10-11
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
返回顶部