Skip to content

Commit 31444cb

Browse files
committed
Put back num_threads in illumination_correction (ref #131)
1 parent 31fe853 commit 31444cb

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

fractal/tasks/illumination_correction.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414
import json
1515
import warnings
16+
from concurrent.futures import ThreadPoolExecutor
1617

1718
import anndata as ad
1819
import dask
@@ -249,15 +250,16 @@ def illumination_correction(
249250
accumulated_data = da.stack(data_czyx_new, axis=0)
250251

251252
# 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+
)
261263

262264

263265
if __name__ == "__main__":
@@ -305,6 +307,13 @@ def illumination_correction(
305307
" (optional, defaults to 110)"
306308
),
307309
)
310+
parser.add_argument(
311+
"-nt",
312+
"--num_threads",
313+
default=2,
314+
type=int,
315+
help="num threads",
316+
)
308317

309318
args = parser.parse_args()
310319
illumination_correction(
@@ -315,4 +324,5 @@ def illumination_correction(
315324
chl_list=args.chl_list,
316325
coarsening_xy=args.coarsening_xy,
317326
background=args.background,
327+
num_threads=args.num_threads,
318328
)

0 commit comments

Comments
 (0)