diff measure_image_quality.xml @ 3:08a2cf887a44 draft

"planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit c3917e27eb1c1deeb381aa0dc8161c07699562fb"
author bgruening
date Mon, 11 May 2020 07:46:58 -0400
parents 4dcd464c22ff
children 6f4715b8540a
line wrap: on
line diff
--- a/measure_image_quality.xml	Thu Apr 16 05:33:18 2020 -0400
+++ b/measure_image_quality.xml	Mon May 11 07:46:58 2020 -0400
@@ -1,24 +1,36 @@
 <tool id="cp_measure_image_quality" name="MeasureImageQuality" version="@CP_VERSION@">
     <description>measure features that indicate image quality</description>
-  
+
     <macros>
         <import>macros.xml</import>
         <xml name="macro_calc_threshold">
             <conditional name="con_use_all_methods">
                 <param name="use_all_methods" type="select" display="radio" label="Use all thresholding methods?">
+                    <help>
+                        <![CDATA[
+                            Select 'Yes' to calculate thresholds using all the available methods. Only the global methods are used. While most methods are straightfoward, some methods have additional parameters that require special handling:
+                            <br> - Otsu: Thresholds for all combinations of class number, minimization parameter and middle class assignment are computed.
+                            <br> - Mixture of Gaussians (MoG): Thresholds for image coverage fractions of 0.05, 0.25, 0.75 and 0.95 are computed.
+                            See the IdentifyPrimaryObjects module for more information on thresholding methods.
+                            ]]>
+                    </help>
                     <option value="Yes">Yes</option>
                     <option value="No">No</option>
                 </param>
                 <when value="Yes" />
                 <when value="No">
-                    <repeat name="rpt_threshold_method" title="Add another threshold method">
+                    <repeat name="rpt_threshold_method" title="new threshold method" min="1">
                         <conditional name="con_threshold_methods">
                             <param name="select_threshold_method" type="select" label="Select a thresholding method">
+                                <help>
+                                    This setting allows you to apply automatic thresholding methods used in the Identify modules.
+                                    Only the global methods are applied. For more help on thresholding, see the Identify modules.
+                                </help>
                                 <option value="Otsu">Otsu</option>
                                 <option value="MoG">MoG</option>
                                 <option value="Background">Background</option>
-                                <option value="RobustBackground">RobustBackground</option>
-                                <option value="RidlerCalvard">RidlerCalvard</option>
+                                <option value="RobustBackground">Robust background</option>
+                                <option value="RidlerCalvard">Ridler Calvard</option>
                                 <option value="Kapur">Kapur</option>
                                 <option value="MCT">MCT</option>
                             </param>
@@ -46,6 +58,13 @@
             </param>
             <conditional name="con_threshold_classes">
                 <param name="threshold_classes" label="Two-class or three-class thresholding?" type="select">
+                    <help>
+                        Select Two classes if the grayscale levels are readily distinguishable into foreground (i.e., objects) and background. 
+                        Select Three classes if there is a middle set of grayscale levels that belongs to neither the foreground nor background.
+                        For example, three-class thresholding may be useful for images in which you have nuclear staining along with a low-intensity non-specific cell staining. 
+                        Where two-class thresholding might incorrectly assign this intermediate staining to the nuclei objects, three-class thresholding allows you to assign it to the foreground or background as desired. 
+                        However, in extreme cases where either there are almost no objects or the entire field of view is covered with objects, three-class thresholding may perform worse than two-class.
+                    </help>
                     <option value="Two classes">Two classes</option>
                     <option value="Three classes">Three classes</option>
                 </param>
@@ -63,7 +82,7 @@
             <param name="mog_fraction_cover" label="Typical fraction of the image covered by objects" type="float" value="0.1" min="0.0" max="1.0"/>
         </xml>
     </macros>
-    
+
     <expand macro="py_requirements"/>
     <expand macro="cmd_modules" />
 
@@ -110,10 +129,10 @@
         all_method = "No"
     else:
         all_method = params['con_calc_threshold']['con_use_all_methods']['use_all_methods']
-        if all_method == "No":
-            threshold_count = 1
-        else:
-            threshold_count = len(params['con_calc_threshold']['con_use_all_methods']['rpt_threshold_method'])
+    if all_method == "No":
+        threshold_count = 1
+    else:
+        threshold_count = len(params['con_calc_threshold']['con_use_all_methods']['rpt_threshold_method'])
 
     _str += FOURSPACES + "Threshold count:%d\n" % threshold_count
 
