Kuchelmeister Hannes
commited on
Commit
·
ea08a74
1
Parent(s):
a76ccef
change code to select based on study id instead of date
Browse files
annotation-preprocessing/0_fetch_from_database.py
CHANGED
@@ -3,6 +3,19 @@ import pandas as pd
|
|
3 |
import os
|
4 |
from dotenv import load_dotenv
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
def fetch_objects_from_datase(db):
|
7 |
cursor = db.cursor()
|
8 |
|
@@ -14,16 +27,7 @@ def fetch_objects_from_datase(db):
|
|
14 |
UniqueGroundTruth.y_max,
|
15 |
UniqueGroundTruth.object_type_id,
|
16 |
ObjectType.name,
|
17 |
-
Image.add_date
|
18 |
-
FROM UniqueGroundTruth
|
19 |
-
JOIN DetectedObject on DetectedObject.id = UniqueGroundTruth.object_id
|
20 |
-
JOIN Image on Image.id = DetectedObject.image_id
|
21 |
-
JOIN FocusStack on FocusStack.id = Image.focus_stack_id
|
22 |
-
JOIN ObjectType on ObjectType.id = UniqueGroundTruth.object_type_id
|
23 |
-
WHERE metaclass_id = 1 -- only select eggs;
|
24 |
-
AND unix_timestamp(Image.add_date) > unix_timestamp('2021-03-07 00:00:00')
|
25 |
-
ORDER BY UniqueGroundTruth.focus_stack_id;
|
26 |
-
""")
|
27 |
|
28 |
result = cursor.fetchall()
|
29 |
return result
|
@@ -49,13 +53,8 @@ def fetch_focus_stacks_from_database(db):
|
|
49 |
FocusStack.id IN( -- get all focus stacks that have objects in them;
|
50 |
SELECT DISTINCT
|
51 |
UniqueGroundTruth.focus_stack_id
|
52 |
-
|
53 |
-
|
54 |
-
JOIN Image on Image.id = DetectedObject.image_id
|
55 |
-
JOIN FocusStack on FocusStack.id = Image.focus_stack_id
|
56 |
-
JOIN ObjectType on ObjectType.id = UniqueGroundTruth.object_type_id
|
57 |
-
WHERE metaclass_id = 1 -- only select eggs;
|
58 |
-
AND unix_timestamp(Image.add_date) > unix_timestamp('2021-03-07 00:00:00')
|
59 |
)
|
60 |
ORDER BY FocusStack.id DESC, focus_value, focus_level
|
61 |
""")
|
|
|
3 |
import os
|
4 |
from dotenv import load_dotenv
|
5 |
|
6 |
+
BASE_OBJECT_SQL = """
|
7 |
+
FROM UniqueGroundTruth
|
8 |
+
JOIN DetectedObject on DetectedObject.id = UniqueGroundTruth.object_id
|
9 |
+
JOIN Image on Image.id = DetectedObject.image_id
|
10 |
+
JOIN FocusStack on FocusStack.id = Image.focus_stack_id
|
11 |
+
JOIN Scan on Scan.id = FocusStack.scan_id
|
12 |
+
JOIN Slide on Slide.id = Scan.slide_id
|
13 |
+
JOIN ObjectType on ObjectType.id = UniqueGroundTruth.object_type_id
|
14 |
+
WHERE metaclass_id = 1 -- only select eggs;
|
15 |
+
AND study_id = 31
|
16 |
+
ORDER BY UniqueGroundTruth.focus_stack_id
|
17 |
+
"""
|
18 |
+
|
19 |
def fetch_objects_from_datase(db):
|
20 |
cursor = db.cursor()
|
21 |
|
|
|
27 |
UniqueGroundTruth.y_max,
|
28 |
UniqueGroundTruth.object_type_id,
|
29 |
ObjectType.name,
|
30 |
+
Image.add_date""" + BASE_OBJECT_SQL)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
result = cursor.fetchall()
|
33 |
return result
|
|
|
53 |
FocusStack.id IN( -- get all focus stacks that have objects in them;
|
54 |
SELECT DISTINCT
|
55 |
UniqueGroundTruth.focus_stack_id
|
56 |
+
""" + BASE_OBJECT_SQL
|
57 |
+
+ """
|
|
|
|
|
|
|
|
|
|
|
58 |
)
|
59 |
ORDER BY FocusStack.id DESC, focus_value, focus_level
|
60 |
""")
|