-
Notifications
You must be signed in to change notification settings - Fork 1
/
lidcstats.py
46 lines (33 loc) · 967 Bytes
/
lidcstats.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
import os
from viewdicom import viewVolume, returnNumSlices
import matplotlib.pyplot as plt
import statistics
'''
root = r"D:\Documents\School\2020-21\CT\LIDC-IDRI"
slices = []
for path, subdirs, files in os.walk(root):
counter = 0
for name in files:
if (name[-3: ] == 'dcm'):
counter +=1
if (counter > 5):
slices.append(returnNumSlices(path))
print(path)
n, bins, patches = plt.hist(slices, 100, facecolor = 'blue', alpha = 0.8)
plt.show()
'''
slices = []
with open ('dirs.txt') as f:
content = f.readlines()
content = [x.strip() for x in content]
for file in content:
slices.append(len(os.listdir(file)))
L2 = [ x for x in slices if 50 <= x <= 350 ]
print(statistics.mean(L2))
'''
n, bins, patches = plt.hist(slices, 350, facecolor = 'blue', alpha = 0.7)
plt.xlabel('Number of Slices')
plt.ylabel('Frequency (Number of Scans)')
plt.title('Distribution of Slices in LIDC-IDRI')
plt.show()
'''