def auto_find_minimisation_sqsum(self, slices: List[int], recon_params: ReconstructionParameters, initial_cor: Union[float, List[float]], progress: Progress) -> List[float]: """ :param slices: Slice indices to be reconstructed :param recon_params: Reconstruction parameters :param initial_cor: Initial COR for the slices. Will be used as the start for the minimisation. If a float is passed it will be used for all slices. If a list is passed, the COR will be retrieved for each slice. :param progress: Progress reporter """ # Ensure we have some sample data if self.images is None: return [0.0] if isinstance(initial_cor, list): assert len(slices) == len(initial_cor), "A COR for each slice index being reconstructed must be provided" else: # why be efficient when you can be lazy? initial_cor = [initial_cor] * len(slices) reconstructor = get_reconstructor_for(recon_params.algorithm) progress = Progress.ensure_instance(progress, num_steps=len(slices)) progress.update(0, msg=f"Calculating COR for slice {slices[0]}") cors = [] for idx, slice in enumerate(slices): cor = reconstructor.find_cor(self.images, slice, initial_cor[idx], recon_params) cors.append(cor) progress.update(msg=f"Calculating COR for slice {slice}") return cors
def run_full_recon(self, recon_params: ReconstructionParameters, progress: Progress) -> Optional[Images]: # Ensure we have some sample data images = self.images if images is None: return None reconstructor = get_reconstructor_for(recon_params.algorithm) # get the image height based on the current ROI recon = reconstructor.full(images, self.data_model.get_all_cors_from_regression(images.height), recon_params, progress) recon = self._apply_pixel_size(recon, recon_params, progress) return recon
def __init__(self, images: Images, slice_idx: int, initial_cor: ScalarCoR, recon_params: ReconstructionParameters): self.image_width = images.width self.sino = images.sino(slice_idx) # Initial parameters self.centre_cor = initial_cor.value self.cor_step = 50 # Cache projection angles self.proj_angles = images.projection_angles() self.recon_params = recon_params self.reconstructor = get_reconstructor_for(recon_params.algorithm)
def run_preview_recon( self, slice_idx, cor: ScalarCoR, recon_params: ReconstructionParameters) -> Optional[Images]: # Ensure we have some sample data if self.images is None: return None # Perform single slice reconstruction reconstructor = get_reconstructor_for(recon_params.algorithm) output_shape = (1, self.images.width, self.images.width) recon: Images = Images.create_empty_images(output_shape, self.images.dtype, self.images.metadata) recon.data[0] = reconstructor.single_sino( self.images.sino(slice_idx), cor, self.images.projection_angles(recon_params.max_projection_angle), recon_params) recon = self._apply_pixel_size(recon, recon_params) return recon
def __init__(self, images: Images, slice_idx: int, initial_cor: ScalarCoR, recon_params: ReconstructionParameters, iters_mode: bool): self.image_width = images.width self.sino = images.sino(slice_idx) # Initial parameters if iters_mode: self.centre_value: Union[int, float] = INIT_ITERS_CENTRE_VALUE self.step = INIT_ITERS_STEP self.initial_cor = initial_cor self._recon_preview = self._recon_iters_preview self._divide_step = self._divide_iters_step else: self.centre_value = initial_cor.value self.step = self.image_width * 0.05 self._recon_preview = self._recon_cor_preview self._divide_step = self._divide_cor_step # Cache projection angles self.proj_angles = images.projection_angles(recon_params.max_projection_angle) self.recon_params = recon_params self.reconstructor = get_reconstructor_for(recon_params.algorithm)
def get_allowed_filters(alg_name: str): reconstructor = get_reconstructor_for(alg_name) return reconstructor.allowed_filters()