@@ -138,6 +138,30 @@ def process_folder(path, suffix, outpath, model_file, fmt):
138138 fmt : str
139139 The file format suffix for storing the results.
140140 """
141+ matching_files = listdir_matching (path , suffix , fullpath = True )
142+ process_files (matching_files , outpath , model_file , fmt )
143+
144+
145+ def process_files (files , outpath , model_file , fmt ):
146+ """Run shading correction and projections on a list of files.
147+
148+ Parameters
149+ ----------
150+ files : list(str)
151+ The files to be processed, as a list of strings with the full path.
152+ outpath : str
153+ The output folder where results will be stored. Existing files will be
154+ overwritten.
155+ model_file : str
156+ The full path to a normalized 32-bit shading model image. If set to '-'
157+ or 'NONE', no shading correction will be applied, i.e. only the
158+ projection step will have an effect.
159+ fmt : str
160+ The file format suffix for storing the results.
161+ """
162+ log .info ("Running shading correction and projections on %s files..." ,
163+ len (files ))
164+
141165 if model_file .upper () in ["-" , "NONE" ]:
142166 model = None
143167 else :
@@ -152,12 +176,8 @@ def process_folder(path, suffix, outpath, model_file, fmt):
152176 except AttributeError :
153177 misc .error_exit ("Opening shading model [%s] failed!" % model_file )
154178
155- matching_files = listdir_matching (path , suffix )
156- log .info ("Running shading correction and projections on %s files..." ,
157- len (matching_files ))
158-
159- for orig_file in matching_files :
160- in_file = os .path .join (path , orig_file )
179+ for in_file in files :
161180 correct_and_project (in_file , outpath , model , 'ALL' , fmt )
181+
162182 if model :
163183 model .close ()
0 commit comments