Skip to content

Commit ab1d6ed

Browse files
committed
Allow model file to be '-' or 'None' to disable shading correction
1 parent 25b8746 commit ab1d6ed

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/imcflibs/imagej/shading.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,23 @@ def process_folder(path, suffix, outpath, model_file, fmt):
116116
The output folder where results will be stored. Existing files will be
117117
overwritten.
118118
model_file : str
119-
The full path to a normalized 32-bit shading model image.
119+
The full path to a normalized 32-bit shading model image. If set to '-'
120+
or 'NONE', no shading correction will be applied.
120121
fmt : str
121122
The file format suffix for storing the results.
122123
"""
123-
imp = ij.IJ.openImage(model_file)
124+
if model_file in ["-", "NONE"]:
125+
model = None
126+
else:
127+
model = ij.IJ.openImage(model_file)
128+
model.show() # required, otherwise the IJ.run() call ignores the model
129+
124130
matching_files = listdir_matching(path, suffix)
131+
log.info("Running shading correction and projections on %s files...",
132+
len(matching_files))
125133

126-
imp.show() # required, otherwise the IJ.run() call will ignore the imp
127134
for orig_file in matching_files:
128135
in_file = os.path.join(path, orig_file)
129-
correct_and_project(in_file, outpath, imp, 'ALL', fmt)
130-
imp.close()
136+
correct_and_project(in_file, outpath, model, 'ALL', fmt)
137+
if model:
138+
model.close()

0 commit comments

Comments
 (0)