13
13
"""
14
14
import json
15
15
import warnings
16
+ from concurrent .futures import ThreadPoolExecutor
16
17
17
18
import anndata as ad
18
19
import dask
@@ -249,15 +250,16 @@ def illumination_correction(
249
250
accumulated_data = da .stack (data_czyx_new , axis = 0 )
250
251
251
252
# Construct resolution pyramid
252
- write_pyramid (
253
- accumulated_data ,
254
- newzarrurl = newzarrurl ,
255
- overwrite = overwrite ,
256
- coarsening_xy = coarsening_xy ,
257
- num_levels = num_levels ,
258
- chunk_size_x = img_size_x ,
259
- chunk_size_y = img_size_y ,
260
- )
253
+ with dask .config .set (pool = ThreadPoolExecutor (num_threads )):
254
+ write_pyramid (
255
+ accumulated_data ,
256
+ newzarrurl = newzarrurl ,
257
+ overwrite = overwrite ,
258
+ coarsening_xy = coarsening_xy ,
259
+ num_levels = num_levels ,
260
+ chunk_size_x = img_size_x ,
261
+ chunk_size_y = img_size_y ,
262
+ )
261
263
262
264
263
265
if __name__ == "__main__" :
@@ -305,6 +307,13 @@ def illumination_correction(
305
307
" (optional, defaults to 110)"
306
308
),
307
309
)
310
+ parser .add_argument (
311
+ "-nt" ,
312
+ "--num_threads" ,
313
+ default = 2 ,
314
+ type = int ,
315
+ help = "num threads" ,
316
+ )
308
317
309
318
args = parser .parse_args ()
310
319
illumination_correction (
@@ -315,4 +324,5 @@ def illumination_correction(
315
324
chl_list = args .chl_list ,
316
325
coarsening_xy = args .coarsening_xy ,
317
326
background = args .background ,
327
+ num_threads = args .num_threads ,
318
328
)
0 commit comments