-
Notifications
You must be signed in to change notification settings - Fork 1
/
extract_omero_labels.py
31 lines (26 loc) · 1.06 KB
/
extract_omero_labels.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
import argparse
import logging
import os
import yaml
from OmeSliCC.Omero import Omero
from OmeSliCC.OmeroLabelReader import OmeroLabelReader
from OmeSliCC.parameters import *
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Omero label reader')
parser.add_argument('--params',
help='The parameters file',
default=PARAMETER_FILE)
args = parser.parse_args()
with open(args.params) as file:
params = yaml.safe_load(file)
log_params = params['log']
basepath = os.path.dirname(log_params['filename'])
if not os.path.exists(basepath):
os.makedirs(basepath)
logging.basicConfig(format=log_params['log_format'], level=logging.INFO,
handlers=[logging.StreamHandler(), logging.FileHandler(log_params['filename'])])
with Omero(params) as omero:
with OmeroLabelReader(params, omero=omero) as label_reader:
image_ids = omero.get_annotation_image_ids()
label_reader.create_label_csv(image_ids)
logging.info('Done')