@@ -142,19 +161,15 @@
     if all_method == "No":
         for method in params['con_calc_threshold']['con_use_all_methods']['rpt_threshold_method']:
             _str += FOURSPACES + "Select a thresholding method:%s\n" % method['con_threshold_methods']['select_threshold_method']
-
-            fraction_cover = method['con_threshold_methods']['mog_fraction_cover'] if 'mog_fraction_cover' in method[
-                'con_threshold_methods'] else 0.1
+ 
+            fraction_cover = method['con_threshold_methods']['mog_fraction_cover'] if 'mog_fraction_cover' in method['con_threshold_methods'] else 0.1
 
-            tt_classes = method['con_threshold_methods']['con_threshold_classes'][
-                'threshold_classes'] if 'con_threshold_classes' in method['con_threshold_methods'] else 'Two classes'
+            tt_classes = method['con_threshold_methods']['con_threshold_classes']['threshold_classes'] if 'con_threshold_classes' in method['con_threshold_methods'] else 'Two classes'
 
-            minimize = method['con_threshold_methods']['otsu_weighted_entropy'] if 'otsu_weighted_entropy' in method[
-                'con_threshold_methods'] else 'Entropy'
+            minimize = method['con_threshold_methods']['otsu_weighted_entropy'] if 'otsu_weighted_entropy' in method['con_threshold_methods'] else 'Entropy'
 
             if tt_classes == "Three classes":
-                pixel_intensity = method['con_threshold_methods']['con_threshold_classes'][
-                    'pixel_foreground_or_background']
+                pixel_intensity = method['con_threshold_methods']['con_threshold_classes']['pixel_foreground_or_background']
             else:
                 pixel_intensity = "Foreground"
 
@@ -177,20 +192,25 @@
     new_count = module_count + 1
     lines[4] = k + ":%d\n" % new_count
 
-    with open("output", "w") as f:
+    with open("output.cppipe", "w") as f:
         f.writelines(lines)
         f.write(writemiq())
 
-f.close()
-        </configfile>    
+    f.close()
+        </configfile>
     </configfiles>
-  
+
     <inputs>
-        <expand macro="input_pipeline_macro" />
+        <expand macro="input_pipeline_param" />
         <param name="calc_for_images" type="text" label="Calculate metrics for which images?" value="All loaded images">
+            <help>
+                Image names are separated by comma and correspond to the values in the section NameAndType of the 'Starting module' tool.
+
+            </help>
             <expand macro="text_validator" />
         </param>
-        <param name="include_rescaling_value" type="select" display="radio" label="Include the image rescaling value?">
+
+        <param name="include_rescaling_value" type="select" display="radio" label="Include the image rescaling value?" help="Select 'Yes' to add the image’s rescaling value as a quality control metric. This value is recorded only for images loaded using the Input modules. This is useful in confirming that all images are rescaled by the same value, given that some acquisition device vendors may output this value differently. ">
             <option value="Yes">Yes</option>
             <option value="No">No</option>
         </param>
@@ -198,27 +218,42 @@
         <conditional name="con_calc_blur_metrics">
             <param name="calc_blur_metrics" type="select" display="radio" label="Calculate blur metrics?">
                 <option value="Yes">Yes</option>
-                <option value="No">No</option>
+                <option value="No" selected="True">No</option>
             </param>
             <when value="Yes">
-                <repeat name="rpt_blur_measurements" title="Add another scale">
-                    <param name="blur_measurements" label="Spatial scale for blur measurements" type="integer" value="20"/>
+                <repeat name="rpt_blur_measurements" title="new scale" min="1">
+                    <param name="blur_measurements" label="Spatial scale for blur measurements" type="integer" value="20">
+                        <help>
+                            Enter an integer for the window size N, in units of pixels. The LocalFocusScore is measured within an N × N pixel window applied to the image, and the Correlation of a pixel is measured with respect to its neighbors N pixels away.
+                            A higher number for the window size N measures larger patterns of image blur whereas smaller numbers measure more localized patterns of blur. We suggest selecting a window size that is on the order of the feature of interest (e.g., the object diameter). You can measure these metrics for multiple window sizes by selecting additional scales for each image.
+                        </help>
+                    </param>
                 </repeat>
             </when>
             <when value="No" />
         </conditional>
