From ab1d6ed7ce0c39020e9bd1fbd9ace47e8ba6c66b Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Mon, 25 Feb 2019 17:25:32 +0100
Subject: [PATCH] Allow model file to be '-' or 'None' to disable shading
 correction

---
 src/imcflibs/imagej/shading.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/imcflibs/imagej/shading.py b/src/imcflibs/imagej/shading.py
index f1aeb14..18f66ac 100644
--- a/src/imcflibs/imagej/shading.py
+++ b/src/imcflibs/imagej/shading.py
@@ -116,15 +116,23 @@ def process_folder(path, suffix, outpath, model_file, fmt):
         The output folder where results will be stored. Existing files will be
         overwritten.
     model_file : str
-        The full path to a normalized 32-bit shading model image.
+        The full path to a normalized 32-bit shading model image. If set to '-'
+        or 'NONE', no shading correction will be applied.
     fmt : str
         The file format suffix for storing the results.
     """
-    imp = ij.IJ.openImage(model_file)
+    if model_file in ["-", "NONE"]:
+        model = None
+    else:
+        model = ij.IJ.openImage(model_file)
+        model.show()  # required, otherwise the IJ.run() call ignores the model
+
     matching_files = listdir_matching(path, suffix)
+    log.info("Running shading correction and projections on %s files...",
+             len(matching_files))
 
-    imp.show()  # required, otherwise the IJ.run() call will ignore the imp
     for orig_file in matching_files:
         in_file = os.path.join(path, orig_file)
-        correct_and_project(in_file, outpath, imp, 'ALL', fmt)
-    imp.close()
+        correct_and_project(in_file, outpath, model, 'ALL', fmt)
+    if model:
+        model.close()
-- 
GitLab