Skip to content

Commit 25b8746

Browse files
committed
Allow shading model to be None, with no correction being done then
1 parent b55646b commit 25b8746

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/imcflibs/imagej/shading.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ def correct_and_project(filename, path, model, proj, fmt):
6666
path : str
6767
The full path to a directory for storing the results. Will be created in
6868
case it doesn't exist yet. Existing files will be overwritten.
69-
model : ij.ImagePlus
70-
A 32-bit floating point image to be used as the shading model.
69+
model : ij.ImagePlus or None
70+
A 32-bit floating point image to be used as the shading model. If model
71+
is None, no shading correction will be applied.
7172
proj : str
7273
A string describing the projections to be created. Use 'None' for not
7374
creating any projections, 'ALL' to do all supported ones.
@@ -80,24 +81,25 @@ def correct_and_project(filename, path, model, proj, fmt):
8081
log.info("Found shading corrected file, not re-creating: %s", target)
8182
return
8283

83-
log.debug("Applying shading correction on [%s]...", filename)
8484
if not os.path.exists(path):
8585
os.makedirs(path)
8686

87-
orig = bioformats.import_image(filename, split_c=True)
88-
corrected = apply_model(orig, model)
89-
bioformats.export_using_orig_name(corrected, path, filename, "", fmt, True)
87+
imps = bioformats.import_image(filename, split_c=True)
88+
if model is not None:
89+
log.debug("Applying shading correction on [%s]...", filename)
90+
imps = apply_model(imps, model)
91+
bioformats.export_using_orig_name(imps, path, filename, "", fmt, True)
9092

9193
if proj == 'None':
9294
projs = []
9395
elif proj == 'ALL':
9496
projs = ['Average', 'Maximum']
9597
else:
9698
projs = [proj]
97-
projections.create_and_save(corrected, projs, path, filename, fmt)
99+
projections.create_and_save(imps, projs, path, filename, fmt)
98100

99-
# corrected.show()
100-
corrected.close()
101+
# imps.show()
102+
imps.close()
101103
log.debug("Done processing [%s].", os.path.basename(filename))
102104

103105

0 commit comments

Comments
 (0)