view omero_hyperstack_to_gastruloid_measurements.xml @ 2:45375dc5dd8d draft default tip

planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/omero_hyperstack_to_gastruloid_measurements commit 5e181f51312e53a72d354584439fa9359cd16723-dirty
author lldelisle
date Thu, 15 Feb 2024 12:28:09 +0000
parents bd5771ff6aa3
children
line wrap: on
line source

<tool id="omero_hyperstack_to_gastruloid_measurements" name="Omero hyperstack to Gastruloid measurements" profile="20.01" version="@TOOL_VERSION@+galaxy0">
    <macros>
        <token name="@TOOL_VERSION@">20240214</token>
        <xml name="segmentation">
            <conditional name="use_ilastik">
                <param name="segmentation_method" type="select" label="Segmentation method">
                    <option value="convert_to_mask">Simply convert to mask</option>
                    <option value="ilastik">Use an ilastik project</option>
                </param>
                <when value="ilastik">
                    <param name="ilastik_project" type="data" format="h5" label="Ilastik project" />
                    <param name="ilastik_project_type" type="select" label="Type of Ilastik project">
                        <option value="Regular">Regular</option>
                        <option value="Auto-context">Auto-context</option>
                    </param>
                    <param name="ilastik_label_OI" type="integer" value="3" label="Index of label of interest in Ilastik project" />
                    <param name="probability_threshold" type="float" min="0" max="1" value="0.4" label="Probability threshold for ilastik" />
                    <conditional name="background">
                        <param name="get_background" type="select" label="Get ROI with background" help="Can be useful to normalize fluo">
                            <option value="yes">Yes</option>
                            <option value="no">No</option>
                        </param>
                        <when value="yes">
                            <param name="ilastik_label_BG" type="integer" value="1" label="Index of label of background in Ilastik project" />
                            <param name="probability_threshold_BG" type="float" min="0" max="1" value="0.8" label="Probability threshold for background in ilastik" />                    
                        </when>
                        <when value="no">
                            <param name="ilastik_label_BG" type="hidden" value="0"/>
                            <param name="probability_threshold_BG" type="hidden" value="0"/>
                        </when>
                    </conditional>
                    <param name="thresholding_method" type="hidden" value="Default"/>
                </when>
                <when value="convert_to_mask">
                    <param name="thresholding_method" type="select" label="Thresholding method" help="Method to use in the convert to mask">
                        <option value="Default">Default</option>
                        <option value="Huang">Huang</option>
                        <option value="Intermodes">Intermodes</option>
                        <option value="IsoData">IsoData</option>
                        <option value="IJ_IsoData">IJ_IsoData</option>
                        <option value="Li">Li</option>
                        <option value="MaxEntropy">MaxEntropy</option>
                        <option value="Mean">Mean</option>
                        <option value="MinError">MinError</option>
                        <option value="Minimum">Minimum</option>
                        <option value="Moments">Moments</option>
                        <option value="Otsu">Otsu</option>
                        <option value="Percentile">Percentile</option>
                        <option value="RenyiEntropy">RenyiEntropy</option>
                        <option value="Shanbhag">Shanbhag</option>
                        <option value="Triangle">Triangle</option>
                        <option value="Yen">Yen</option>
                    </param>
                    <param name="ilastik_project_type" type="hidden" value="Regular" />
                    <param name="ilastik_label_OI" type="hidden" value="3" />
                    <param name="probability_threshold" type="hidden" value="0" />
                    <section name="background" title="" >
                        <param name="ilastik_label_BG" type="hidden" value="0"/>
                        <param name="probability_threshold_BG" type="hidden" value="0"/>
                    </section>
                </when>
            </conditional>
            <section name="options" title="Options..." expanded="false" >
                <param name="options_do" type="select" label="In Options... do=" help="Operation to perform after thresholding">
                    <option value="Nothing">Nothing</option>
                    <option value="Erode">Erode</option>
                    <option value="Dilate">Dilate</option>
                    <option value="Open">Open</option>
                    <option value="Close">Close</option>
                    <option value="Outline">Outline</option>
                    <option value="Fill">Fill</option>
                    <option value="Holes">Holes</option>
                    <option value="Skeletonize">Skeletonize</option>
                </param>
                <param name="options_iteration" type="integer" min="1" value="1" label="In Options... iteration=" />
                <param name="options_count" type="integer" min="1" max="8" value="1" label="In Options... count=" />
            </section>
            <param name="fill_holes_before_median" type="boolean" truevalue="true" falsevalue="false" checked="false" label="Fill holes before the Median..." />
            <param name="radius_median" type="float" value="10" label="Radius for median (=smooth the mask)" />
            <param name="min_size_particle" type="float" min="0" value="20000" label="Minimum surface for Analyze Particle" />
            <param name="keep_only_largest" type="boolean" truevalue="true" falsevalue="false" checked="true" label="Keep only one gastruloid per timepoint" />
        </xml>
    </macros>
    <requirements>
        <requirement type="package" version="20231211">fiji</requirement>
        <requirement type="package" version="3.7">python</requirement>
        <requirement type="package" version="2.1.0">fiji-max_inscribed_circles</requirement>
        <requirement type="package" version="1.8.2">fiji-ilastik</requirement>
        <requirement type="package" version="5.8.3">fiji-omero_ij</requirement>
        <requirement type="package" version="5.16.0">fiji-simple_omero_client</requirement>
    </requirements>
    <command detect_errors="exit_code"><![CDATA[
        ## the user wants to use a non-public OMERO instance
        ## check if credentials are set in the user-preferences, if not warn the user and exit
        #set $username = $__user__.extra_preferences.get('omero_account|username', "")
        #set $password = $__user__.extra_preferences.get('omero_account|password', "")

        #if ($username == "" or $password ==""):
            echo "OMERO connection credentials are empty. Set your credentials via: User -> Preferences -> Manage Information" 1>&2 &&
            exit 1 &&
        #end if
        #if str($mode.use_ilastik.segmentation_method) == "ilastik":
            #set $ilastik_project_file = str($mode.use_ilastik.ilastik_project)
            #set $ilastik_project_name = str($mode.use_ilastik.ilastik_project.name)
        #else
            #set $ilastik_project_file = "inexisting.ilp"
            #set $ilastik_project_name = "inexisting.ilp"
        #end if

        mkdir output &&
        ## Because ilastik wants to write to ${HOME}/.cache and ${HOME}/.config
        export HOME=`pwd` &&
        ImageJ-ilastik --ij2 --headless --console --run '$__tool_directory__/'1-omero_timelapse_image_to_measurements_phase.groovy 
            'USERNAME="",PASSWORD="",credentials="${credentials}",host="${omero_host}",port="${omero_port}",object_type="${omero_object.object_type}",id="${omero_object.omero_id}",segmentation_method="${mode.use_ilastik.segmentation_method}",use_existing="${mode.use_existing}",ilastik_project="$ilastik_project_file",ilastik_project_short_name="$ilastik_project_name",ilastik_project_type="${mode.use_ilastik.ilastik_project_type}",ilastik_label_OI="${mode.use_ilastik.ilastik_label_OI}",probability_threshold="${mode.use_ilastik.probability_threshold}",radius_median="${mode.radius_median}",min_size_particle="${mode.min_size_particle}",get_spine="true",minimum_diameter_um="${minimum_diameter_um}",closeness_tolerance_um="${closeness_tolerance_um}",min_similarity="${min_similarity}",output_directory="output",debug="${debug}",rescue="${mode.rescue}",ilastik_label_BG="${mode.use_ilastik.background.ilastik_label_BG}",probability_threshold_BG="${mode.use_ilastik.background.probability_threshold_BG}",keep_only_largest="${mode.keep_only_largest}",replace_at_runtime="${mode.replace_at_runtime}",thresholding_method="${mode.use_ilastik.thresholding_method}",options_do="${mode.options.options_do}",options_iteration="${mode.options.options_iteration}",options_count="${mode.options.options_count}",fill_holes_before_median="${mode.fill_holes_before_median}"' > output.log
        ]]>
    </command>
    <configfiles>
        <configfile name="credentials"><![CDATA[#set $username = $__user__.extra_preferences.get('omero_account|username', "")
#set $password = $__user__.extra_preferences.get('omero_account|password', "")
$username
$password
        ]]></configfile>
    </configfiles>
    <inputs>
        <param name="omero_host" type="text" label="OMERO host URL">
            <validator type="regex" message="Enter a valid host location, for example, your.omero.server">^[a-zA-Z0-9._-]*$</validator>
            <validator type="expression" message="No two dots (..) allowed">'..' not in value</validator>
        </param>
        <param name="omero_port" type="integer" value="4064" label="Omero port" />
        <conditional name="omero_object">
            <param name="object_type" type="select" label="Type of object to analyze">
                <option value="image">Single Omero Image</option>
                <option value="well">All images of a Well</option>
                <option value="plate">All images of a Plate</option>
                <option value="dataset">All images of a Dataset</option>
            </param>
            <when value="image">
                <param name="omero_id" type="integer" value="" label="Image ID on omero" />
            </when>
            <when value="well">
                <param name="omero_id" type="integer" value="" label="Well ID on omero" />
            </when>
            <when value="plate">
                <param name="omero_id" type="integer" value="" label="Plate ID on omero" />
            </when>
            <when value="dataset">
                <param name="omero_id" type="integer" value="" label="Dataset ID on omero" />
            </when>
        </conditional>
        <conditional name="mode">
            <param name="mode_select" type="select" label="Which mode do you want to use?" >
                <option value="replace_existing">Replace existing (not recommanded with Ilastik)</option>
                <option value="spine_only">Recompute only spine</option>
                <option value="regular">Regular (from scratch)</option>
                <option value="rescue">Rescue (if Regular did not go to the end)</option>
            </param>
            <when value="replace_existing">
                <expand macro="segmentation"/>
                <param name="replace_at_runtime" type="hidden" value="true"/>
                <param name="rescue" type="hidden" value="false"/>
                <param name="use_existing" type="hidden" value="false"/>
            </when>
            <when value="regular">
                <expand macro="segmentation"/>
                <param name="replace_at_runtime" type="hidden" value="false"/>
                <param name="rescue" type="hidden" value="false"/>
                <param name="use_existing" type="hidden" value="false"/>
            </when>
            <when value="rescue">
                <expand macro="segmentation"/>
                <param name="replace_at_runtime" type="hidden" value="false"/>
                <param name="rescue" type="hidden" value="true"/>
                <param name="use_existing" type="hidden" value="false"/>
            </when>
            <when value="spine_only">
                <section name="use_ilastik" title="" >
                    <param name="segmentation_method" type="hidden" value="convert_to_mask" />
                    <param name="ilastik_project_type" type="hidden" value="Regular" />
                    <param name="ilastik_label_OI" type="hidden" value="3" />
                    <param name="probability_threshold" type="hidden" value="0" />
                    <section name="background" title="" >
                        <param name="ilastik_label_BG" type="hidden" value="0"/>
                        <param name="probability_threshold_BG" type="hidden" value="0"/>
                    </section>
                </section>
                <param name="replace_at_runtime" type="hidden" value="false"/>
                <param name="radius_median" type="hidden" value="10" />
                <param name="min_size_particle" type="hidden" value="20000" />
                <param name="keep_only_largest" type="hidden" value="true"/>
                <param name="rescue" type="hidden" value="false"/>
                <param name="use_existing" type="hidden" value="true"/>
            </when>
        </conditional>
        <param name="minimum_diameter_um" type="float" min="0" value="40" label="Minimum diameter of inscribed circles (in um)" />
        <param name="closeness_tolerance_um" type="float" min="0" value="50" label="Closeness Tolerance for the spine (in um)" help="Maximum distance between circles along the spine"/>
        <param name="min_similarity" type="float" min="-1" max="1" value="0.1" label="Min similarity for the spine" help="Close to 0 values allow more U shapes while close to 1 values only allows I shapes" />
        <param name="debug" type="boolean" truevalue="true" falsevalue="false" checked="false" label="Debug the elongation index" help="This will output all inscribed circles" />
        <param name="keep_intermediate" type="boolean" checked="false" label="Keep intermediate results (ilastik prediction + tables)" />
    </inputs>

    <outputs>
        <data name="logfile" format="txt" from_work_dir="output.log" label="${tool.name} on ${omero_object.object_type} ID ${omero_object.omero_id} with $getVar('mode.use_ilastik.ilastik_project.name', 'no ilastik'): logfile">
        </data>
        <collection name="tables" type="list" label="${tool.name} on ${omero_object.object_type} ID ${omero_object.omero_id} with $getVar('mode.use_ilastik.ilastik_project.name', 'no ilastik'): Tables">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.csv" directory="output" format="csv"/>
            <filter>keep_intermediate</filter>
        </collection>
        <collection name="hyperstacks_with_overlay" type="list" label="${tool.name} on ${omero_object.object_type} ID ${omero_object.omero_id} with $getVar('mode.use_ilastik.ilastik_project.name', 'no ilastik'): Hyperstacks">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.tiff" directory="output" format="tiff"/>
        </collection>
        <collection name="ilastik_results" type="list" label="${tool.name} on ${omero_object.object_type} ID ${omero_object.omero_id} with $getVar('mode.use_ilastik.ilastik_project.name', 'no ilastik'): Ilastik">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.tif$" directory="output" format="tiff"/>
            <filter>keep_intermediate and mode['use_ilastik']['segmentation_method'] == "ilastik"</filter>
        </collection>
    </outputs>
    <help>
    <![CDATA[
**Overview**

This tool will get images from omero, use an ilastik project to get propability and generate a mask.
The potential gastruloids will be indentified by analyze Particles.
On each ROI, the elongation index will be computed.

**License**

License text::

    // This macro was written by the BIOP (https://github.com/BIOP)
    // Romain Guiet and Rémy Dornier
    // Lucille Delisle modified to support headless
    // And to be more robust to OMERO reboot
    // merge the analysis script with templates available at
    // https://github.com/BIOP/OMERO-scripts/tree/025047955b5c1265e1a93b259c1de4600d00f107/Fiji

    /*
    * = COPYRIGHT =
    * © All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, BioImaging And Optics Platform (BIOP), 2024
    * 
    * Licensed under the BSD-3-Clause License:
    * Redistribution and use in source and binary forms, with or without modification, are permitted provided 
    * that the following conditions are met:
    * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 
    *    in the documentation and/or other materials provided with the distribution.
    * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products 
    *     derived from this software without specific prior written permission.
    * 
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
    * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
    * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
    * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
    * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
    * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */

]]>
    </help>
</tool>