From 94e9e4915e6ed2803ebd6199ccf35c668b60d9b3 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Tue, 2 Apr 2019 22:09:23 +0200 Subject: [PATCH] Catch non-existing model file --- src/imcflibs/imagej/shading.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/imcflibs/imagej/shading.py b/src/imcflibs/imagej/shading.py index bd66e18..bd0774b 100644 --- a/src/imcflibs/imagej/shading.py +++ b/src/imcflibs/imagej/shading.py @@ -6,6 +6,7 @@ import ij # pylint: disable-msg=import-error from ..imagej import bioformats # pylint: disable-msg=no-name-in-module from ..imagej import projections +from ..imagej import misc from ..pathtools import listdir_matching, gen_name_from_orig from ..log import LOG as log @@ -130,7 +131,11 @@ def process_folder(path, suffix, outpath, model_file, fmt): model = None else: model = ij.IJ.openImage(model_file) - model.show() # required, otherwise the IJ.run() call ignores the model + # the model needs to be shown, otherwise the IJ.run() call ignores it + try: + model.show() + except AttributeError: + misc.error_exit("Opening shading model [%s] failed!" % model_file) matching_files = listdir_matching(path, suffix) log.info("Running shading correction and projections on %s files...", -- GitLab