-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpumcd.not_so_simple_example.py
82 lines (61 loc) · 2.52 KB
/
gpumcd.not_so_simple_example.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
import ctypes,numpy as np,os,math,time
from os import path
import gpumcd
import medimage as image
print('Start of program.')
sett = gpumcd.Settings("d:\\postdoc\\gpumcd_data")
print(sett.planSettings.goalSfom)
casedir = "d:\\postdoc\\analyses\\gpumcd_python"
ct_image=image.image(path.join(casedir,'ct.xdr'))
ct_image.ct_to_hu(1000,1)
ct_image.resample([3,3,3])
ct = gpumcd.CT(sett,ct_image) #for dicoms, dont set intercept,slope.
machfile = "d:/postdoc/gpumcd_data/machines/machine_van_sami/brentAgility.beamlets.gpumdt"
engine = gpumcd.Engine(sett,ct,machfile)
print('gpumcd init done.')
print (engine.lasterror())
start_time = time.time()
frame1size = 5
frame2size = 3
BeamFrames = gpumcd.make_c_array(gpumcd.BeamFrame,2)
BeamFrames[0]=gpumcd.BeamFrame(1)
BeamFrames[0].beamInfo[0].relativeWeight = 50
BeamFrames[0].beamInfo[0].isoCenter.x=0
BeamFrames[0].beamInfo[0].isoCenter.y=-20 #its below the back, so lets pull it up inside the patient
BeamFrames[0].beamInfo[0].isoCenter.z=0
BeamFrames[0].beamInfo[0].collimatorAngle.first=0
BeamFrames[0].beamInfo[0].collimatorAngle.second=0
BeamFrames[0].beamInfo[0].couchAngle.first=0
BeamFrames[0].beamInfo[0].couchAngle.second=0
BeamFrames[0].beamInfo[0].gantryAngle.first=0
BeamFrames[0].beamInfo[0].gantryAngle.second=0
BeamFrames[0].beamInfo[0].fieldMax.first=frame1size
BeamFrames[0].beamInfo[0].fieldMax.second=frame1size
BeamFrames[0].beamInfo[0].fieldMin.first=-frame1size
BeamFrames[0].beamInfo[0].fieldMin.second=-frame1size
BeamFrames[1]=gpumcd.BeamFrame(1)
BeamFrames[1].beamInfo[0].relativeWeight = 50
BeamFrames[1].beamInfo[0].isoCenter.x=0
BeamFrames[1].beamInfo[0].isoCenter.y=-20
BeamFrames[1].beamInfo[0].isoCenter.z=0
BeamFrames[1].beamInfo[0].collimatorAngle.first=0
BeamFrames[1].beamInfo[0].collimatorAngle.second=0
BeamFrames[1].beamInfo[0].couchAngle.first=0
BeamFrames[1].beamInfo[0].couchAngle.second=0
BeamFrames[1].beamInfo[0].gantryAngle.first=90
BeamFrames[1].beamInfo[0].gantryAngle.second=90
BeamFrames[1].beamInfo[0].fieldMax.first=frame2size
BeamFrames[1].beamInfo[0].fieldMax.second=frame2size
BeamFrames[1].beamInfo[0].fieldMin.first=-frame2size
BeamFrames[1].beamInfo[0].fieldMin.second=-frame2size
print('executing simulation...')
retval = engine.__gpumcd_object__.execute_beamlets(
*gpumcd.c_array_to_pointer(BeamFrames,True),
sett.planSettings
)
end_time = time.time()
print (engine.lasterror())
print("runtime gpumcd:",end_time-start_time)
engine.set_dose()
engine.ct.dosemap.saveas(path.join(casedir,'dose.xdr'))
engine.ct.dosemap.saveas(path.join(casedir,'dose.mhd'))