-        
+
         <param name="calc_intensity_metrics" type="select" display="radio" label="Calculate intensity metrics?">
+            <help>
+                Select 'Yes' to calculate image-based intensity measures, namely the mean, maximum, minimum, standard deviation and median absolute deviation of pixel intensities. These measures are identical to those calculated by MeasureImageIntensity.
+            </help>
             <option value="Yes">Yes</option>
             <option value="No">No</option>
         </param>
         <param name="calc_saturation_metrics" type="select" display="radio" label="Calculate saturation metrics">
+            <help>
+                Select 'Yes' to calculate the saturation metrics PercentMaximal and PercentMinimal, i.e., the percentage of pixels at the upper or lower limit of each individual image.
+                For this calculation, the hard limits of 0 and 1 are not used because images often have undergone some kind of transformation such that no pixels ever reach the absolute maximum or minimum of the image format. Given the noise typical in images, both these measures should be a low percentage but if the images were saturated during imaging, a higher than usual PercentMaximal will be observed, and if there are no objects, the PercentMinimal value will increase.
+            </help>
             <option value="Yes">Yes</option>
             <option value="No">No</option>
         </param>
 
         <conditional name="con_calc_threshold">
             <param name="calc_threshold" type="select" display="radio" label="Calculate thresholds?">
+                <help>
+                    Automatically calculate a suggested threshold for each image. One indicator of image quality is that these threshold values lie within a typical range. Outlier images with high or low thresholds often contain artifacts.
+                </help>
                 <option value="Yes">Yes</option>
                 <option value="No">No</option>
             </param>
@@ -231,13 +266,13 @@
     </inputs>
 
     <outputs>
-        <expand macro="output_pipeline_macro" />
+        <expand macro="output_pipeline_param" />
     </outputs>
 
     <tests>
         <test>
             <expand macro="test_input_pipeline_param" />
-            
+
             <param name="calc_for_images" value="All loaded images" />
             <param name="include_rescaling_value" value="Yes" />
 
@@ -250,27 +285,41 @@
 
             <param name="calc_intensity_metrics" value="Yes" />
             <param name="calc_saturation_metrics" value="Yes" />
-                <conditional name="con_calc_threshold">
-                    <param name="calc_threshold" value="Yes" />
-                </conditional>
+            <conditional name="con_calc_threshold">
+                <param name="calc_threshold" value="Yes" />
+            </conditional>
 
-                <conditional name="con_use_all_methods">
-                    <param name="use_all_methods" value="No" />
-                    <repeat name="rpt_threshold_method">
-                        <conditional name="con_threshold_methods">
-                            <param name="select_threshold_method" value="Otsu" />
-                            <param name="otsu_weighted_entropy" value="Weighted variance" />
-                            <conditional name="con_threshold_classes">
-                                <param name="threshold_classes" value="Two classes" />
-                            </conditional>
+            <conditional name="con_use_all_methods">
+                <param name="use_all_methods" value="No" />
+                <repeat name="rpt_threshold_method">
+                    <conditional name="con_threshold_methods">
+                        <param name="select_threshold_method" value="Otsu" />
+                        <param name="otsu_weighted_entropy" value="Weighted variance" />
+                        <conditional name="con_threshold_classes">
+                            <param name="threshold_classes" value="Two classes" />
                         </conditional>
-                    </repeat>
-                </conditional>
-            
-            <expand macro="test_out_file" file="measure_image_quality.txt" />
+                    </conditional>
+                </repeat>
+            </conditional>
+
+            <expand macro="test_out_file" file="measure_image_quality.cppipe" />
         </test>
     </tests>
-    
-    <expand macro="help" module="MeasureImageQuality" />
-    <expand macro="citations" />  
+
+    <help>
+        <![CDATA[
+
+            .. class:: infomark
+
+            **What it does**
+
+            This tool collects measurements indicating possible image aberrations, e.g., blur (poor focus), intensity, saturation (i.e., the percentage of pixels in the image that are at/near the maximum possible value, and at/near the minimum possible value).
+            Details and guidance for each of these measures is provided in the settings help.
+            Please note that for best results, this module should be applied to the original raw images, rather than images that have already been corrected for illumination.
+
+            @COMMON_HELP@
+            ]]>
+    </help>
+
+    <expand macro="citations" />
 </tool>