forked from adamtiger/LHYP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_usage.py
39 lines (33 loc) · 1.21 KB
/
example_usage.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
# Reads the sa folder wiht dicom files and contours
# then draws the contours on the images.
from con_reader import CONreaderVM
from dicom_reader import DCMreaderVM
from con2img import draw_contourmtcs2image as draw
image_folder = '/media/adambudai/Storage/heartdata/hypertrophy/cleanready/10635813AMR806/sa/images'
con_file = '/media/adambudai/Storage/heartdata/hypertrophy/cleanready/10635813AMR806/sa/contours.con'
# reading the dicom files
dr = DCMreaderVM(image_folder)
# reading the contours
cr = CONreaderVM(con_file)
contours = cr.get_hierarchical_contours()
# drawing the contours for the images
for slc in contours:
for frm in contours[slc]:
image = dr.get_image(slc, frm) # numpy array
cntrs = []
rgbs = []
for mode in contours[slc][frm]:
# choose color
if mode == 'ln':
rgb = [1, 0, 0]
elif mode == 'lp':
rgb = [0, 1, 0]
elif mode == 'rn':
rgb = [1, 1, 0]
else:
rgb = None
if rgb is not None:
cntrs.append(contours[slc][frm][mode])
rgbs.append(rgb)
if len(cntrs) > 0:
draw(image, cntrs, rgbs)