Mercurial > repos > bgruening > cp_measure_image_quality
comparison 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 |
comparison
equal
deleted
inserted
replaced
2:4dcd464c22ff | 3:08a2cf887a44 |
---|---|
1 <tool id="cp_measure_image_quality" name="MeasureImageQuality" version="@CP_VERSION@"> | 1 <tool id="cp_measure_image_quality" name="MeasureImageQuality" version="@CP_VERSION@"> |
2 <description>measure features that indicate image quality</description> | 2 <description>measure features that indicate image quality</description> |
3 | 3 |
4 <macros> | 4 <macros> |
5 <import>macros.xml</import> | 5 <import>macros.xml</import> |
6 <xml name="macro_calc_threshold"> | 6 <xml name="macro_calc_threshold"> |
7 <conditional name="con_use_all_methods"> | 7 <conditional name="con_use_all_methods"> |
8 <param name="use_all_methods" type="select" display="radio" label="Use all thresholding methods?"> | 8 <param name="use_all_methods" type="select" display="radio" label="Use all thresholding methods?"> |
9 <help> | |
10 <![CDATA[ | |
11 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: | |
12 <br> - Otsu: Thresholds for all combinations of class number, minimization parameter and middle class assignment are computed. | |
13 <br> - Mixture of Gaussians (MoG): Thresholds for image coverage fractions of 0.05, 0.25, 0.75 and 0.95 are computed. | |
14 See the IdentifyPrimaryObjects module for more information on thresholding methods. | |
15 ]]> | |
16 </help> | |
9 <option value="Yes">Yes</option> | 17 <option value="Yes">Yes</option> |
10 <option value="No">No</option> | 18 <option value="No">No</option> |
11 </param> | 19 </param> |
12 <when value="Yes" /> | 20 <when value="Yes" /> |
13 <when value="No"> | 21 <when value="No"> |
14 <repeat name="rpt_threshold_method" title="Add another threshold method"> | 22 <repeat name="rpt_threshold_method" title="new threshold method" min="1"> |
15 <conditional name="con_threshold_methods"> | 23 <conditional name="con_threshold_methods"> |
16 <param name="select_threshold_method" type="select" label="Select a thresholding method"> | 24 <param name="select_threshold_method" type="select" label="Select a thresholding method"> |
25 <help> | |
26 This setting allows you to apply automatic thresholding methods used in the Identify modules. | |
27 Only the global methods are applied. For more help on thresholding, see the Identify modules. | |
28 </help> | |
17 <option value="Otsu">Otsu</option> | 29 <option value="Otsu">Otsu</option> |
18 <option value="MoG">MoG</option> | 30 <option value="MoG">MoG</option> |
19 <option value="Background">Background</option> | 31 <option value="Background">Background</option> |
20 <option value="RobustBackground">RobustBackground</option> | 32 <option value="RobustBackground">Robust background</option> |
21 <option value="RidlerCalvard">RidlerCalvard</option> | 33 <option value="RidlerCalvard">Ridler Calvard</option> |
22 <option value="Kapur">Kapur</option> | 34 <option value="Kapur">Kapur</option> |
23 <option value="MCT">MCT</option> | 35 <option value="MCT">MCT</option> |
24 </param> | 36 </param> |
25 <when value="Otsu"> | 37 <when value="Otsu"> |
26 <expand macro="otsu_method" /> | 38 <expand macro="otsu_method" /> |
44 <option value="Weighted variance">Weighted variance</option> | 56 <option value="Weighted variance">Weighted variance</option> |
45 <option value="Entropy">Entropy</option> | 57 <option value="Entropy">Entropy</option> |
46 </param> | 58 </param> |
47 <conditional name="con_threshold_classes"> | 59 <conditional name="con_threshold_classes"> |
48 <param name="threshold_classes" label="Two-class or three-class thresholding?" type="select"> | 60 <param name="threshold_classes" label="Two-class or three-class thresholding?" type="select"> |
61 <help> | |
62 Select Two classes if the grayscale levels are readily distinguishable into foreground (i.e., objects) and background. | |
63 Select Three classes if there is a middle set of grayscale levels that belongs to neither the foreground nor background. | |
64 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. | |
65 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. | |
66 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. | |
67 </help> | |
49 <option value="Two classes">Two classes</option> | 68 <option value="Two classes">Two classes</option> |
50 <option value="Three classes">Three classes</option> | 69 <option value="Three classes">Three classes</option> |
51 </param> | 70 </param> |
52 <when value="Three classes"> | 71 <when value="Three classes"> |
53 <param name="pixel_foreground_or_background" label="Assign pixels in the middle intensity class to the foreground or the background?" type="select"> | 72 <param name="pixel_foreground_or_background" label="Assign pixels in the middle intensity class to the foreground or the background?" type="select"> |
61 | 80 |
62 <xml name="mog_method"> | 81 <xml name="mog_method"> |
63 <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"/> | 82 <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"/> |
64 </xml> | 83 </xml> |
65 </macros> | 84 </macros> |
66 | 85 |
67 <expand macro="py_requirements"/> | 86 <expand macro="py_requirements"/> |
68 <expand macro="cmd_modules" /> | 87 <expand macro="cmd_modules" /> |
69 | 88 |
70 <configfiles> | 89 <configfiles> |
71 <inputs name="inputs" /> | 90 <inputs name="inputs" /> |
108 if calc_threshold == "No": | 127 if calc_threshold == "No": |
109 threshold_count = 1 | 128 threshold_count = 1 |
110 all_method = "No" | 129 all_method = "No" |
111 else: | 130 else: |
112 all_method = params['con_calc_threshold']['con_use_all_methods']['use_all_methods'] | 131 all_method = params['con_calc_threshold']['con_use_all_methods']['use_all_methods'] |
113 if all_method == "No": | 132 if all_method == "No": |
114 threshold_count = 1 | 133 threshold_count = 1 |
115 else: | 134 else: |
116 threshold_count = len(params['con_calc_threshold']['con_use_all_methods']['rpt_threshold_method']) | 135 threshold_count = len(params['con_calc_threshold']['con_use_all_methods']['rpt_threshold_method']) |
117 | 136 |
118 _str += FOURSPACES + "Threshold count:%d\n" % threshold_count | 137 _str += FOURSPACES + "Threshold count:%d\n" % threshold_count |
119 | 138 |
120 _str += FOURSPACES + "Select the images to measure:%s\n" % selected_images | 139 _str += FOURSPACES + "Select the images to measure:%s\n" % selected_images |
121 | 140 |
140 _str += FOURSPACES + "Use all thresholding methods?:%s\n" % all_method | 159 _str += FOURSPACES + "Use all thresholding methods?:%s\n" % all_method |
141 | 160 |
142 if all_method == "No": | 161 if all_method == "No": |
143 for method in params['con_calc_threshold']['con_use_all_methods']['rpt_threshold_method']: | 162 for method in params['con_calc_threshold']['con_use_all_methods']['rpt_threshold_method']: |
144 _str += FOURSPACES + "Select a thresholding method:%s\n" % method['con_threshold_methods']['select_threshold_method'] | 163 _str += FOURSPACES + "Select a thresholding method:%s\n" % method['con_threshold_methods']['select_threshold_method'] |
145 | 164 |
146 fraction_cover = method['con_threshold_methods']['mog_fraction_cover'] if 'mog_fraction_cover' in method[ | 165 fraction_cover = method['con_threshold_methods']['mog_fraction_cover'] if 'mog_fraction_cover' in method['con_threshold_methods'] else 0.1 |
147 'con_threshold_methods'] else 0.1 | 166 |
148 | 167 tt_classes = method['con_threshold_methods']['con_threshold_classes']['threshold_classes'] if 'con_threshold_classes' in method['con_threshold_methods'] else 'Two classes' |
149 tt_classes = method['con_threshold_methods']['con_threshold_classes'][ | 168 |
150 'threshold_classes'] if 'con_threshold_classes' in method['con_threshold_methods'] else 'Two classes' | 169 minimize = method['con_threshold_methods']['otsu_weighted_entropy'] if 'otsu_weighted_entropy' in method['con_threshold_methods'] else 'Entropy' |
151 | |
152 minimize = method['con_threshold_methods']['otsu_weighted_entropy'] if 'otsu_weighted_entropy' in method[ | |
153 'con_threshold_methods'] else 'Entropy' | |
154 | 170 |
155 if tt_classes == "Three classes": | 171 if tt_classes == "Three classes": |
156 pixel_intensity = method['con_threshold_methods']['con_threshold_classes'][ | 172 pixel_intensity = method['con_threshold_methods']['con_threshold_classes']['pixel_foreground_or_background'] |
157 'pixel_foreground_or_background'] | |
158 else: | 173 else: |
159 pixel_intensity = "Foreground" | 174 pixel_intensity = "Foreground" |
160 | 175 |
161 _str += FOURSPACES + "Typical fraction of the image covered by objects:%.1f\n" % fraction_cover | 176 _str += FOURSPACES + "Typical fraction of the image covered by objects:%.1f\n" % fraction_cover |
162 | 177 |
175 | 190 |
176 module_count = int(v) | 191 module_count = int(v) |
177 new_count = module_count + 1 | 192 new_count = module_count + 1 |
178 lines[4] = k + ":%d\n" % new_count | 193 lines[4] = k + ":%d\n" % new_count |
179 | 194 |
180 with open("output", "w") as f: | 195 with open("output.cppipe", "w") as f: |
181 f.writelines(lines) | 196 f.writelines(lines) |
182 f.write(writemiq()) | 197 f.write(writemiq()) |
183 | 198 |
184 f.close() | 199 f.close() |
185 </configfile> | 200 </configfile> |
186 </configfiles> | 201 </configfiles> |
187 | 202 |
188 <inputs> | 203 <inputs> |
189 <expand macro="input_pipeline_macro" /> | 204 <expand macro="input_pipeline_param" /> |
190 <param name="calc_for_images" type="text" label="Calculate metrics for which images?" value="All loaded images"> | 205 <param name="calc_for_images" type="text" label="Calculate metrics for which images?" value="All loaded images"> |
206 <help> | |
207 Image names are separated by comma and correspond to the values in the section NameAndType of the 'Starting module' tool. | |
208 | |
209 </help> | |
191 <expand macro="text_validator" /> | 210 <expand macro="text_validator" /> |
192 </param> | 211 </param> |
193 <param name="include_rescaling_value" type="select" display="radio" label="Include the image rescaling value?"> | 212 |
213 <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. "> | |
194 <option value="Yes">Yes</option> | 214 <option value="Yes">Yes</option> |
195 <option value="No">No</option> | 215 <option value="No">No</option> |
196 </param> | 216 </param> |
197 | 217 |
198 <conditional name="con_calc_blur_metrics"> | 218 <conditional name="con_calc_blur_metrics"> |
199 <param name="calc_blur_metrics" type="select" display="radio" label="Calculate blur metrics?"> | 219 <param name="calc_blur_metrics" type="select" display="radio" label="Calculate blur metrics?"> |
200 <option value="Yes">Yes</option> | 220 <option value="Yes">Yes</option> |
201 <option value="No">No</option> | 221 <option value="No" selected="True">No</option> |
202 </param> | 222 </param> |
203 <when value="Yes"> | 223 <when value="Yes"> |
204 <repeat name="rpt_blur_measurements" title="Add another scale"> | 224 <repeat name="rpt_blur_measurements" title="new scale" min="1"> |
205 <param name="blur_measurements" label="Spatial scale for blur measurements" type="integer" value="20"/> | 225 <param name="blur_measurements" label="Spatial scale for blur measurements" type="integer" value="20"> |
226 <help> | |
227 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. | |
228 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. | |
229 </help> | |
230 </param> | |
206 </repeat> | 231 </repeat> |
207 </when> | 232 </when> |
208 <when value="No" /> | 233 <when value="No" /> |
209 </conditional> | 234 </conditional> |
210 | 235 |
211 <param name="calc_intensity_metrics" type="select" display="radio" label="Calculate intensity metrics?"> | 236 <param name="calc_intensity_metrics" type="select" display="radio" label="Calculate intensity metrics?"> |
237 <help> | |
238 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. | |
239 </help> | |
212 <option value="Yes">Yes</option> | 240 <option value="Yes">Yes</option> |
213 <option value="No">No</option> | 241 <option value="No">No</option> |
214 </param> | 242 </param> |
215 <param name="calc_saturation_metrics" type="select" display="radio" label="Calculate saturation metrics"> | 243 <param name="calc_saturation_metrics" type="select" display="radio" label="Calculate saturation metrics"> |
244 <help> | |
245 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. | |
246 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. | |
247 </help> | |
216 <option value="Yes">Yes</option> | 248 <option value="Yes">Yes</option> |
217 <option value="No">No</option> | 249 <option value="No">No</option> |
218 </param> | 250 </param> |
219 | 251 |
220 <conditional name="con_calc_threshold"> | 252 <conditional name="con_calc_threshold"> |
221 <param name="calc_threshold" type="select" display="radio" label="Calculate thresholds?"> | 253 <param name="calc_threshold" type="select" display="radio" label="Calculate thresholds?"> |
254 <help> | |
255 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. | |
256 </help> | |
222 <option value="Yes">Yes</option> | 257 <option value="Yes">Yes</option> |
223 <option value="No">No</option> | 258 <option value="No">No</option> |
224 </param> | 259 </param> |
225 <when value="Yes"> | 260 <when value="Yes"> |
226 <expand macro="macro_calc_threshold" /> | 261 <expand macro="macro_calc_threshold" /> |
229 </conditional> | 264 </conditional> |
230 | 265 |
231 </inputs> | 266 </inputs> |
232 | 267 |
233 <outputs> | 268 <outputs> |
234 <expand macro="output_pipeline_macro" /> | 269 <expand macro="output_pipeline_param" /> |
235 </outputs> | 270 </outputs> |
236 | 271 |
237 <tests> | 272 <tests> |
238 <test> | 273 <test> |
239 <expand macro="test_input_pipeline_param" /> | 274 <expand macro="test_input_pipeline_param" /> |
240 | 275 |
241 <param name="calc_for_images" value="All loaded images" /> | 276 <param name="calc_for_images" value="All loaded images" /> |
242 <param name="include_rescaling_value" value="Yes" /> | 277 <param name="include_rescaling_value" value="Yes" /> |
243 | 278 |
244 <conditional name="con_calc_blur_metrics"> | 279 <conditional name="con_calc_blur_metrics"> |
245 <param name="calc_blur_metrics" value="Yes" /> | 280 <param name="calc_blur_metrics" value="Yes" /> |
248 </repeat> | 283 </repeat> |
249 </conditional> | 284 </conditional> |
250 | 285 |
251 <param name="calc_intensity_metrics" value="Yes" /> | 286 <param name="calc_intensity_metrics" value="Yes" /> |
252 <param name="calc_saturation_metrics" value="Yes" /> | 287 <param name="calc_saturation_metrics" value="Yes" /> |
253 <conditional name="con_calc_threshold"> | 288 <conditional name="con_calc_threshold"> |
254 <param name="calc_threshold" value="Yes" /> | 289 <param name="calc_threshold" value="Yes" /> |
255 </conditional> | 290 </conditional> |
256 | 291 |
257 <conditional name="con_use_all_methods"> | 292 <conditional name="con_use_all_methods"> |
258 <param name="use_all_methods" value="No" /> | 293 <param name="use_all_methods" value="No" /> |
259 <repeat name="rpt_threshold_method"> | 294 <repeat name="rpt_threshold_method"> |
260 <conditional name="con_threshold_methods"> | 295 <conditional name="con_threshold_methods"> |
261 <param name="select_threshold_method" value="Otsu" /> | 296 <param name="select_threshold_method" value="Otsu" /> |
262 <param name="otsu_weighted_entropy" value="Weighted variance" /> | 297 <param name="otsu_weighted_entropy" value="Weighted variance" /> |
263 <conditional name="con_threshold_classes"> | 298 <conditional name="con_threshold_classes"> |
264 <param name="threshold_classes" value="Two classes" /> | 299 <param name="threshold_classes" value="Two classes" /> |
265 </conditional> | |
266 </conditional> | 300 </conditional> |
267 </repeat> | 301 </conditional> |
268 </conditional> | 302 </repeat> |
269 | 303 </conditional> |
270 <expand macro="test_out_file" file="measure_image_quality.txt" /> | 304 |
305 <expand macro="test_out_file" file="measure_image_quality.cppipe" /> | |
271 </test> | 306 </test> |
272 </tests> | 307 </tests> |
273 | 308 |
274 <expand macro="help" module="MeasureImageQuality" /> | 309 <help> |
275 <expand macro="citations" /> | 310 <![CDATA[ |
311 | |
312 .. class:: infomark | |
313 | |
314 **What it does** | |
315 | |
316 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). | |
317 Details and guidance for each of these measures is provided in the settings help. | |
318 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. | |
319 | |
320 @COMMON_HELP@ | |
321 ]]> | |
322 </help> | |
323 | |
324 <expand macro="citations" /> | |
276 </tool> | 325 </tool> |