Esempio n. 1
0
 def __init__(self, shape):
     super().__init__(shape)
     t0 = time.time()
     self.filter = fast_fft.SpatialFilter(shape, self.PERIOD_RANGE, precision=32, threads=6, better_plan=True)
     if time.time() - t0 > 0.5:
         fast_fft.store_plan_hints(FFTW_WISDOM)
         logger.debug('FFTW wisdom stored')
Esempio n. 2
0
def get_fft_filter(image_shape, min_feature, max_feature, microns_per_pixel):
    fftw_hints = pathlib.Path(__file__).parent / 'fftw_hints'
    if fftw_hints.exists():
        fast_fft.load_plan_hints(str(fftw_hints))
    fft_filter = fast_fft.SpatialFilter(image_shape, period_range=(min_feature, max_feature),
        spacing=microns_per_pixel, order=2, keep_dc=False, threads=1, better_plan=True)
    fast_fft.store_plan_hints(str(fftw_hints))
    return fft_filter
Esempio n. 3
0
 def __init__(self, shape):
     super().__init__(shape)
     t0 = time.time()
     self.filter = fast_fft.SpatialFilter(
         shape, self.PERIOD_RANGE, precision=32, threads=multiprocessing.cpu_count(), better_plan=False
     )
     if time.time() - t0 > 0.5:
         fast_fft.store_plan_hints(FFTW_WISDOM)
Esempio n. 4
0
def _get_filter(shape, period_range):
    timer = threading.Timer(1, logger.warning, ['Slow construction of FFTW filter for image shape {} (likely no cached plan could be found). May take >30 minutes!', shape])
    timer.start()
    fft_filter = fast_fft.SpatialFilter(shape, period_range, precision=32, threads=6, better_plan=True)
    if timer.is_alive():
        timer.cancel()
    else: # timer went off and warning was issued...
        logger.info('FFT filter constructed. Caching plan wisdom for next time.')
        fast_fft.store_plan_hints(str(FFTW_WISDOM))
    return fft_filter.filter
Esempio n. 5
0
def _get_filter(shape, period_range):
    timer = threading.Timer(1, logger.warning, ['Slow construction of FFTW filter for image shape {} (likely no cached plan could be found). May take >30 minutes!', shape])
    timer.start()
    fft_filter = fast_fft.SpatialFilter(shape, period_range, precision=32, threads=6, better_plan=True)
    if timer.is_alive():
        timer.cancel()
    else: # timer went off and warning was issued...
        logger.info('FFT filter constructed. Caching plan wisdom for next time.')
        fast_fft.store_plan_hints(str(FFTW_WISDOM))
    return fft_filter.filter