From 69ddb8d8e8328d9302ed745444dc40056296d8f5 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Fri, 21 Dec 2018 08:10:52 +0100
Subject: [PATCH] Create output directory if necessary
---
src/imcflibs/imagej/shading.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/imcflibs/imagej/shading.py b/src/imcflibs/imagej/shading.py
index 31573fd..27d835a 100644
--- a/src/imcflibs/imagej/shading.py
+++ b/src/imcflibs/imagej/shading.py
@@ -59,7 +59,8 @@ def correct_and_project(filename, path, model, proj, fmt):
filename : str
The full path to a multi-channel image stack.
path : str
- The full path to a directory for storing the results.
+ The full path to a directory for storing the results. Will be created in
+ case it doesn't exist yet.
model : ij.ImagePlus
A 32-bit floating point image to be used as the shading model.
proj : str
@@ -69,6 +70,9 @@ 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.
"""
+ if not os.path.exists(path):
+ os.makedirs(path)
+
orig = bioformats.import_image(filename, split_c=True)
corrected = apply_model(orig, model)
bioformats.export_using_orig_name(corrected, path, filename, "", fmt)
--
GitLab