-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverview.py
45 lines (37 loc) · 1.15 KB
/
overview.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
from util import *
from setting import *
df = pd.read_csv(join(DS_dir,'stage_1_train_labels.csv'))
# print('\nShow training label: Does not have pneumonia')
# print(df.iloc[0])
# print('\nShow training label: Have pneumonia')
# print(df.iloc[4])
patientId = df['patientId'][0]
dcm_file = join(DS_dir ,'stage_1_train_images/%s.dcm' % patientId)
dcm_data = pydicom.read_file(dcm_file)
print('\n##Sample dcm data')
print(dcm_data)
im = dcm_data.pixel_array
print('\n## Type of image')
print(type(im))
print('\n## Data type of image')
print(im.dtype)
print('\n## Shape of image')
print(im.shape)
pylab.figure()
pylab.imshow(im, cmap=pylab.cm.gist_gray)
pylab.show()
pylab.axis('off')
parsed = parse_data(df)
print('\n## Sample parsed item')
print(parsed['00436515-870c-4b36-a041-de91049b9ab4'])
draw(parsed['00436515-870c-4b36-a041-de91049b9ab4'])
df_detailed = pd.read_csv(join(DS_dir, 'stage_1_detailed_class_info.csv'))
patientId = df_detailed['patientId'][0]
draw(parsed[patientId])
summary = {}
for n, row in df_detailed.iterrows():
if row['class'] not in summary:
summary[row['class']] = 0
summary[row['class']] += 1
print('\n##Summary')
print(summary)