Skip to content

Commit 18a9a75

Browse files
authored
Merge pull request #229 from Rdornier/split-view-user-label
Adding support for custom user label
2 parents 0c7356a + e68504f commit 18a9a75

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

omero/figure_scripts/Split_View_Figure.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -499,19 +499,28 @@ def split_view_figure(conn, script_params):
499499
image_labels = []
500500

501501
# function for getting image labels.
502-
def get_image_names(full_name, tags_list, pd_list):
502+
def get_image_names(full_name, tags_list, pd_list, iid):
503503
name = full_name.split("/")[-1]
504504
return [name]
505505

506506
# default function for getting labels is getName (or use datasets / tags)
507507
if script_params["Image_Labels"] == "Datasets":
508-
def get_datasets(name, tags_list, pd_list):
508+
def get_datasets(name, tags_list, pd_list, iid):
509509
return [dataset for project, dataset in pd_list]
510510
get_labels = get_datasets
511511
elif script_params["Image_Labels"] == "Tags":
512-
def get_tags(name, tags_list, pd_list):
512+
def get_tags(name, tags_list, pd_list, iid):
513513
return [t for t in tags_list]
514514
get_labels = get_tags
515+
elif script_params["Image_Labels"] == "Custom":
516+
def get_custom_label(name, tags_list, pd_list, iid):
517+
all_labels = script_params["All_labels"]
518+
for label_pair in all_labels.split("//n"):
519+
if str(iid) in label_pair:
520+
if len(label_pair.split("//s")) > 1:
521+
return [label_pair.split("//s")[1]]
522+
return [""]
523+
get_labels = get_custom_label
515524
else:
516525
get_labels = get_image_names
517526

@@ -552,7 +561,7 @@ def get_tags(name, tags_list, pd_list):
552561
log(" Tags: %s" % tags)
553562
log(" Project/Datasets: %s" % pd_string)
554563

555-
image_labels.append(get_labels(name, tags_list, pd_list))
564+
image_labels.append(get_labels(name, tags_list, pd_list, iid))
556565

557566
# use the first image to define dimensions, channel colours etc.
558567
size_x = omero_image.getSizeX()
@@ -674,7 +683,8 @@ def run_script():
674683
"""
675684

676685
data_types = [rstring('Image')]
677-
labels = [rstring('Image Name'), rstring('Datasets'), rstring('Tags')]
686+
labels = [rstring('Image Name'), rstring('Datasets'), rstring('Tags'),
687+
rstring('Custom')]
678688
algorithms = [rstring('Maximum Intensity'), rstring('Mean Intensity')]
679689
formats = [rstring('JPEG'), rstring('PNG'), rstring('TIFF')]
680690
ckeys = list(COLOURS.keys())
@@ -750,6 +760,10 @@ def run_script():
750760
description="Label images with Image name (default) or datasets"
751761
" or tags", values=labels, default='Image Name'),
752762

763+
scripts.String(
764+
"All_labels", grouping="93",
765+
description="User defined label", default=''),
766+
753767
scripts.Int(
754768
"Stepping", grouping="93",
755769
description="The Z increment for projection.", default=1, min=1),

0 commit comments

Comments
 (0)