Skip to content

Commit

Permalink
Merge pull request #73 from kostrykin/superdsm
Browse files Browse the repository at this point in the history
adapts environment variables and annotations for SuperDSM
  • Loading branch information
kostrykin authored Nov 3, 2023
2 parents 05fa2c1 + dd4c3d7 commit be7a5ea
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 64 deletions.
11 changes: 5 additions & 6 deletions tools/superdsm/run-superdsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
import shutil
import tempfile

import ray
import superdsm.automation
import superdsm.io
import superdsm.render


hyperparameters = [
('AF_scale', float),
Expand Down Expand Up @@ -71,7 +66,11 @@ def create_config(args):

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 ray
import superdsm.automation
import superdsm.io
import superdsm.render

ray.init(num_cpus=num_processes, log_to_driver=True)

Expand Down
125 changes: 67 additions & 58 deletions tools/superdsm/superdsm.xml
Original file line number Diff line number Diff line change
@@ -1,67 +1,76 @@
<tool id="ip_superdsm" name="Perform segmentation using deformable shape models" version="0.1.3+galaxy1" profile="20.05">
<description>with SuperDSM</description>
<tool id="ip_superdsm" name="Perform segmentation using deformable shape models" version="0.1.3+galaxy2" profile="20.05">
<description>with SuperDSM</description>
<edam_operations>
<edam_operation>operation_3443</edam_operation>
</edam_operations>
<requirements>
<xrefs>
<xref type="bio.tools">superdsm</xref>
<xref type="biii">superdsm</xref>
</xrefs>
<requirements>
<requirement type="package" version="0.1.3">superdsm</requirement>
<requirement type="package" version="1.6.0">ray-core</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="2020.0">mkl</requirement><!-- this seems to be the last version of MKL which supports the "MKL_DEBUG_CPU_TYPE" environment variable -->
<requirement type="package" version="*=mkl">blas</requirement><!-- using MKL instead of other BLAS can significantly improve performance on some hardware, cf. https://stackoverflow.com/questions/62783262/why-is-numpy-with-ryzen-threadripper-so-much-slower-than-xeon -->
</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>
<environment_variables>
<environment_variable name="MKL_DEBUG_CPU_TYPE">5</environment_variable><!-- this enables accelerated CPU instruction sets on AMD hardware, does nothing in Intel hardware, thus no need to change this -->
</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)" />
<section name="config" title="Hyperparameters" expanded="false">
Expand Down

0 comments on commit be7a5ea

Please sign in to comment.