-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewCandidates.py
99 lines (67 loc) · 2.12 KB
/
viewCandidates.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env python2.7
import os
import sys
import tables
import pandas
from mayavi import mlab
dataset_file = sys.argv[1]
df = pandas.read_csv(dataset_file, sep='\t')
path, file = os.path.split(dataset_file)
arrFile = os.path.join(path, 'resampled.h5')
#arrFile = os.path.join(path, 'resampledCarray.h5')
#arrFile = os.path.join('/data/datasets/luna/resampled.h5')
DB = tables.open_file(arrFile, mode='r')
images = DB.root.resampled
#from generators import prepVGGimages
for index, row in df.iterrows():
#data = transpose(data, (1, 2, 0))
if index<45: continue
imageNum = row['imgNum']
image = images[int(imageNum)]
#image = normalizeRange(image)
voxelC = row[['voxelZ', 'voxelY', 'voxelX']].as_matrix()
p = 64
crop = image[
int(voxelC[0] - p): int(voxelC[0] + p),
int(voxelC[1] - p): int(voxelC[1] + p),
int(voxelC[2] - p): int(voxelC[2] + p)
]
print crop.shape
print crop.min(), crop.mean(), crop.max()
#plot_nodule(crop)
print crop.min(), crop.mean(), crop.max()
print '\n\n'
'''
slice = crop[int(p/2),:,:]
slice = grey2color(slice)
imshow('image', slice*1)
waitKey(0)
#crash
'''
'''
mean attenuation of 21 cbenign was 37 +- 7 HU
mean attenuation of 42 malignant was 40 +- 8.7 HU
air: -1000
lung: -500
fat: -100 to -50
water: 0
CSF +15
Kidney +30
Blood +30 to +45
Muscle +10 to +40
Grey matter +37 to +45
White matter +20 to +30
Liver +40 to +60
Soft Tissue, Contrast +100 to +300
Bone +700 (cancellous bone) to +3000 (cortical bone)
'''
src = mlab.pipeline.scalar_field(crop)
mlab.pipeline.iso_surface(src, name='bone', contours=[500, 1200 ], opacity=1.0, color=(1,1,1))
mlab.pipeline.iso_surface(src, name='lung', contours=[-700, -600], opacity=0.3)
#mlab.pipeline.iso_surface(src, name='fat', contours=[-100, -50], opacity=0.3, color=(1,0.5,0))
#mlab.pipeline.iso_surface(src, name='other', contours=[50, 300], opacity=0.7, color=(0,1.0,0))
mlab.show(stop=False)
mlab.show_pipeline(engine=None, rich_view=True)
#response = raw_input("hit enter to continue or ctrl-c to quit")
#time.sleep(3)
# mlab.pipeline.iso_surface(src, contours=[s.max()-0.1*s.ptp(), ],)