def test_iterative(self): cell = Cell(input_voxel_size=1, size=[10, 10, 10], phi=0, theta=0) psf = PSF(sigma=0.1, aspect_ratio=2) psf.save('data/psf.tif') cell.convolve(psf) cell.save('data/cell.tif') iterative_deconvolve_3d(inputfile=os.getcwd() + '/data/cell.tif', psffile=os.getcwd() + '/data/psf.tif', outputfile=os.getcwd() + '/data/deconvolved.tif', normalize=False, perform=True, detect=True, wiener=0, low=5, terminate=0.001, iterations=2) self.assertEqual(os.path.exists('data/deconvolved.tif'), True) shutil.rmtree('data/')
def __convolve_batch_helper(item, inputfolder, psffolder, outputfolder, **kwargs_to_ignore): inputfile, psffile = item stack = Stack(filename=inputfolder + inputfile) psf = PSF(filename=psffolder + psffile) stack.convolve(psf) stack.save(outputfolder + psffile[:-4] + '/' + inputfile) for c in ['PSF sigma xy um', 'PSF aspect ratio']: stack.metadata[c] = psf.metadata[c] stack.metadata.save(outputfolder + psffile[:-4] + '/' + inputfile[:-4] + '.csv') psf.save(outputfolder + psffile) psf.metadata.save(outputfolder + psffile[:-4] + '.csv')
def test_rltv(self): cell = Cell(input_voxel_size=1, size=[10, 10, 10], phi=0, theta=0) psf = PSF(sigma=0.1, aspect_ratio=2) psf.save('data/psf.tif') cell.convolve(psf) cell.save('data/cell.tif') imagej_path = get_fiji_path() deconvolution_lab_rltv(imagej_path=imagej_path, inputfile=os.getcwd() + '/data/cell.tif', psffile=os.getcwd() + '/data/psf.tif', regularization_lambda=0.001, iterations=2, outputfile=os.getcwd() + '/data/deconvolved.tif') self.assertEqual(os.path.exists('data/deconvolved.tif'), True) shutil.rmtree('data/')
def __generate_psfs_batch_helper(item, outputfolder, input_voxel_size, **kwargs_to_ignore): metadata = Metadata() metadata.set_voxel_size(input_voxel_size) sigma, aspect_ratio = item sigmaz = sigma * aspect_ratio sigmax = sigma / metadata['Voxel size x'] sigmaz = sigmaz / metadata['Voxel size z'] psf = PSF(sigma=sigmax, aspect_ratio=sigmaz / sigmax) psf.save(outputfolder + 'psf_sigma_' + str(sigma) + '_aspect_ratio_' + str(aspect_ratio) + '.tif', normalize_output=True) metadata['PSF sigma xy um'] = sigma metadata['PSF aspect ratio'] = aspect_ratio metadata['isPSF'] = True metadata.save(outputfolder + 'psf_sigma_' + str(sigma) + '_aspect_ratio_' + str(aspect_ratio) + '.csv')