def test_decon_wrapper_with_variable_shapes(self): """ test that the """ images = [ self.deskewed, self.deskewed[:, 4:-4, 4:-4], self.deskewed[2:-2, 16:-16, 16:-16] ] decon(images, self.otf, **self.config)
def test_decon_wrapper_with_psf_array(self): """ test that we can deconvolve an image """ psf = imread(self.psf) decon_result = decon(self.deskewed, psf, **self.config) self.assertTrue(np.allclose(decon_result, self.stored_decon))
def test_decon_wrapper_save_deskewed(self): """ test that the """ config = dict(self.config) config['deskew'] = 31.5 decon_result = decon(self.raw, self.otf, save_deskewed=True, **config) self.assertTrue(len(decon_result) == 2)
def test_decon_wrapper_with_many_inputs(self): """ test that the """ images = [self.deskewed, self.deskewed, self.deskewed] decon_results = decon(images, self.otf, **self.config) self.assertTrue( all([np.allclose(d, self.stored_decon) for d in decon_results]))
def proc_channel(pos): for chan in channels: data = dir+experiment+pos+channels[chan] psf = dir+"\\"+kernels[chan] if not os.path.isfile(data): print("bad file path: "+data) if not os.path.isfile(psf): print('bad file path: '+psf) result = decon(data, psf, cleanup_otf=True, wavelength=wavelengths[chan], na=1.47, nimm=1.515) # to output full zstack # tifffile.imsave(outdir+pos+"\\testthing%s.tif" % chan, result.astype(dtype=np.uint16)) # to output individual z-planes in the format generated by micromanager for zIdx in range(0, len(result)): out_filename = '\\img_000000000_Zyla_%s_Widefield_%03d.tif' % (chan, zIdx) tifffile.imsave(outdir+pos+out_filename, result[zIdx].astype(dtype=np.uint16))
wavelengths = {'405': 430, '488': 515, '561': 585, '637': 655} # set range on position if want a subset for pos in positions[:]: if not os.path.exists(outdir+pos): os.mkdir(outdir+pos) for chan in channels: data = dir+experiment+pos+channels[chan] psf = dir+"\\"+kernels[chan] if not os.path.isfile(data): print("bad file path: "+data) if not os.path.isfile(psf): print('bad file path: '+psf) result = decon(data, psf, cleanup_otf=True, wavelength=wavelengths[chan], na=1.47, nimm=1.515) # to output full zstack # tifffile.imsave(outdir+pos+"\\testthing%s.tif" % chan, result.astype(dtype=np.uint16)) # to output individual z-planes in the format generated by micromanager for zIdx in range(0, len(result)): out_filename = '\\img_000000000_Zyla_%s_Widefield_%03d.tif' % (chan, zIdx) tifffile.imsave(outdir+pos+out_filename, result[zIdx].astype(dtype=np.uint16))
requires installation of python and other python packlages, which are included in the anaconda python release. pyCUDAdecon and instructions to install and use are at https://github.com/tlambert03/pycudadecon """ #import required packages from pycudadecon import decon, make_otf from skimage.external.tifffile import imsave # set input a and output file paths image_path = 'C1-YeastTNA1_1516_conv_RG_26oC_003.tif' psf_path = 'gpsf_3D_1514_a3_001_WF-sub105.tif' otfOutPath = 'otf.tif' # do the deconvolution on GPU numIters = 30 result = decon(image_path, psf_path, n_iters=numIters) print("result data type is " + str(result.dtype)) print('results numpy array shape is ') print(result.shape) # save the result, print('Saving result image TIFF file') # using skimage.external.tifffile.imsave imsave(('result' + str(numIters) + 'iterations.tif'), result) #, imagej) # save otf tiff file from PSF image tiff. print('making otf') make_otf(psf_path, otfOutPath, dzpsf=0.15, dxpsf=0.05, wavelength=510, na=1.3, nimm=1.333, otf_bgrd=None, krmax=0, fixorigin=10, cleanup_otf=True, max_otf_size=60000)
def test_decon_wrapper_save_deskewed(raw_image, config): """test that save_deskewed includes deskewed when passing raw image""" config["deskew"] = 31.5 decon_result = decon(raw_image, OTF_PATH, save_deskewed=True, **config) assert len(decon_result) == 2
def test_decon_wrapper_with_variable_shapes(deskewed_image, config): """test passing a list of variabel shape images to decon""" im = deskewed_image images = [im, im[:, 4:-4, 4:-4], im[2:-2, 16:-16, 16:-16]] decon(images, OTF_PATH, **config)
def test_decon_wrapper_with_many_inputs(deskewed_image, decon_image, config): """test passing a list of images to decon""" images = [deskewed_image, deskewed_image, deskewed_image] for d in decon(images, OTF_PATH, **config): npt.assert_allclose(d, decon_image, atol=ATOL)
def test_decon_wrapper_with_psf_array(deskewed_image, decon_image, config): """test that we can deconvolve an image with psf as array""" decon_result = decon(deskewed_image, imread(PSF_PATH), **config) npt.assert_allclose(decon_result, decon_image, atol=ATOL)
def test_decon_wrapper_with_psf(deskewed_image, decon_image, config): """test that we can deconvolve an image with psf as string""" decon_result = decon(deskewed_image, PSF_PATH, **config) npt.assert_allclose(decon_result, decon_image, atol=ATOL)
def test_decon_wrapper_with_otf(deskewed_image, decon_image, config): """test that we can deconvolve when provided OTF directly""" decon_result = decon(deskewed_image, OTF_PATH, **config) npt.assert_allclose(decon_result, decon_image, atol=ATOL)
def test_decon_wrapper_with_otf(self): """ test that the """ decon_result = decon(self.deskewed, self.otf, **self.config) self.assertTrue(np.allclose(decon_result, self.stored_decon))