-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
112 lines (94 loc) · 3.22 KB
/
main.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#! python 2
from windows import window
from makevolume import makevolume
import vtk
def createrendering(filename, volumeval, volumeopacities, volumecolors, volumecolorvalues,
isoctf, isovcolorvals, isovals, isoopacity, depthpeel = False, roi = False, extractedroi = None):
if(roi == True):
read = extractedroi
elif(roi == False):
read = vtk.vtkDataSetReader()
read.SetFileName(filename)
volumelist = []
isosurfacelist = []
volume = makevolume()
values = volumeval
opacities = volumeopacities
if (len(volumeval)!= 0):
volume.volumeopacity(values, opacities)
colval = volumecolors
rgb = volumecolorvalues
volume.volumecolortransfer(colval, rgb)
volume.createvolumeproperties(0.4, 0.6, 0.2)
volumelist.append(volume.mapvolume(read.GetOutputPort()))
isocolv = isoctf
isorgb = isovcolorvals
volume.isocolortransfer(isocolv, isorgb)
isovalueandopacitylist = zip(isovals,isoopacity)
for each in isovalueandopacitylist:
isosurfacelist.append(volume.generateisosurface(each[0], each[1],read.GetOutputPort()))
newWindow = window(isosurfacelist, volumelist)
newWindow.createWindow(depthpeel, roi)
mrcp = {'filename': 'mrcp.vtk',
'volumeval': [2042.37, 4066.5, 7130.05, 11561.6, 13348.3],
'volumeopacities': [ 0, 1],
'volumecolors': [1312.95, 3902.38, 7184.75],
'volumecolorvalues': [(220, 195, 172), (204, 153, 102), (172, 204, 135)],
'isoctf': [],
'isovcolorvals': [],
'isovals': [],
'isoopacity': [],
'depthpeel': False }
contrastcombined = {'filename': 'fatsat.vtk',
'volumeval': [500, 800, 1734],
'volumeopacities': [0, .2,0],
'volumecolors': [2221, 2336, 3550],
'volumecolorvalues': [(220, 195, 172), (204, 153, 102), (172, 204, 135)],
'isoctf': [0, 1734],
'isovcolorvals': [(59, 76, 192),(180, 4, 38)],
'isovals': [800],
'isoopacity': [0.5],
'depthpeel': True }
contrastvol = {'filename': 'fatsat.vtk',
'volumeval': [500, 800, 1734],
'volumeopacities': [0, 1,0],
'volumecolors': [2221, 2336, 3550],
'volumecolorvalues': [(220, 195, 172), (204, 153, 102), (172, 204, 135)],
'isoctf': [],
'isovcolorvals': [],
'isovals': [],
'isoopacity': [],
'depthpeel': True }
contrastiso = {'filename': 'fatsat.vtk',
'volumeval': [],
'volumeopacities': [],
'volumecolors': [],
'volumecolorvalues': [],
'isoctf': [0, 1734],
'isovcolorvals': [(204, 153, 102),(204, 153, 102)],
'isovals': [800],
'isoopacity': [0.8],
'depthpeel': True }
read = vtk.vtkDataSetReader()
read.SetFileName('isovis.vtk')
extract = vtk.vtkExtractVOI()
extract.SetVOI(0,500, 200,260,0,150)
extract.SetSampleRate(1, 1, 1)
extract.SetInputConnection(read.GetOutputPort())
fullbody = {'filename': None,
'volumeval': [-22.66, -15.69, -4.20, 40.12, 86.07, 254.15],
'volumeopacities': [0, .19, 0.7, 0, 0,0.83 ],
'volumecolors': [42.90,163.49, 277.64],
'volumecolorvalues': [(140, 67, 30), (234, 160, 30), (255, 255, 255)],
'isoctf': [],
'isovcolorvals': [],
'isovals': [],
'isoopacity': [],
'depthpeel': False,
'roi': True,
'extractedroi': extract}
createrendering(**contrastcombined)
createrendering(**contrastvol)
createrendering(**contrastiso)
createrendering(**mrcp)
createrendering(**fullbody)