Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def sample_pixels(args):
"""Version of histomicstk.utils.sample_pixels that takes a Namespace
and handles the special default values.
"""
args = (args._asdict() if hasattr(args, '_asdict') else vars(args)).copy()
for k in 'magnification', 'sample_fraction', 'sample_approximate_total':
if args[k] == -1:
del args[k]
return htk_utils.sample_pixels(**args)
M x N eigenvector angle image for E(:,:,0) in radians
see eigen.py. Oriented parallel to vessel structures.
References
----------
.. [#] Frangi, Alejandro F., et al. "Multiscale vessel enhancement
filtering." Medical Image Computing and Computer-Assisted
Interventation. MICCAI98. Springer Berlin Heidelberg,1998. 130-137.
"""
# calculate hessian matrix
H = sigma ** 2 * htk_utils.hessian(im_input, sigma)
# calculate eigenvalue image
E, V1, V2 = htk_utils.eigen(H)
# compute blobness measures
Deviation = E[:, :, 0]/(E[:, :, 1] + np.spacing(1))
Frobenius = np.sqrt(E[:, :, 0]**2 + E[:, :, 1]**2)
# calculate angles for 'Theta'
Theta = np.arctan2(V1[:, :, 1], V1[:, :, 0])
return Deviation, Frobenius, E, Theta
'width': args.analysis_roi[2],
'height': args.analysis_roi[3],
'units': 'base_pixels'
}
# =========================================================================
if is_wsi:
print('\n>> Computing foreground fraction of all tiles ...\n')
start_time = time.time()
num_tiles = ts.getSingleTile(**it_kwargs)['iterator_range']['position']
print('Number of tiles = {}'.format(num_tiles))
if process_whole_image:
tile_fgnd_frac_list = htk_utils.compute_tile_foreground_fraction(
args.inputImageFile, im_fgnd_mask_lres, fgnd_seg_scale,
it_kwargs
)
else:
tile_fgnd_frac_list = np.full(num_tiles, 1.0)
num_fgnd_tiles = np.count_nonzero(
tile_fgnd_frac_list >= args.min_fgnd_frac)
percent_fgnd_tiles = 100.0 * num_fgnd_tiles / num_tiles
fgnd_frac_comp_time = time.time() - start_time
print('Number of foreground tiles = {:d} ({:2f}%)'.format(