From 0b535dfba7881ea46fabc835225df93abc6f3fca Mon Sep 17 00:00:00 2001 From: Andrew Herzing Date: Fri, 28 Jun 2024 10:16:39 -0400 Subject: [PATCH] Added docstrings for several functions --- tomotools/base.py | 5 +---- tomotools/recon.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/tomotools/base.py b/tomotools/base.py index 590a0318..931c7bfe 100644 --- a/tomotools/base.py +++ b/tomotools/base.py @@ -327,10 +327,7 @@ class TomoStack(CommonStack): """ def plot_sinos(self, *args, **kwargs): - """ - Plot the TomoStack in sinogram orientation. - - """ + """Plot the TomoStack in sinogram orientation.""" self.swap_axes(1, 0).swap_axes(1, 2).plot(navigator='slider', *args, **kwargs) return diff --git a/tomotools/recon.py b/tomotools/recon.py index ffc90361..e607ba27 100644 --- a/tomotools/recon.py +++ b/tomotools/recon.py @@ -348,12 +348,44 @@ def run(stack, method, niterations=20, constrain=None, thresh=0, cuda=None, thic def dart_segment(rec, thresholds, gray_vals): + """ + Segmentation step for DART Reconstruction. + + Args + ---------- + rec : NumPy array + Tomographic reconstruction. + thresholds : list or NumPy array + Threshold values for segmentation. + gray_vals : list or NumPy array + Grayscale values to assign the segmented regions. + + Returns + ---------- + segmented : NumPy array + Segmented version of the reconstruction. + + """ bins = np.digitize(rec, bins=thresholds, right=False) segmented = np.array(gray_vals)[bins] return segmented def get_dart_boundaries(segmented): + """ + Boundary step for DART Reconstruction. + + Args + ---------- + segmented : NumPy array + Segmented reconstruction. + + Returns + ---------- + boundaries : NumPy array + Boundaries of the segmented reconstruction. + + """ kernel = np.array([[1, 1, 1], [1, -8, 1], [1, 1, 1]])