Skip to content

Commit

Permalink
Making reference to image IDs not contained in a pack negative in Fig…
Browse files Browse the repository at this point in the history
…ures (#84)

* replacing non-source image IDs with -1

* using the correct var and type
  • Loading branch information
erickmartins committed May 13, 2024
1 parent 06281d2 commit dd6d61c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/generate_omero_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import xml.etree.cElementTree as ETree
import os
import copy
import re


def create_or_set_projects(pjs: List[Project], conn: BlitzGateway,
Expand Down Expand Up @@ -287,9 +288,14 @@ def update_figure_refs(ann: FileAnnotation, ans: List[Annotation],
filedata = file.read()
for src_id, dest_id in img_map.items():
clean_id = int(src_id.split(":")[-1])
src_str = f"\"imageId\": {clean_id}"
dest_str = f"\"imageId\": {dest_id}"
src_str = f"\"imageId\": {clean_id},"
dest_str = f"\"imageId\": {dest_id},"
filedata = filedata.replace(src_str, dest_str)
for fig in re.finditer("\"imageId\": ([0-9]+),", filedata):
if int(fig.group(1)) not in img_map.values():
src_str = f"\"imageId\": {fig.group(1)},"
dest_str = f"\"imageId\": {str(-1)},"
filedata = filedata.replace(src_str, dest_str)
with open(dest_path, 'w') as file:
file.write(filedata)
return
Expand Down

0 comments on commit dd6d61c

Please sign in to comment.