-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_images_by_date.py
49 lines (35 loc) · 1.23 KB
/
get_images_by_date.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
"""
Simple script that reads all Images uploaded to OMERO on current day
Based on Erick Ratamero's answer in the following forum thread:
https://forum.image.sc/t/filter-omero-images-solely-by-date-using-python/75568
"""
import omero
from omero.gateway import BlitzGateway
import numpy as np
import ezomero
from datetime import date, datetime, timedelta
import time
import credentials as creds
today = date.today()
start = datetime(today.year, today.month, today.day)
end = start+timedelta(days=1)
username = creds.username
password = creds.password
hostname= creds.hostname
myport = creds.port
#conn = BlitzGateway(username, password,host=hostname,port=myport,secure=True)
conn = ezomero.connect(user=username, password=password,
host=hostname,
port=myport,
secure=True)
q = conn.getQueryService()
params = omero.sys.Parameters()
timestamp = (today - datetime(1970, 1, 1)) / timedelta(seconds=1)
params.map = {"date": omero.rtypes.rlong(timestamp)}
results = q.projection(
"select i.id from Image i"
" where i.details.creationEvent.time > :date",
params,
conn.SERVICE_OPTS
)
print(results)