Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ts_metadata = ts.getMetadata()
print json.dumps(ts_metadata, indent=2)
is_wsi = ts_metadata['magnification'] is not None
#
# Compute colorspace statistics (mean, variance) for whole slide
#
wsi_mean = args.source_mu_lab
wsi_stddev = args.source_std_lab
if is_wsi:
print('\n>> Computing mean and variance for whole slide ...\n')
wsi_mean, wsi_stddev = htk_cnorm.reinhard_stats(
img_path[i], args.sample_fraction, args.analysis_mag)
#
# Compute tissue/foreground mask at low-res for whole slide images
#
if is_wsi:
print('\n>> Computing tissue/foreground mask at low-res ...\n')
im_fgnd_mask_lres, fgnd_seg_scale = \
cli_utils.segment_wsi_foreground_at_low_res(ts)
#
# Compute foreground fraction of tiles in parallel using Dask
#
tile_fgnd_frac_list = [1.0]
cli_utils.disp_time_hms(fgnd_frac_comp_time)))
# =========================================================================
# ========================= Compute reinhard stats ========================
# =========================================================================
src_mu_lab = None
src_sigma_lab = None
print('\n>> Computing reinhard color normalization stats ...\n')
start_time = time.time()
# src_mu_lab, src_sigma_lab = htk_cnorm.reinhard_stats(
# args.inputImageFile, 0.01, magnification=args.analysis_mag,
# tissue_seg_mag=0.625)
src_mu_lab, src_sigma_lab = htk_cnorm.reinhard_stats(
args.inputImageFile, 0.01, magnification=args.analysis_mag)
print('Reinahrd stats')
print(src_mu_lab, src_sigma_lab)
rstats_time = time.time() - start_time
print('Reinhard stats computation time = {}'.format(
cli_utils.disp_time_hms(rstats_time)))
# =========================================================================
# ======================== Detect Nuclie in Parallel - Dask ==============
# =========================================================================
print('\n>> Detecting cell ...\n')
start_time = time.time()
print('Tile foreground fraction computation time = {}'.format(
cli_utils.disp_time_hms(fgnd_frac_comp_time)))
#
# Compute reinhard stats for color normalization
#
src_mu_lab = None
src_sigma_lab = None
if is_wsi and process_whole_image:
print('\n>> Computing reinhard color normalization stats ...\n')
start_time = time.time()
src_mu_lab, src_sigma_lab = htk_cnorm.reinhard_stats(
args.inputImageFile, 0.01, magnification=args.analysis_mag)
rstats_time = time.time() - start_time
print('Reinhard stats computation time = {}'.format(
cli_utils.disp_time_hms(rstats_time)))
#
# Detect nuclei in parallel using Dask
#
print('\n>> Detecting nuclei ...\n')
start_time = time.time()
tile_nuclei_list = []
print('Tile foreground fraction computation time = {}'.format(
cli_utils.disp_time_hms(fgnd_frac_comp_time)))
#
# Compute reinhard stats for color normalization
#
src_mu_lab = None
src_sigma_lab = None
if is_wsi and process_whole_image:
print('\n>> Computing reinhard color normalization stats ...\n')
start_time = time.time()
src_mu_lab, src_sigma_lab = htk_cnorm.reinhard_stats(
args.inputImageFile, 0.01, magnification=args.analysis_mag)
rstats_time = time.time() - start_time
print('Reinhard stats computation time = {}'.format(
cli_utils.disp_time_hms(rstats_time)))
#
# Detect and compute nuclei features in parallel using Dask
#
print('\n>> Detecting nuclei and computing features ...\n')
start_time = time.time()
tile_result_list = []
tile_magnification = ts_metadata['magnification']
is_wsi = tile_magnification is not None
#
# Compute colorspace statistics (mean, variance) for whole slide
#
wsi_mean = args.source_mu_lab
wsi_stddev = args.source_std_lab
if is_wsi:
print('\n>> Computing mean and variance for whole slide ...\n')
wsi_mean, wsi_stddev = htk_cnorm.reinhard_stats(
img_paths[i], args.sample_fraction, args.analysis_mag)
#
# Compute tissue/foreground mask at low-res for whole slide images
#
if is_wsi:
print('\n>> Computing tissue/foreground mask at low-res ...\n')
im_fgnd_mask_lres, fgnd_seg_scale = \
cli_utils.segment_wsi_foreground_at_low_res(ts)
#
# Compute foreground fraction of tiles in parallel using Dask
#
tile_fgnd_frac_list = [1.0]
percent_fgnd_tiles = 100.0 * num_fgnd_tiles / num_tiles
fgnd_frac_comp_time = time.time() - start_time
print('Number of foreground tiles = {0:d} ({1:2f}%%)'.format(
num_fgnd_tiles, percent_fgnd_tiles))
print('Tile foreground fraction computation time = {}'.format(
cli_utils.disp_time_hms(fgnd_frac_comp_time)))
print('\n>> Computing reinhard color normalization stats ...\n')
start_time = time.time()
src_mu_lab, src_sigma_lab = htk_cnorm.reinhard_stats(
img_paths[i], 0.01, magnification=args.analysis_mag)
rstats_time = time.time() - start_time
print('Reinhard stats computation time = {}'.format(
cli_utils.disp_time_hms(rstats_time)))
#
# Detect boundary and centroids in parallel using Dask
#
print('\n>> Detecting boundary and centroids ...\n')
start_time = time.time()
tile_result_list = []