-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongoapi.py
79 lines (63 loc) · 2.08 KB
/
mongoapi.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import pymongo
host = 'ca-mongo'
my_client = pymongo.MongoClient("mongodb://" + host + ":27017/")
my_db = my_client["camic"]
heat_col = my_db['heatmap']
mark_col = my_db['mark']
analysis_col = my_db['analysis']
# SEGMENTATIONS - COMPUTER, AND HUMAN.
def computer(quad):
# analysis. submit_date, type, computation, execution_id
my_list = []
exec_list = [] # weed out the duplicates
# QUERY ON IMAGE
query = {
"image.slide": str(quad['nid']),
"image.imageid": quad['imageid'],
"image.study": quad['studyid'],
"image.subject": quad['subjectid']
}
# for x in mark_col.find(query, {
# "geometries": 0,
# "_id": 0
# }):
for x in analysis_col.find(query, {
"analysis": 1,
"_id": 0
}):
execid = x['analysis']['execution_id']
if execid not in exec_list:
exec_list.append(execid)
my_list.append(x)
return my_list
def human(quad):
# creator, created_date, provenance.analysis source, computation, execution_id
my_list = []
exec_list = [] # weed out the duplicates
query = {
"provenance.image.slide": str(quad['nid']), # "50830"
"provenance.analysis.source": "human"
}
for x in mark_col.find(query, {"_id": 0, "geometries": 0}):
execid = x['provenance']['analysis']['execution_id']
if execid not in exec_list:
exec_list.append(execid)
my_list.append(x)
return my_list
# HEATMAP
def heat(quad):
# source, execution_id, computation (no date)
my_list = []
exec_list = [] # weed out the duplicates
query = {
"provenance.image.slide": str(quad['nid']),
"provenance.image.case_id": quad['imageid'],
"provenance.image.subject_id": quad['subjectid'],
"provenance.analysis.study_id": quad['studyid']
}
for x in heat_col.find(query, {"_id": 0, "data": 0}):
execid = x['provenance']['analysis']['execution_id']
if execid not in exec_list:
exec_list.append(execid)
my_list.append(x)
return my_list