Skip to content
Snippets Groups Projects
Commit fbe2deeb authored by Tamino Huxohl's avatar Tamino Huxohl
Browse files

document recon filter

parent 673dfc18
No related branches found
No related tags found
No related merge requests found
from mu_map.file.interfile import Interfile, InterfileKeys from mu_map.file.interfile import Interfile, InterfileKeys
"""
Template for a Gaussian post-filter in a STIR reconstruction.
"""
TEMPLATE_FILTER_GAUSSIAN_PARAMS = """ TEMPLATE_FILTER_GAUSSIAN_PARAMS = """
post-filter type := Separable Gaussian post-filter type := Separable Gaussian
separable gaussian filter parameters := separable gaussian filter parameters :=
...@@ -13,9 +16,21 @@ separable gaussian filter parameters := ...@@ -13,9 +16,21 @@ separable gaussian filter parameters :=
end separable gaussian filter parameters := end separable gaussian filter parameters :=
""" """
class GaussianFilter: class GaussianFilter:
"""
Class handling a Gaussian post-filter in a reconstruction.
"""
def __init__(self, projection: Interfile, width_scale: int = 1.0): 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 header, _ = projection
self.params = TEMPLATE_FILTER_GAUSSIAN_PARAMS self.params = TEMPLATE_FILTER_GAUSSIAN_PARAMS
...@@ -31,7 +46,13 @@ class GaussianFilter: ...@@ -31,7 +46,13 @@ class GaussianFilter:
self.params = self.params.replace("{SIZE_Y}", header[InterfileKeys.dim(1)]) self.params = self.params.replace("{SIZE_Y}", header[InterfileKeys.dim(1)])
self.params = self.params.replace("{SIZE_Z}", header[InterfileKeys.dim(2)]) 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 = self.params.strip().split("\n")
lines = list(map(lambda line: " " + line, lines)) lines = list(map(lambda line: " " + line, lines))
lines.append("\n") lines.append("\n")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment