Skip to content

Commit 1aed64f

Browse files
committed
Make correct_and_project() return a tuple of bool
1 parent a61a260 commit 1aed64f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/imcflibs/imagej/shading.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,32 @@ def correct_and_project(filename, path, model, proj, fmt):
7878
fmt : str
7979
The file format suffix to be used for the results and projections, e.g.
8080
'.ics' for ICS2 etc. See the Bio-Formats specification for details.
81+
82+
Returns
83+
-------
84+
(bool, bool)
85+
A tuple of booleans indicating whether a shading correction has been
86+
applied and whether projections were created. The latter depends on
87+
both, the requested projections as well as the image type (e.g. it can
88+
be False even if projections were requested, but the image)
8189
"""
8290
target = gen_name_from_orig(path, filename, "", fmt)
8391
if os.path.exists(target):
8492
log.info("Found shading corrected file, not re-creating: %s", target)
85-
return
93+
return False, False
8694

8795
if not os.path.exists(path):
8896
os.makedirs(path)
8997

9098
imps = bioformats.import_image(filename, split_c=True)
99+
ret_corr = False
91100
if model is not None:
92101
log.debug("Applying shading correction on [%s]...", filename)
93102
imp = apply_model(imps, model)
94103
bioformats.export_using_orig_name(imp, path, filename, "", fmt, True)
95104
# imps needs to be updated with the new (=merged) stack:
96105
imps = [imp]
106+
ret_corr = True
97107

98108
if proj == 'None':
99109
projs = []
@@ -102,10 +112,11 @@ def correct_and_project(filename, path, model, proj, fmt):
102112
else:
103113
projs = [proj]
104114
for imp in imps:
105-
projections.create_and_save(imp, projs, path, filename, fmt)
115+
ret_proj = projections.create_and_save(imp, projs, path, filename, fmt)
106116
imp.close()
107117

108118
log.debug("Done processing [%s].", os.path.basename(filename))
119+
return ret_corr, ret_proj
109120

110121

111122
def process_folder(path, suffix, outpath, model_file, fmt):

0 commit comments

Comments
 (0)