changeset 2:7fcd96cf0d52 draft

planemo upload for repository https://github.com/BMCV/galaxy-image-analysis/tree/master/tools/superdsm/ commit 597cb3dc531963d02c5db0e4fc2596fcb06728dd
author imgteam
date Wed, 17 Dec 2025 22:28:28 +0000
parents 680b866ba043
children c2412cb5fc2e
files creators.xml run-superdsm.py superdsm.xml test-data/cfg-full.tsv test-data/cfg.tsv tests.xml
diffstat 6 files changed, 487 insertions(+), 104 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/creators.xml	Wed Dec 17 22:28:28 2025 +0000
@@ -0,0 +1,43 @@
+<macros>
+
+    <xml name="creators/bmcv">
+        <organization name="Biomedical Computer Vision Group, Heidelberg Universtiy" alternateName="BMCV" url="http://www.bioquant.uni-heidelberg.de/research/groups/biomedical_computer_vision.html" />
+        <yield />
+    </xml>
+
+    <xml name="creators/kostrykin">
+        <person givenName="Leonid" familyName="Kostrykin"/>
+        <yield/>
+    </xml>
+
+    <xml name="creators/rmassei">
+        <person givenName="Riccardo" familyName="Massei"/>
+        <yield/>
+    </xml>
+
+    <xml name="creators/alliecreason">
+        <person givenName="Allison" familyName="Creason"/>
+        <yield/>
+    </xml>
+
+    <xml name="creators/bugraoezdemir">
+        <person givenName="Bugra" familyName="Oezdemir"/>
+        <yield/>
+    </xml>
+
+    <xml name="creators/thawn">
+        <person givenName="Till" familyName="Korten"/>
+        <yield/>
+    </xml>
+
+    <xml name="creators/pavanvidem">
+        <person givenName="Pavan" familyName="Videm"/>
+        <yield/>
+    </xml>
+
+    <xml name="creators/tuncK">
+        <person givenName="Tunc" familyName="Kayikcioglu"/>
+        <yield/>
+    </xml>
+
+</macros>
--- a/run-superdsm.py	Thu Jul 06 00:01:07 2023 +0000
+++ b/run-superdsm.py	Wed Dec 17 22:28:28 2025 +0000
@@ -7,38 +7,35 @@
 """
 
 import argparse
+import csv
 import imghdr
 import os
 import pathlib
 import shutil
 import tempfile
 
-import ray
-import superdsm.automation
-import superdsm.io
-import superdsm.render
-
 
 hyperparameters = [
     ('AF_scale', float),
-    ('c2f_region_analysis/min_atom_radius', float),
-    ('c2f_region_analysis_min_norm_energy_improvement', float),
-    ('c2f_region_analysis_max_atom_norm_energy', float),
-    ('c2f_region_analysis_max_cluster_marker_irregularity', float),
-    ('dsm_alpha', float),
-    ('dsm_AF_alpha', float),
-    ('global_energy_minimization_betai', float),
-    ('global_energy_minimization_AF_beta', float),
-    ('postprocess_mask_max_distance', int),
-    ('postprocess_mask_stdamp', float),
-    ('postprocess_max_norm_energy', float),
-    ('postprocess_min_contrast', float),
-    ('postprocess_min_object_radius', float),
+    ('c2f-region-analysis/min_atom_radius', float),
+    ('c2f-region-analysis/min_norm_energy_improvement', float),
+    ('c2f-region-analysis/max_atom_norm_energy', float),
+    ('c2f-region-analysis/max_cluster_marker_irregularity', float),
+    ('dsm/alpha', float),
+    ('dsm/AF_alpha', float),
+    ('global-energy-minimization/pruning', str),
+    ('global-energy-minimization/beta', float),
+    ('global-energy-minimization/AF_beta', float),
+    ('postprocess/mask_max_distance', int),
+    ('postprocess/mask_stdamp', float),
+    ('postprocess/max_norm_energy', float),
+    ('postprocess/min_contrast', float),
+    ('postprocess/min_object_radius', float),
 ]
 
 
 def get_param_name(key):
-    return key.replace('/', '_')
+    return key.replace('/', '_').replace('-', '_')
 
 
 def create_config(args):
@@ -50,14 +47,25 @@
     return cfg
 
 
+def flatten_dict(d, sep='/'):
+    result = {}
+    for key, val in d.items():
+        if isinstance(val, dict):
+            for sub_key, sub_val in flatten_dict(val, sep=sep).items():
+                result[f'{key}{sep}{sub_key}'] = sub_val
+        else:
+            result[key] = val
+    return result
+
+
 if __name__ == "__main__":
     parser = argparse.ArgumentParser(description='Segmentation of cell nuclei in 2-D fluorescence microscopy images')
-    parser.add_argument('image', help='Path to the input image')
-    parser.add_argument('cfg', help='Path to the file containing the configuration')
-    parser.add_argument('masks', help='Path to the file containing the segmentation masks')
-    parser.add_argument('overlay', help='Path to the file containing the overlay of the segmentation results')
-    parser.add_argument('seg_border', type=int)
+    parser.add_argument('image', type=str, help='Path to the input image')
     parser.add_argument('slots', type=int)
+    parser.add_argument('--do-masks', type=str, default=None, help='Path to the file containing the segmentation masks')
+    parser.add_argument('--do-cfg', type=str, default=None, help='Path to the file containing the configuration')
+    parser.add_argument('--do-overlay', type=str, default=None, help='Path to the file containing the overlay of the segmentation results')
+    parser.add_argument('--do-overlay-border', type=int)
     for key, ptype in hyperparameters:
         parser.add_argument('--' + get_param_name(key), type=ptype, default=None)
     args = parser.parse_args()
@@ -71,26 +79,54 @@
 
     os.environ['MKL_NUM_THREADS'] = str(num_threads_per_process)
     os.environ['OPENBLAS_NUM_THREADS'] = str(num_threads_per_process)
-    os.environ['MKL_DEBUG_CPU_TYPE'] = '5'
+
+    import giatools.io
+    import ray
+    import superdsm.automation
+    import superdsm.io
+    import superdsm.render
 
-    ray.init(num_cpus=num_processes, log_to_driver=True)
+    # The explicit `dir` and `prefix` is to avoid breaking the 107 byte limit for socket paths in Biocontainers
+    # See for details: https://github.com/BMCV/galaxy-image-analysis/pull/178
+    with tempfile.TemporaryDirectory(dir='/tmp', prefix='superdsm') as tmpdirname:
+        tmpdir = pathlib.Path(tmpdirname)
+        ray.init(num_cpus=num_processes, log_to_driver=True, _temp_dir=str(tmpdir / 'ray'))
 
-    with tempfile.TemporaryDirectory() as tmpdirname:
-        tmpdir = pathlib.Path(tmpdirname)
         img_ext = imghdr.what(args.image)
         img_filepath = tmpdir / f'input.{img_ext}'
         shutil.copy(str(args.image), img_filepath)
 
         pipeline = superdsm.pipeline.create_default_pipeline()
         cfg = create_config(args)
-        img = superdsm.io.imread(img_filepath)
-        data, cfg, _ = superdsm.automation.process_image(pipeline, cfg, img)
+        img = giatools.io.imread(img_filepath, impl=superdsm.io.imread)
 
-        with open(args.cfg, 'w') as fp:
-            cfg.dump_json(fp)
+        # Create configuration if it is required:
+        if args.do_cfg or args.do_overlay or args.do_masks:
+            cfg, _ = superdsm.automation.create_config(pipeline, cfg, img)
+
+        # Perform segmentation if it is required:
+        if args.do_overlay or args.do_masks:
+            print('Performing segmentation')
+            data, cfg, _ = pipeline.process_image(img, cfg)
 
-        overlay = superdsm.render.render_result_over_image(data, border_width=args.seg_border, normalize_img=False)
-        superdsm.io.imwrite(args.overlay, overlay)
+        # Write configuration used for segmentation, or the automatically created one, otherwise:
+        if args.do_cfg:
+            print(f'Writing config to: {args.do_cfg}')
+            with open(args.do_cfg, 'w') as fp:
+                tsv_out = csv.writer(fp, delimiter='\t')
+                tsv_out.writerow(['Hyperparameter', 'Value'])
+                rows = sorted(flatten_dict(cfg.entries).items(), key=lambda item: item[0])
+                for key, value in rows:
+                    tsv_out.writerow([key, value])
 
-        masks = superdsm.render.rasterize_labels(data)
-        superdsm.io.imwrite(args.masks, masks)
+        # Write the overlay image:
+        if args.do_overlay:
+            print(f'Writing overlay to: {args.do_overlay}')
+            overlay = superdsm.render.render_result_over_image(data, border_width=args.do_overlay_border, normalize_img=False)
+            superdsm.io.imwrite(args.do_overlay, overlay)
+
+        # Write the label map:
+        if args.do_masks:
+            print(f'Writing masks to: {args.do_masks}')
+            masks = superdsm.render.rasterize_labels(data)
+            superdsm.io.imwrite(args.do_masks, masks)
--- a/superdsm.xml	Thu Jul 06 00:01:07 2023 +0000
+++ b/superdsm.xml	Wed Dec 17 22:28:28 2025 +0000
@@ -1,66 +1,137 @@
-<tool id="ip_superdsm" name="SuperDSM" version="0.1.3" profile="20.05">
-   <description>globally optimal segmentation method based on superadditivity and deformable shape models for cell nuclei in fluorescence microscopy images</description>
-   <requirements> 
-        <requirement type="package" version="0.1.3">superdsm</requirement>
-        <requirement type="package" version="1.6.0">ray-core</requirement>
+<tool id="ip_superdsm" name="Perform segmentation using deformable shape models" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="20.05">
+    <description>with SuperDSM</description>
+    <macros>
+        <import>creators.xml</import>
+        <import>tests.xml</import>
+        <token name="@TOOL_VERSION@">0.2.0</token>
+        <token name="@VERSION_SUFFIX@">1</token>
+    </macros>
+    <creator>
+        <expand macro="creators/bmcv"/>
+    </creator>
+    <edam_operations>
+        <edam_operation>operation_3443</edam_operation>
+    </edam_operations>
+    <xrefs>
+        <xref type="bio.tools">superdsm</xref>
+        <xref type="biii">superdsm</xref>
+    </xrefs>
+    <requirements>
+
+        <requirement type="package" version="@TOOL_VERSION@">superdsm</requirement>
+        <requirement type="package" version="0.1.1">giatools</requirement>
+
+        <!--
+        Pin the dependencies to specific versions for reproducibility:
+        https://github.com/BMCV/SuperDSM#dependency-version-considerations
+        -->
+        <requirement type="package" version="1.20">numpy</requirement>
+        <requirement type="package" version="1.6.3">scipy</requirement>
         <requirement type="package" version="0.18.1">scikit-image</requirement>
-   </requirements>
-   <command detect_errors="aggressive">
-   <![CDATA[
-   python '$__tool_directory__/run-superdsm.py'
-   '${dataset}'
-   'cfg.json'
-   'masks.png'
-   'overlay.png'
-   $seg_border
-   \${GALAXY_SLOTS:-4}
-   #if str($config.AF_scale) != '':
-       --AF_scale '${config.AF_scale}'
-   #end if
-   #if str($config.c2f_region_analysis_min_atom_radius) != '':
-       --c2f_region_analysis_min_atom_radius '${config.c2f_region_analysis_min_atom_radius}'
-   #end if
-   #if str($config.c2f_region_analysis_min_norm_energy_improvement) != '':
-       --c2f_region_analysis_min_norm_energy_improvement '${config.c2f_region_analysis_min_norm_energy_improvement}'
-   #end if
-   #if str($config.c2f_region_analysis_max_atom_norm_energy) != '':
-       --c2f_region_analysis_max_atom_norm_energy '${config.c2f_region_analysis_max_atom_norm_energy}'
-   #end if
-   #if str($config.c2f_region_analysis_max_cluster_marker_irregularity) != '':
-       --c2f_region_analysis_max_cluster_marker_irregularity '${config.c2f_region_analysis_max_cluster_marker_irregularity}'
-   #end if
-   #if str($config.dsm_alpha) != '':
-       --dsm_alpha '${config.dsm_alpha}'
-   #end if
-   #if str($config.dsm_AF_alpha) != '':
-       --dsm_AF_alpha '${config.dsm_AF_alpha}'
-   #end if
-   #if str($config.global_energy_minimization_beta) != '':
-       --global_energy_minimization_beta '${config.global_energy_minimization_beta}'
-   #end if
-   #if str($config.global_energy_minimization_AF_beta) != '':
-       --global_energy_minimization_AF_beta '${config.global_energy_minimization_AF_beta}'
-   #end if
-   #if str($config.postprocess_mask_max_distance) != '':
-       --postprocess_mask_max_distance '${config.postprocess_mask_max_distance}'
-   #end if
-   #if str($config.postprocess_mask_stdamp) != '':
-       --postprocess_mask_stdamp '${config.postprocess_mask_stdamp}'
-   #end if
-   #if str($config.postprocess_max_norm_energy) != '':
-       --postprocess_max_norm_energy '${config.postprocess_max_norm_energy}'
-   #end if
-   #if str($config.postprocess_min_contrast) != '':
-       --postprocess_min_contrast '${config.postprocess_min_contrast}'
-   #end if
-   #if str($config.postprocess_min_object_radius) != '':
-       --postprocess_min_object_radius '${config.postprocess_min_object_radius}'
-   #end if
-   ]]>
-   </command>
-   <inputs>
+        <requirement type="package" version="1.2.6">cvxopt</requirement>
+        <requirement type="package" version="1.1.13">cvxpy</requirement>
+        <requirement type="package" version="1.6.0">ray-core</requirement>
+
+        <!--
+        2020.0 is the last version of MKL which supports the "MKL_DEBUG_CPU_TYPE" environment variable.
+        -->
+        <requirement type="package" version="2020.0">mkl</requirement>
+
+        <!--
+        Using MKL instead of other BLAS can significantly improve performance on some hardware:
+        https://stackoverflow.com/questions/62783262/why-is-numpy-with-ryzen-threadripper-so-much-slower-than-xeon
+
+        Pinning BLAS to version 1.0 is required for reproducibility:
+        https://github.com/BMCV/SuperDSM#dependency-version-considerations
+        -->
+        <requirement type="package" version="1.0=mkl">blas</requirement>
+
+    </requirements>
+    <command detect_errors="aggressive">
+    <![CDATA[
+    python '$__tool_directory__/run-superdsm.py'
+    '${dataset}'
+    \${GALAXY_SLOTS:-4}
+    #if 'masks' in $outputs:
+        --do-masks 'masks.png'
+    #end if
+    #if 'cfg' in $outputs:
+        --do-cfg 'cfg.tsv'
+    #end if
+    #if 'overlay' in $outputs:
+        --do-overlay 'overlay.png'
+        #if $seg_border.value % 2 == 1:
+            #set $seg_border = "%d" % ($seg_border.value + 1)
+            --do-overlay-border $seg_border
+        #else:
+            --do-overlay-border $seg_border
+        #end if
+    #end if
+    #if str($config.AF_scale) != '':
+        --AF_scale '${config.AF_scale}'
+    #end if
+    #if str($config.c2f_region_analysis_min_atom_radius) != '':
+        --c2f_region_analysis_min_atom_radius '${config.c2f_region_analysis_min_atom_radius}'
+    #end if
+    #if str($config.c2f_region_analysis_min_norm_energy_improvement) != '':
+        --c2f_region_analysis_min_norm_energy_improvement '${config.c2f_region_analysis_min_norm_energy_improvement}'
+    #end if
+    #if str($config.c2f_region_analysis_max_atom_norm_energy) != '':
+        --c2f_region_analysis_max_atom_norm_energy '${config.c2f_region_analysis_max_atom_norm_energy}'
+    #end if
+    #if str($config.c2f_region_analysis_max_cluster_marker_irregularity) != '':
+        --c2f_region_analysis_max_cluster_marker_irregularity '${config.c2f_region_analysis_max_cluster_marker_irregularity}'
+    #end if
+    #if str($config.dsm_alpha) != '':
+        --dsm_alpha '${config.dsm_alpha}'
+    #end if
+    #if str($config.dsm_AF_alpha) != '':
+        --dsm_AF_alpha '${config.dsm_AF_alpha}'
+    #end if
+    --global_energy_minimization_pruning '${global_energy_minimization_pruning}'
+    #if str($config.global_energy_minimization_beta) != '':
+        --global_energy_minimization_beta '${config.global_energy_minimization_beta}'
+    #end if
+    #if str($config.global_energy_minimization_AF_beta) != '':
+        --global_energy_minimization_AF_beta '${config.global_energy_minimization_AF_beta}'
+    #end if
+    #if str($config.postprocess_mask_max_distance) != '':
+        --postprocess_mask_max_distance '${config.postprocess_mask_max_distance}'
+    #end if
+    #if str($config.postprocess_mask_stdamp) != '':
+        --postprocess_mask_stdamp '${config.postprocess_mask_stdamp}'
+    #end if
+    #if str($config.postprocess_max_norm_energy) != '':
+        --postprocess_max_norm_energy '${config.postprocess_max_norm_energy}'
+    #end if
+    #if str($config.postprocess_min_contrast) != '':
+        --postprocess_min_contrast '${config.postprocess_min_contrast}'
+    #end if
+    #if str($config.postprocess_min_object_radius) != '':
+        --postprocess_min_object_radius '${config.postprocess_min_object_radius}'
+    #end if
+    ]]>
+    </command>
+    <environment_variables>
+
+        <!--
+        This enables accelerated CPU instruction sets on AMD hardware, does nothing in Intel hardware, thus no need to change this:
+        -->
+        <environment_variable name="MKL_DEBUG_CPU_TYPE">5</environment_variable>
+
+    </environment_variables>
+    <inputs>
         <param name="dataset" type="data" format="tiff,png" label="Dataset" />
-        <param name="seg_border" type="integer" min="1" value="8" label="Width of the outlines (in pixels) of the segmentation results (overlays)" />
+        <param argument="--global_energy_minimization_pruning" type="select" label="Graph pruning for global energy minimization" help="Exact graph pruning corresponds to the original algorithm, which provably yields globally optimal results. Robust graph pruning is more greedy and has a provably bounded approximation error. Depending on the data, this can be significantly faster than exact graph pruning, without degrading the segmentation or cluster splitting performance.">
+            <option value="exact">Exact graph pruning (Kostrykin and Rohr, TPAMI 2023)</option>
+            <option value="isbi24" selected="true">Robust graph pruning (Kostrykin and Rohr, ISBI 2024)</option>
+        </param>
+        <param name="outputs" type="select" label="Tool outputs" multiple="true" optional="false" help="Note that if neither a segmentation overlay nor a label map is created, segmentation and cluster splitting will not be performed. As a consequence, hyperparameters which are determined automatically during segmentation and cluster splitting will not be reported, even if &quot;Report all hyperparameters&quot; is selected.">
+            <option value="overlay" selected="true">Create a segmentation overlay</option>
+            <option value="masks">Create a label map (e.g., for further processing)</option>
+            <option value="cfg">Report all hyperparameters (manually set and automatically determined values)</option>
+        </param>
+        <param name="seg_border" type="integer" min="1" value="8" label="Width of the outlines (in pixels)" help="This parameter is only used for segmentation overlays (see above)." />
         <section name="config" title="Hyperparameters" expanded="false">
             <param argument="--AF_scale" optional="true" type="float" value="" min="0" label="scale σ" help="The scale of the objects to be segmented. Leave empty to use the automatically determined value." />
             <param argument="--c2f_region_analysis_min_atom_radius" optional="true" type="float" value="" min="0" label="min_atom_radius" help="No region determined by the Coarse-to-fine region analysis scheme is smaller than a circle of this radius (in terms of the surface area). Leave empty to use the automatically determined value." />
@@ -79,22 +150,60 @@
         </section>
     </inputs>
     <outputs>
-        <data format="json" name="cfg" from_work_dir="cfg.json" label="${tool.name} on ${on_string}: cfg" />
-        <data format="png" name="masks" from_work_dir="masks.png" label="${tool.name} on ${on_string}: masks" />
-        <data format="png" name="overlay" from_work_dir="overlay.png" label="${tool.name} on ${on_string}: overlay" />
+        <data format="png" name="masks" from_work_dir="masks.png" label="${tool.name} on ${on_string}: masks">
+            <filter>'masks' in outputs</filter>
+        </data>
+        <data format="tsv" name="cfg" from_work_dir="cfg.tsv" label="${tool.name} on ${on_string}: cfg">
+            <filter>'cfg' in outputs</filter>
+        </data>
+        <data format="png" name="overlay" from_work_dir="overlay.png" label="${tool.name} on ${on_string}: overlay">
+            <filter>'overlay' in outputs</filter>
+        </data>
     </outputs>
     <tests>
-        <test>
+        <test expect_num_outputs="3">
             <param name="dataset" value="BBBC033_C2_z28.png" />
-            <output name="overlay" value="overlay.png" ftype="png" compare="sim_size" />
+            <param name="global_energy_minimization_pruning" value="exact" />
+            <param name="outputs" value="overlay,masks,cfg" />
+            <expand macro="tests/intensity_image_diff" name="overlay" value="overlay.png" ftype="png"/>
+            <output name="cfg" value="cfg-full.tsv" ftype="tsv" compare="diff" />
+            <output name="masks" ftype="png">
+                <assert_contents>
+
+                    <has_image_width width="1024"/>
+                    <has_image_height height="1344"/>
+                    <has_image_channels channels="1"/>
+                    <has_image_n_labels n="16"/><!-- 15 objects plus the background -->
+
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <param name="dataset" value="BBBC033_C2_z28.png" />
+            <param name="global_energy_minimization_pruning" value="exact" />
+            <param name="outputs" value="cfg" />
+            <output name="cfg" value="cfg.tsv" ftype="tsv" compare="diff" />
         </test>
     </tests>
     <help>
-        This tool permits the segmentation of cell nuclei in 2-D fluorescence microscopy images.
+
+        **Performs segmentation of 2-D fluorescence microscopy images using deformable shape models and superadditivity.**
 
-        You can either use an individual input image (PNG, TIF) or a collection of such images.
+        SuperDSM is a globally optimal method for cell nuclei segmentation using deformable shape models and their inherent law of superadditivity.
+
+        You can either use an individual input image (PNG, TIFF) or a collection of such images.
+
     </help>
     <citations>
+        <citation type="bibtex">
+        @inproceedings{kostrykin2024,
+          author = {Kostrykin, L. and Rohr, K.},
+          title = {Robust Graph Pruning for Efficient Segmentation and Cluster Splitting of Cell Nuclei using Deformable Shape Models},
+          booktitle = {Proc. IEEE International Symposium on Biomedical Imaging (ISBI'24)},
+          pages = {accepted for presentation},
+          year = {2024},
+        }
+        </citation>
         <citation type="doi">10.1109/TPAMI.2022.3185583</citation>
     </citations>
 </tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/cfg-full.tsv	Wed Dec 17 22:28:28 2025 +0000
@@ -0,0 +1,68 @@
+Hyperparameter	Value
+AF_scale	
+c2f-region-analysis/AF_min_atom_radius	0.33
+c2f-region-analysis/enabled	True
+c2f-region-analysis/max_atom_norm_energy	0.05
+c2f-region-analysis/max_cluster_marker_irregularity	0.2
+c2f-region-analysis/min_atom_radius	30
+c2f-region-analysis/min_norm_energy_improvement	0.1
+c2f-region-analysis/seed_connectivity	8
+dsm/AF_alpha	0.0005
+dsm/AF_background_margin	0.4
+dsm/AF_smooth_amount	0.2
+dsm/AF_smooth_subsample	0.4
+dsm/alpha	2.116
+dsm/background_margin	26
+dsm/cachesize	1
+dsm/cachetest	
+dsm/cp_timeout	300
+dsm/enabled	True
+dsm/epsilon	1.0
+dsm/gaussian_shape_multiplier	2
+dsm/init	elliptical
+dsm/scale	1000
+dsm/smooth_amount	13
+dsm/smooth_mat_dtype	float32
+dsm/smooth_mat_max_allocations	inf
+dsm/smooth_subsample	26
+dsm/sparsity_tol	0
+global-energy-minimization/AF_beta	0.66
+global-energy-minimization/AF_max_seed_distance	inf
+global-energy-minimization/beta	2793.1200000000003
+global-energy-minimization/enabled	True
+global-energy-minimization/gamma	0.8
+global-energy-minimization/max_iter	5
+global-energy-minimization/max_seed_distance	inf
+global-energy-minimization/max_work_amount	1000000
+global-energy-minimization/pruning	exact
+histological	False
+postprocess/AF_max_object_radius	inf
+postprocess/AF_min_glare_radius	inf
+postprocess/AF_min_object_radius	0.0
+postprocess/contrast_epsilon	0.0001
+postprocess/discard_image_boundary	False
+postprocess/enabled	True
+postprocess/exterior_offset	5
+postprocess/exterior_scale	5
+postprocess/fill_holes	True
+postprocess/glare_detection_min_layer	0.5
+postprocess/glare_detection_num_layers	5
+postprocess/glare_detection_smoothness	3
+postprocess/mask_max_distance	1
+postprocess/mask_smoothness	3
+postprocess/mask_stdamp	2.0
+postprocess/max_boundary_eccentricity	inf
+postprocess/max_eccentricity	0.99
+postprocess/max_norm_energy	0.2
+postprocess/max_object_radius	inf
+postprocess/min_boundary_glare_radius	inf
+postprocess/min_boundary_obj_radius	0
+postprocess/min_contrast	1.35
+postprocess/min_glare_radius	inf
+postprocess/min_object_radius	0.0
+preprocess/AF_sigma2	1.0
+preprocess/enabled	True
+preprocess/lower_clip_mean	False
+preprocess/offset_clip	3
+preprocess/sigma1	1.4142135623730951
+preprocess/sigma2	65.05382386916237
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/cfg.tsv	Wed Dec 17 22:28:28 2025 +0000
@@ -0,0 +1,32 @@
+Hyperparameter	Value
+AF_scale	
+c2f-region-analysis/AF_min_atom_radius	0.33
+c2f-region-analysis/max_atom_norm_energy	0.05
+c2f-region-analysis/max_cluster_marker_irregularity	0.2
+c2f-region-analysis/min_atom_radius	30
+c2f-region-analysis/min_norm_energy_improvement	0.1
+dsm/AF_alpha	0.0005
+dsm/AF_background_margin	0.4
+dsm/AF_smooth_amount	0.2
+dsm/AF_smooth_subsample	0.4
+dsm/alpha	2.116
+dsm/background_margin	26
+dsm/smooth_amount	13
+dsm/smooth_subsample	26
+global-energy-minimization/AF_beta	0.66
+global-energy-minimization/AF_max_seed_distance	inf
+global-energy-minimization/beta	2793.1200000000003
+global-energy-minimization/max_seed_distance	inf
+global-energy-minimization/pruning	exact
+postprocess/AF_max_object_radius	inf
+postprocess/AF_min_glare_radius	inf
+postprocess/AF_min_object_radius	0.0
+postprocess/mask_max_distance	1
+postprocess/mask_stdamp	2.0
+postprocess/max_norm_energy	0.2
+postprocess/max_object_radius	inf
+postprocess/min_contrast	1.35
+postprocess/min_glare_radius	inf
+postprocess/min_object_radius	0.0
+preprocess/AF_sigma2	1.0
+preprocess/sigma2	65.05382386916237
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests.xml	Wed Dec 17 22:28:28 2025 +0000
@@ -0,0 +1,95 @@
+<macros>
+
+    <!-- Macros for verification of image outputs -->
+
+    <xml
+        name="tests/binary_image_diff"
+        tokens="name,value,ftype,metric,eps"
+        token_metric="mae"
+        token_eps="0.01">
+
+        <output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="0">
+            <assert_contents>
+                <has_image_n_labels n="2"/>
+                <yield/>
+            </assert_contents>
+        </output>
+
+    </xml>
+
+    <xml
+        name="tests/label_image_diff"
+        tokens="name,value,ftype,metric,eps,pin_labels"
+        token_metric="iou"
+        token_eps="0.01"
+        token_pin_labels="0">
+
+        <output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="@PIN_LABELS@">
+            <assert_contents>
+                <yield/>
+            </assert_contents>
+        </output>
+
+    </xml>
+
+    <xml
+        name="tests/intensity_image_diff"
+        tokens="name,value,ftype,metric,eps"
+        token_metric="rms"
+        token_eps="0.01">
+
+        <output name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@">
+            <assert_contents>
+                <yield/>
+            </assert_contents>
+        </output>
+
+    </xml>
+
+    <!-- Variants of the above for verification of collection elements -->
+
+    <xml
+        name="tests/binary_image_diff/element"
+        tokens="name,value,ftype,metric,eps"
+        token_metric="mae"
+        token_eps="0.01">
+
+        <element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="0">
+            <assert_contents>
+                <has_image_n_labels n="2"/>
+                <yield/>
+            </assert_contents>
+        </element>
+
+    </xml>
+
+    <xml
+        name="tests/label_image_diff/element"
+        tokens="name,value,ftype,metric,eps"
+        token_metric="iou"
+        token_eps="0.01"
+        token_pin_labels="0">
+
+        <element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@" pin_labels="@PIN_LABELS@">
+            <assert_contents>
+                <yield/>
+            </assert_contents>
+        </element>
+
+    </xml>
+
+    <xml
+        name="tests/intensity_image_diff/element"
+        tokens="name,value,ftype,metric,eps"
+        token_metric="rms"
+        token_eps="0.01">
+
+        <element name="@NAME@" value="@VALUE@" ftype="@FTYPE@" compare="image_diff" metric="@METRIC@" eps="@EPS@">
+            <assert_contents>
+                <yield/>
+            </assert_contents>
+        </element>
+
+    </xml>
+
+</macros>