diff --git a/src/processing_steps/0600_segment_implant_cc.py b/src/processing_steps/0600_segment_implant_cc.py index f1e8acb..e930125 100644 --- a/src/processing_steps/0600_segment_implant_cc.py +++ b/src/processing_steps/0600_segment_implant_cc.py @@ -8,6 +8,7 @@ from lib.cpp.cpu.io import load_slice from lib.cpp.cpu.connected_components import largest_connected_component, connected_components import multiprocessing as mp +from multiprocessing.pool import ThreadPool import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt @@ -100,7 +101,7 @@ def label_chunk(i, chunk_size, chunk_prefix, implant_threshold_u16, global_shape return n_features start = datetime.datetime.now() - with mp.Pool(n_cores) as pool: + with ThreadPool(n_cores) as pool: label_chunk_partial = partial(label_chunk, chunk_size=layers_per_chunk, chunk_prefix=f"{intermediate_folder}/{sample}_", implant_threshold_u16=implant_threshold_u16, global_shape=(nz,ny,nx)) n_labels = pool.map(label_chunk_partial, range(n_chunks)) end = datetime.datetime.now() diff --git a/src/processing_steps/0750_bone_region.py b/src/processing_steps/0750_bone_region.py index 6aacd06..f22f2f5 100644 --- a/src/processing_steps/0750_bone_region.py +++ b/src/processing_steps/0750_bone_region.py @@ -17,6 +17,7 @@ from scipy.ndimage import gaussian_filter1d import datetime import multiprocessing as mp +from multiprocessing.pool import ThreadPool from functools import partial # close = dilate then erode @@ -94,7 +95,7 @@ def largest_cc_of(mask, mask_name): return (label == largest_cc_ix) else: start = datetime.datetime.now() - with mp.Pool(n_cores) as pool: + with ThreadPool(n_cores) as pool: label_chunk_partial = partial(label_chunk, chunk_prefix=f"{intermediate_folder}/{sample}_") chunks = [mask[i*layers_per_chunk:(i+1)*layers_per_chunk] for i in range(n_chunks-1)] chunks.append(mask[(n_chunks-1)*layers_per_chunk:]) diff --git a/src/processing_steps/1500_segment_blood_cc.py b/src/processing_steps/1500_segment_blood_cc.py index 7f5cfaf..5784570 100644 --- a/src/processing_steps/1500_segment_blood_cc.py +++ b/src/processing_steps/1500_segment_blood_cc.py @@ -11,6 +11,7 @@ from lib.py.resample import downsample2x, downsample3x import cupy as cp import multiprocessing as mp +from multiprocessing.pool import ThreadPool import datetime from functools import partial @@ -78,7 +79,7 @@ def label_chunk(i, chunk_size, chunk_prefix, global_shape): return n_features start = datetime.datetime.now() - with mp.Pool(n_cores) as pool: + with ThreadPool(n_cores) as pool: label_chunk_partial = partial(label_chunk, chunk_size=layers_per_chunk, chunk_prefix=f"{intermediate_folder}/{sample}_", global_shape=(nz,ny,nx)) n_labels = pool.map(label_chunk_partial, range(n_chunks)) end = datetime.datetime.now()