-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
60 lines (40 loc) · 1.54 KB
/
tests.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
#! /usr/bin/python3
import unittest
import os.path
from scipy import misc
import matplotlib.pyplot as plt
from colony_roi_import import ColonyROIImportCSV
DATA_DIR = "data"
IMAGE_DIR = "photos"
IMAGE_FILENAME = "600px-E.coliAgarpicture.jpg"
ROI_IMAGE_FILENAME = "600px-E.coliAgarpicture-ROI.jpg"
class TestColonyROIImportCSV(unittest.TestCase):
def test_colony_count(self):
roi_import = ColonyROIImportCSV(data_dir=DATA_DIR)
colony_count = roi_import.get_colony_count()
roi_data = roi_import.colony_data()
self.assertEqual(colony_count, 16)
self.assertEqual(len(roi_data), 16)
def test_center_of_mass(self):
roi_import = ColonyROIImportCSV(data_dir=DATA_DIR)
colony_count = roi_import.get_colony_count()
colony_roi_data = roi_import.colony_data()
print(roi_import.center_of_mass(1))
def test_colony_import_visual(self):
"""
Draw ROI on original image
"""
roi_import = ColonyROIImportCSV(data_dir=DATA_DIR)
colony_count = roi_import.get_colony_count()
colony_roi_data = roi_import.colony_data()
f=misc.imread(os.path.join(IMAGE_DIR, IMAGE_FILENAME))
plt.imshow(f)
for i in range(colony_count):
plt.scatter(*roi_import.center_of_mass(i))
colony_i_roi_data = colony_roi_data[i]['roi_data']
l = len(colony_i_roi_data)
for j in range(l):
plt.scatter(*colony_i_roi_data[j], s=1)
plt.show()
if __name__ == "__main__":
unittest.main()