def setUp(self): self.sim = Simulation(n=1024, filters=SourceFilter([ RadialCTFFilter(defocus=d) for d in np.linspace(1.5e4, 2.5e4, 7) ], n=1024))
def testRadialCTFFilterMultiplier(self): filter = RadialCTFFilter(defocus=2.5e4) * RadialCTFFilter(defocus=2.5e4) result = filter.evaluate_grid(8) self.assertEqual(result.shape, (8, 8)) self.assertTrue(np.allclose( result, np.array([ [ 0.461755701877834, -0.995184514498978, 0.063120922443392, 0.833250206225063, 0.961464660252150, 0.833250206225063, 0.063120922443392, -0.995184514498978], [-0.995184514498978, 0.626977423649552, 0.799934516166400, 0.004814348317439, -0.298096205735759, 0.004814348317439, 0.799934516166400, 0.626977423649552], [ 0.063120922443392, 0.799934516166400, -0.573061561512667, -0.999286510416273, -0.963805291282899, -0.999286510416273, -0.573061561512667, 0.799934516166400], [ 0.833250206225063, 0.004814348317439, -0.999286510416273, -0.633095739808868, -0.368890743119366, -0.633095739808868, -0.999286510416273, 0.004814348317439], [ 0.961464660252150, -0.298096205735759, -0.963805291282899, -0.368890743119366, -0.070000000000000, -0.368890743119366, -0.963805291282899, -0.298096205735759], [ 0.833250206225063, 0.004814348317439, -0.999286510416273, -0.633095739808868, -0.368890743119366, -0.633095739808868, -0.999286510416273, 0.004814348317439], [ 0.063120922443392, 0.799934516166400, -0.573061561512667, -0.999286510416273, -0.963805291282899, -0.999286510416273, -0.573061561512667, 0.799934516166400], [-0.995184514498978, 0.626977423649552, 0.799934516166400, 0.004814348317439, -0.298096205735759, 0.004814348317439, 0.799934516166400, 0.626977423649552] ])**2 ))
def setUp(self): sim = Simulation(n=1024, filters=SourceFilter([ RadialCTFFilter(defocus=d) for d in np.linspace(1.5e4, 2.5e4, 7) ], n=1024)) basis = FBBasis3D((8, 8, 8)) self.estimator = MeanEstimator(sim, basis, preconditioner='none') self.estimator_with_preconditioner = MeanEstimator( sim, basis, preconditioner='circulant')
def testRadialCTFSourceFilter(self): source_filter = SourceFilter( [RadialCTFFilter(defocus=d) for d in np.linspace(1.5e4, 2.5e4, 7)], n=42 ) result = source_filter.evaluate_grid(8) self.assertEqual(result.shape, (8, 8, 7)) # Just check the value of the last filter for now self.assertTrue(np.allclose( result[:, :, -1], np.array([ [ 0.461755701877834, -0.995184514498978, 0.063120922443392, 0.833250206225063, 0.961464660252150, 0.833250206225063, 0.063120922443392, -0.995184514498978], [-0.995184514498978, 0.626977423649552, 0.799934516166400, 0.004814348317439, -0.298096205735759, 0.004814348317439, 0.799934516166400, 0.626977423649552], [ 0.063120922443392, 0.799934516166400, -0.573061561512667, -0.999286510416273, -0.963805291282899, -0.999286510416273, -0.573061561512667, 0.799934516166400], [ 0.833250206225063, 0.004814348317439, -0.999286510416273, -0.633095739808868, -0.368890743119366, -0.633095739808868, -0.999286510416273, 0.004814348317439], [ 0.961464660252150, -0.298096205735759, -0.963805291282899, -0.368890743119366, -0.070000000000000, -0.368890743119366, -0.963805291282899, -0.298096205735759], [ 0.833250206225063, 0.004814348317439, -0.999286510416273, -0.633095739808868, -0.368890743119366, -0.633095739808868, -0.999286510416273, 0.004814348317439], [ 0.063120922443392, 0.799934516166400, -0.573061561512667, -0.999286510416273, -0.963805291282899, -0.999286510416273, -0.573061561512667, 0.799934516166400], [-0.995184514498978, 0.626977423649552, 0.799934516166400, 0.004814348317439, -0.298096205735759, 0.004814348317439, 0.799934516166400, 0.626977423649552] ]) ))
def setUpClass(cls): cls.sim = Simulation(n=1024, filters=SourceFilter([ RadialCTFFilter(defocus=d) for d in np.linspace(1.5e4, 2.5e4, 7) ], n=1024)) basis = FBBasis3D((8, 8, 8)) cls.noise_variance = 0.0030762743633643615 cls.mean_estimator = MeanEstimator(cls.sim, basis) cls.mean_est = np.load(os.path.join(DATA_DIR, 'mean_8_8_8.npy')) # Passing in a mean_kernel argument to the following constructor speeds up some calculations cls.covar_estimator = CovarianceEstimator( cls.sim, basis, mean_kernel=cls.mean_estimator.kernel, preconditioner='none') cls.covar_estimator_with_preconditioner = CovarianceEstimator( cls.sim, basis, mean_kernel=cls.mean_estimator.kernel, preconditioner='circulant')
parser.add_argument('--num_volumes', default=2, type=int) parser.add_argument('--image_size', default=8, type=int) parser.add_argument('--num_images', default=1024, type=int) parser.add_argument('--num_eigs', default=16, type=int) with parser.parse_args() as args: C = args.num_volumes L = args.image_size n = args.num_images sim = Simulation( n=n, C=C, filters=SourceFilter( [RadialCTFFilter(defocus=d) for d in np.linspace(1.5e4, 2.5e4, 7)], n=n ) ) basis = FBBasis3D((L, L, L)) noise_estimator = WhiteNoiseEstimator(sim, batchSize=500) # Estimate the noise variance. This is needed for the covariance estimation step below. noise_variance = noise_estimator.estimate() print(f'Noise Variance = {noise_variance}') """ Estimate the mean. This uses conjugate gradient on the normal equations for the least-squares estimator of the mean volume. The mean volume is represented internally using the basis object, but the output is in the form of an L-by-L-by-L array. """