From 0aa41d09badbce912a32828edb7f5b7b623331a1 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Wed, 9 Jan 2019 11:41:09 +0100 Subject: [PATCH] Only create shading-corrected images if they don't exist yet --- src/imcflibs/imagej/shading.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/imcflibs/imagej/shading.py b/src/imcflibs/imagej/shading.py index 7bb69ab..0121198 100644 --- a/src/imcflibs/imagej/shading.py +++ b/src/imcflibs/imagej/shading.py @@ -7,7 +7,7 @@ from ij.plugin import ImageCalculator, RGBStackMerge from ..imagej import bioformats from ..imagej import projections -from ..pathtools import listdir_matching +from ..pathtools import listdir_matching, gen_name_from_orig from ..log import LOG as log @@ -55,6 +55,11 @@ def apply_model(imps, model, merge=True): def correct_and_project(filename, path, model, proj, fmt): """Apply a shading correction to an image and create a projection. + In case the target file for the shading corrected image already exists, + nothing is done - neither the shading correction is re-created nor any + projections will be done (independent on whether the latter one already + exist or not). + Parameters ---------- filename : str @@ -71,7 +76,12 @@ def correct_and_project(filename, path, model, proj, fmt): The file format suffix to be used for the results and projections, e.g. '.ics' for ICS2 etc. See the Bio-Formats specification for details. """ - log.debug("Processing [%s]...", filename) + target = gen_name_from_orig(path, filename, "", fmt) + if os.path.exists(target): + log.info("Found shading corrected file, not re-creating: %s", target) + return + + log.debug("Applying shading correction on [%s]...", filename) if not os.path.exists(path): os.makedirs(path) -- GitLab