diff --git a/mu_map/recon/filter.py b/mu_map/recon/filter.py index ffcc956f4331cb9c00e541d0be6655ce05ce436f..bc15941f18840b841014e10574037f9e2e05b32e 100644 --- a/mu_map/recon/filter.py +++ b/mu_map/recon/filter.py @@ -1,5 +1,8 @@ from mu_map.file.interfile import Interfile, InterfileKeys +""" +Template for a Gaussian post-filter in a STIR reconstruction. +""" TEMPLATE_FILTER_GAUSSIAN_PARAMS = """ post-filter type := Separable Gaussian separable gaussian filter parameters := @@ -13,9 +16,21 @@ separable gaussian filter parameters := end separable gaussian filter parameters := """ + class GaussianFilter: + """ + Class handling a Gaussian post-filter in a reconstruction. + """ def __init__(self, projection: Interfile, width_scale: int = 1.0): + """ + Initialize a Gaussian post-filter for the reconstruction of a projection. + + :param projection: the projection for which the filter is created + :param width_scale: the width of the filter in each dimension is this scale + times the spacing defined in the projection + :returns: an object which can add this filter to reconstruction parameters + """ header, _ = projection self.params = TEMPLATE_FILTER_GAUSSIAN_PARAMS @@ -31,7 +46,13 @@ class GaussianFilter: self.params = self.params.replace("{SIZE_Y}", header[InterfileKeys.dim(1)]) self.params = self.params.replace("{SIZE_Z}", header[InterfileKeys.dim(2)]) - def insert(self, osem_params: str): + def insert(self, osem_params: str) -> str: + """ + Inter this filter into a string of OSEM parameters for STIR. + + :param osem_params: the params in which this filter is inserted + :return: the params with inserted filter + """ lines = self.params.strip().split("\n") lines = list(map(lambda line: " " + line, lines)) lines.append("\n")