From dbc22ea3b1ae780e798592332f08dc3636f8361e Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Tue, 25 Jan 2022 12:33:09 +0100 Subject: [PATCH] Display Sequence now displays an informative messagebox inseatd of crashing when the list of sequence is empty fixes #7 --- Makefile | 2 +- src/ij-plugins/Ipr/Lipase/Display_Sequence.py | 31 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 0c03701..0c2f216 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ TEMP_PATH:=$(shell echo ~/work/lipase/tmp) TESTS_OUTPUT_DATA_PATH:=$(TEMP_PATH) LIB_SRC_FILES=$(shell find ./src/lipase -name "*.py") PLUGINS_SRC_FILES=$(shell find ./src/ij-plugins -name "*.py") -LIPASE_VERSION=1.04 +LIPASE_VERSION=1.05 BUILD_ROOT_PATH:=$(TEMP_PATH)/build PACKAGE_FILE_PATH=$(BUILD_ROOT_PATH)/lipase-$(LIPASE_VERSION).zip diff --git a/src/ij-plugins/Ipr/Lipase/Display_Sequence.py b/src/ij-plugins/Ipr/Lipase/Display_Sequence.py index d6ec917..2bb23b3 100644 --- a/src/ij-plugins/Ipr/Lipase/Display_Sequence.py +++ b/src/ij-plugins/Ipr/Lipase/Display_Sequence.py @@ -101,22 +101,25 @@ def run_script(): user_settings = UserSettings() IImageEngine.set_instance(IJImageEngine()) catalog = ImageCatalog(user_settings.raw_images_root_path) + if len(catalog.sequences) > 0: + user_selection = ask_for_sequence(catalog) + if len(user_selection) == 0: + return + sequence = user_selection['sequence'] + channel_id = str(user_selection['channel_id']) + IJ.log("channel_id = %s (type = %s)" % (channel_id, str(type(channel_id)))) + if channel_id == 'all': + sequence_as_stack = open_sequence_in_imagej(sequence) + else: + hyperstack = sequence.as_hyperstack(selected_channel_ids=[channel_id], selected_frames=None, selected_slices=None) + sequence_as_stack = hyperstack.hyperstack - user_selection = ask_for_sequence(catalog) - if len(user_selection) == 0: - return - sequence = user_selection['sequence'] - channel_id = str(user_selection['channel_id']) - IJ.log("channel_id = %s (type = %s)" % (channel_id, str(type(channel_id)))) - if channel_id == 'all': - sequence_as_stack = open_sequence_in_imagej(sequence) - else: - hyperstack = sequence.as_hyperstack(selected_channel_ids=[channel_id], selected_frames=None, selected_slices=None) - sequence_as_stack = hyperstack.hyperstack + print(type(sequence_as_stack)) + global SEQUENCE + SEQUENCE = sequence_as_stack + else: + IJ.runMacro('waitForUser("Warning", "No sequences have been found in raw images root dir (%s)"' % user_settings.raw_images_root_path) - print(type(sequence_as_stack)) - global SEQUENCE - SEQUENCE = sequence_as_stack # note : when launched from fiji, __name__ doesn't have the value "__main__", as when launched from python run_script()