Mercurial > repos > ximgchess > hexrd
comparison macros.xml @ 0:3316ac4fd07b draft default tip
"planemo upload for repository https://github.com/ximg-chess/galaxytools/tools/hexrd commit 944c00504583f201b006fb01f7e19fd98fca4a29"
| author | ximgchess |
|---|---|
| date | Wed, 05 Jan 2022 14:14:56 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:3316ac4fd07b |
|---|---|
| 1 <macros> | |
| 2 <token name="@TOOL_VERSION@">0.8.12</token> | |
| 3 <token name="@VERSION_SUFFIX@">1</token> | |
| 4 <token name="@PROFILE@">21.09</token> | |
| 5 <xml name="requirements"> | |
| 6 <requirements> | |
| 7 <requirement type="package" version="@TOOL_VERSION@">hexrd</requirement> | |
| 8 <yield/> | |
| 9 </requirements> | |
| 10 </xml> | |
| 11 <xml name="citations"> | |
| 12 <citations> | |
| 13 <citation type="doi">10.1016/j.matchar.2020.110366</citation> | |
| 14 <yield /> | |
| 15 </citations> | |
| 16 </xml> | |
| 17 | |
| 18 <token name="@CMD_IMPORTS@"> | |
| 19 #import re | |
| 20 #import yaml | |
| 21 | |
| 22 #set global $img_panel_dict = dict() | |
| 23 #if $detector.panel_assignment == 'panel_table' | |
| 24 #set $fh = open(str($detector.image_panel_table),'r') | |
| 25 #for $line in $fh: | |
| 26 #set $fields = $line.strip().split('\t') | |
| 27 #silent $img_panel_dict[$fields[0]] = $fields[1] | |
| 28 #end for | |
| 29 #end if | |
| 30 #set global $panels = $yaml.safe_load(open(str($instrument),'r'))['detectors'].keys() | |
| 31 #def identifier_or_name($input1) | |
| 32 #if hasattr($input1, 'element_identifier') | |
| 33 #return $input1.element_identifier | |
| 34 #elif hasattr($input1, 'name') | |
| 35 #return $input1.name | |
| 36 #else | |
| 37 #return str($input1) | |
| 38 #end if | |
| 39 #end def | |
| 40 #def clean($name1) | |
| 41 #set $name_clean = $re.sub('[^\w\-_]', '_', $re.sub('(?i)[.](npz|hexrd|yml|dat|out)$','', $name1.split()[-1])) | |
| 42 #return $name_clean | |
| 43 #end def | |
| 44 #def ln_name($ds,$ext) | |
| 45 #set $lname = "%s.%s" % ($clean($identifier_or_name($ds)),$ext) | |
| 46 #return $lname | |
| 47 #end def | |
| 48 #def get_panel($img_input): | |
| 49 #set $img_name = $identifier_or_name($img_input) | |
| 50 #if $img_panel_dict and $img_name in $img_panel_dict: | |
| 51 #return $img_panel_dict[$img_name] | |
| 52 #end if | |
| 53 #for $p in $panels: | |
| 54 #if $p in $img_name: | |
| 55 #return $p | |
| 56 #end if | |
| 57 #end for | |
| 58 #return $img_name | |
| 59 #end def | |
| 60 </token> | |
| 61 | |
| 62 <xml name="common_config" token_multiple_inputs="true" > | |
| 63 <param name="inputs" type="data" format="hexrd.images.npz" multiple="true" label="Image series frame-cache"/> | |
| 64 <conditional name="detector"> | |
| 65 <param name="panel_assignment" type="select" label="Assign detector panel to images"> | |
| 66 <option value="infer_from_name" selected="true">Infer the panel from the image name</option> | |
| 67 <option value="panel_table">Input a table with image panels assignments</option> | |
| 68 </param> | |
| 69 <when value="infer_from_name"/> | |
| 70 <when value="panel_table"> | |
| 71 <param name="image_panel_table" type="data" format="tabular" label="Image panel assignment table"> | |
| 72 <help>A 2-column table:image dataset name detector panel name</help> | |
| 73 </param> | |
| 74 </when> | |
| 75 </conditional> | |
| 76 <param name="instrument" type="data" format="yaml" label="instrument"/> | |
| 77 <param name="material" type="data" format="hexrd.materials.h5" label="material"/> | |
| 78 <param name="active_material" type="select" label="active material name"> | |
| 79 <options> | |
| 80 <filter type="data_meta" ref="material" key="materials"/> | |
| 81 </options> | |
| 82 </param> | |
| 83 <param name="dmin" type="float" value="1.0" min="0" max="10" optional="true" label="dmin angstroms" help="used to figure out the maximum sampling for g-vectors default 1.0"/> | |
| 84 <param name="tth_width" type="float" value="0.25" min="0" max="10" optional="true" label="tth tolerance in degrees" help="tth_width default 0.25 "/> | |
| 85 <param name="min_sfac_ratio" type="float" value="" min="0" max="1" optional="true" label="min percentage of max to exclude" help="min_sfac_ratio min percentage of max |F|^2 to exclude; default None"/> | |
| 86 <!-- | |
| 87 <param name="active_material" type="text" value="" label="active material name"> | |
| 88 <validator type="empty_field" /> | |
| 89 </param> | |
| 90 --> | |
| 91 </xml> | |
| 92 | |
| 93 <token name="@CMD_LINKS@"><![CDATA[@CMD_IMPORTS@ | |
| 94 mkdir -p imageseries && | |
| 95 ln -s '$material' $ln_name($material,'h5') && | |
| 96 ln -s '$instrument' $ln_name($instrument,'yml') && | |
| 97 #for $input in $inputs | |
| 98 ln -s '$input' imageseries/$ln_name($input,'npz') && | |
| 99 #end for | |
| 100 ]]> | |
| 101 </token> | |
| 102 <token name="@FIT_GRAIN_LINKS@"><![CDATA[@CMD_LINKS@ | |
| 103 ln -s '$ome_map' $ln_name($ome_map,'npz') && | |
| 104 ln -s '$accepted_orientations' $ln_name($accepted_orientations,'dat') && | |
| 105 ##mkdir -p analysis && | |
| 106 ##cp '$grains_estimate' analysis/$ln_name($grains_estimate,'out') && | |
| 107 ]]> | |
| 108 </token> | |
| 109 | |
| 110 <token name="@CONVERT2TAB@"><![CDATA[for i in `find analysis -name '[gs]*.out'`; do sed -i.bak "s/[ ][ ][ ]*/\$(printf '\t')/g" \${i}; done]]></token> | |
| 111 | |
| 112 <token name="@COMMON_YML@"><![CDATA[@CMD_IMPORTS@ | |
| 113 #slurp | |
| 114 #set instrument_file = $ln_name($instrument,'yml') | |
| 115 analysis_name: analysis | |
| 116 | |
| 117 multiprocessing: -1 | |
| 118 | |
| 119 material: | |
| 120 definitions: $ln_name($material,'h5') | |
| 121 active: $active_material | |
| 122 #if $dmin | |
| 123 dmin: $dmin # defaults to 1.0 angstrom | |
| 124 #end if | |
| 125 #if $tth_width | |
| 126 tth_width: $tth_width # defaults to 0.25 degrees | |
| 127 #end if | |
| 128 #if $min_sfac_ratio | |
| 129 min_sfac_ratio: $min_sfac_ratio # min percentage of max |F|^2 to exclude; default None | |
| 130 #end if | |
| 131 | |
| 132 image_series: | |
| 133 format: frame-cache | |
| 134 data: | |
| 135 #for $input in $inputs | |
| 136 - file: imageseries/$ln_name($input,'npz') | |
| 137 args: {} | |
| 138 panel: $get_panel($input) # must match detector key | |
| 139 #end for | |
| 140 | |
| 141 instrument: $instrument_file | |
| 142 | |
| 143 ]]></token> | |
| 144 | |
| 145 <xml name="find_orientations_config"> | |
| 146 <expand macro="common_config" token_multiple_inputs="true" /> | |
| 147 <section name="orientation_maps" title="Orientation Maps" expanded="true"> | |
| 148 <param name="threshold" type="integer" value="25" min="1" label="threshold"/> | |
| 149 <param name="bin_frames" type="integer" value="1" label="bin frames"/> | |
| 150 <!-- active_hkls should be able to be optional="true" --> | |
| 151 <param name="active_hkls" type="text" value="" label="active hkl planes"> | |
| 152 <help>commas separated list of planes, e.g.: 0,1,2,3,4,5</help> | |
| 153 <validator type="regex" message="plane indeces separated by commas">^\d(,\d)*$</validator> | |
| 154 </param> | |
| 155 </section> | |
| 156 <param name="on_map_threshold" type="integer" value="1" min="1" label="on-map threshold used in the scoring"/> | |
| 157 <section name="search_options" title="Search Options" expanded="true"> | |
| 158 <conditional name="search"> | |
| 159 <param name="search_type" type="select" label="Specify Search"> | |
| 160 <option value="seed_search" selected="true">use seed search</option> | |
| 161 <option value="use_quaternion_grid">use quaternion grid</option> | |
| 162 </param> | |
| 163 <when value="seed_search"> | |
| 164 <!-- hkl_seeds should be able to be optional="true" --> | |
| 165 <param name="hkl_seeds" type="text" value="" label="hkl seeds"> | |
| 166 <help>commas separated list of planes, e.g.: 0,1,2 (subset of active hkl planes)</help> | |
| 167 <validator type="regex" message="">^\d(,\d)*$</validator> | |
| 168 </param> | |
| 169 <param name="fiber_step" type="float" value="0.5" min="0" max="10" label="fiber step"/> | |
| 170 <conditional name="params"> | |
| 171 <param name="method" type="select" label="Method"> | |
| 172 <option value="label" selected="true">label</option> | |
| 173 <option value="blob_dog">blob_dog</option> | |
| 174 <option value="blob_log">blob_log</option> | |
| 175 </param> | |
| 176 <when value="label"> | |
| 177 <param name="filter_radius" type="integer" value="1" min="1" label="label filter radius"/> | |
| 178 <param name="threshold" type="integer" value="1" min="1" label="label threshold"/> | |
| 179 </when> | |
| 180 <when value="blob_dog"> | |
| 181 <param name="min_sigma" type="float" value="0.5" min="0" max="10" label="blob_dog min_sigma"/> | |
| 182 <param name="max_sigma" type="float" value="5.0" min="0" max="10" label="blob_dog max_sigma"/> | |
| 183 <param name="sigma_ratio" type="float" value="1.6" min="0" max="10" label="blob_dog sigma_ratio"/> | |
| 184 <param name="threshold" type="float" value="0.01" min="0" max="1.0" label="blob_dog threshold"/> | |
| 185 <param name="overlap" type="float" value="0.1" min="0" max="1.0" label="blob_dog overlap"/> | |
| 186 </when> | |
| 187 <when value="blob_log"> | |
| 188 <param name="min_sigma" type="float" value="0.5" min="0" max="10" label="blob_log min_sigma"/> | |
| 189 <param name="max_sigma" type="float" value="5.0" min="0" max="10" label="blob_log max_sigma"/> | |
| 190 <param name="num_sigma" type="integer" value="10" min="0" max="20" label="blob_log num_sigma"/> | |
| 191 <param name="threshold" type="float" value="0.01" min="0" max="1.0" label="blob_log threshold"/> | |
| 192 <param name="overlap" type="float" value="0.1" min="0" max="1.0" label="blob_log overlap"/> | |
| 193 </when> | |
| 194 </conditional> | |
| 195 </when> | |
| 196 <when value="use_quaternion_grid"> | |
| 197 <param name="quaternion_grid" type="data" format="npz" label="quaterion grid file"/> | |
| 198 </when> | |
| 199 </conditional> | |
| 200 </section> | |
| 201 <section name="omega" title="Omega" expanded="true"> | |
| 202 <param name="omega_tolerance" type="float" value="1.0" min="0" max="10.0" label="omega tolerance"/> | |
| 203 </section> | |
| 204 <section name="eta" title="eta" expanded="true"> | |
| 205 <param name="eta_tolerance" type="float" value="1.0" min="0" max="10.0" label="eta tolerance"/> | |
| 206 <param name="eta_mask" type="float" value="5.0" min="0" max="10.0" label="eta mask"/> | |
| 207 </section> | |
| 208 <section name="clustering" title="Clustering" expanded="true"> | |
| 209 <param name="clustering_algorithm" type="select" label="Clustering algorithm"> | |
| 210 <option value="dbscan" selected="true">dbscan</option> | |
| 211 <option value="sph-dbscan">sph-dbscan</option> | |
| 212 <option value="ort-dbscan">ort-dbscan</option> | |
| 213 <option value="fclusterdata">fclusterdata (won't work for large problems)</option> | |
| 214 </param> | |
| 215 <param name="clustering_radius" type="float" value="1.0" min="0" max="10" label="clustering radius"/> | |
| 216 <param name="clustering_completeness" type="float" value="0.85" min="0" max="1" label="clustering completeness threshold"/> | |
| 217 </section> | |
| 218 <!-- | |
| 219 --> | |
| 220 </xml> | |
| 221 | |
| 222 <token name="@FIND_ORIENTATIONS_YML@"><![CDATA[@COMMON_YML@ | |
| 223 | |
| 224 #set active_hkls = 'all' | |
| 225 #if $orientation_maps.active_hkls: | |
| 226 #set active_hkls = '[' + str($orientation_maps.active_hkls) + ']' | |
| 227 #end if | |
| 228 find_orientations: | |
| 229 orientation_maps: | |
| 230 # A file name must be specified. If it doesn't exist, one will be created | |
| 231 file: null | |
| 232 | |
| 233 threshold: $orientation_maps.threshold | |
| 234 bin_frames: $orientation_maps.bin_frames # defaults to 1 | |
| 235 | |
| 236 # "all", or a list of hkl orders used to find orientations | |
| 237 # defaults to all orders listed in the material definition | |
| 238 active_hkls: $active_hkls | |
| 239 | |
| 240 # either search full quaternion grid, or seed search based on sparse | |
| 241 # orientation maps. For input search space: | |
| 242 # | |
| 243 # use_quaternion_grid: some/file/name | |
| 244 # | |
| 245 # otherwise defaults to seeded search | |
| 246 #if $search_options.search.search_type == 'use_quaternion_grid' | |
| 247 use_quaternion_grid: | |
| 248 #elif $search_options.search.search_type == 'seed_search' | |
| 249 #set hkl_seeds = '[' + str($search_options.search.hkl_seeds) + ']' | |
| 250 seed_search: # this section is ignored if use_quaternion_grid is defined | |
| 251 hkl_seeds: $hkl_seeds # hkls ids to use, must be defined for seeded search | |
| 252 fiber_step: $search_options.search.fiber_step # degrees, defaults to ome tolerance | |
| 253 # Method selection: | |
| 254 # Now 3 choices: label (the original), 'blob_dog', and 'blob_log' | |
| 255 # Each has its own parameter names, examples below. | |
| 256 # | |
| 257 method: | |
| 258 #if $search_options.search.params.method == 'label' | |
| 259 label: | |
| 260 filter_radius: $search_options.search.params.filter_radius | |
| 261 threshold: $search_options.search.params.threshold | |
| 262 #elif $search_options.search.params.method == 'blob_dog' | |
| 263 blob_dog: | |
| 264 min_sigma: $search_options.search.params.min_sigma | |
| 265 max_sigma: $search_options.search.params.max_sigma | |
| 266 sigma_ratio: $search_options.search.params.sigma_ratio | |
| 267 threshold: $search_options.search.params.threshold | |
| 268 overlap: $search_options.search.params.overlap | |
| 269 #elif $search_options.search.params.method == 'blob_log' | |
| 270 blob_log: | |
| 271 min_sigma: $search_options.search.params.min_sigma | |
| 272 max_sigma: $search_options.search.params.max_sigma | |
| 273 num_sigma: $search_options.search.params.num_sigma | |
| 274 threshold: $search_options.search.params.threshold | |
| 275 overlap: $search_options.search.params.overlap | |
| 276 #end if | |
| 277 # this is the on-map threshold using in the scoring | |
| 278 # defaults to 1 | |
| 279 #end if | |
| 280 threshold: $on_map_threshold | |
| 281 | |
| 282 omega: | |
| 283 tolerance: $omega.omega_tolerance # in degrees, defaults to 2x ome step | |
| 284 | |
| 285 eta: | |
| 286 tolerance: $eta.eta_tolerance # in degrees, defaults to 2x ome step | |
| 287 mask: $eta.eta_mask # degrees, mask angles close to ome rotation axis, defaults to 5 | |
| 288 | |
| 289 clustering: | |
| 290 # algorithm choices are | |
| 291 # sph-dbscan | |
| 292 # ort-dbscn | |
| 293 # dbscan <default> | |
| 294 # fclusterdata; this is a fallback and won't work for large problems | |
| 295 algorithm: $clustering.clustering_algorithm | |
| 296 radius: $clustering.clustering_radius | |
| 297 completeness: $clustering.clustering_completeness | |
| 298 | |
| 299 ]]></token> | |
| 300 | |
| 301 <xml name="fit_grains_config"> | |
| 302 <expand macro="common_config" token_multiple_inputs="true"/> | |
| 303 <param name="ome_map" type="data" format="hexrd.eta_ome.npz" label="analysis eta-ome_maps.npz from find_orientations"/> | |
| 304 <param name="accepted_orientations" type="data" format="tabular" label="accepted_orientations from find_orientations"/> | |
| 305 <param name="grains_estimate" type="data" format="tabular" label="grains.out from find_orientations"/> | |
| 306 <param name="do_fit" type="boolean" truevalue="true" falsevalue="false" checked="true" label="fit grains" help="if false, extracts grains but doesn't fit"/> | |
| 307 <param name="npdiv" type="integer" value="2" min="1" label="number of polar pixel grid subdivisions"/> | |
| 308 <param name="threshold" type="integer" value="25" min="1" label="threshold"/> | |
| 309 <section name="tolerance" title="Fit Grain Tolerance" expanded="true"> | |
| 310 <repeat name="tolerance_lists" title="Tolerance values" min="1"> | |
| 311 <param name="tth" type="float" value="" min="0" label="tth"/> | |
| 312 <param name="eta" type="float" value="" min="0" label="eta"/> | |
| 313 <param name="omega" type="float" value="" min="0" label="omega"/> | |
| 314 </repeat> | |
| 315 <param name="refit" type="text" value="1" label="refit"> | |
| 316 <validator type="regex" message="">^\d(,\d)*$</validator> | |
| 317 </param> | |
| 318 <conditional name="max_tth"> | |
| 319 <param name="tth_max_value" type="select" label="Set tth_max"> | |
| 320 <option value="true" selected="true">true</option> | |
| 321 <option value="false">false</option> | |
| 322 <option value="entered">enter value</option> | |
| 323 </param> | |
| 324 <when value="true"/> | |
| 325 <when value="false"/> | |
| 326 <when value="entered"> | |
| 327 <param name="tth_max" type="float" value="14.25" label="tth_max"/> | |
| 328 </when> | |
| 329 </conditional> | |
| 330 </section> | |
| 331 </xml> | |
| 332 | |
| 333 <token name="@FIT_GRAINS_YML@"><![CDATA[@COMMON_YML@ | |
| 334 find_orientations: | |
| 335 orientation_maps: | |
| 336 # A file name must be specified. If it doesn't exist, one will be created | |
| 337 file: $ln_name($ome_map,'npz') | |
| 338 | |
| 339 fit_grains: | |
| 340 do_fit: $do_fit # if false, extracts grains but doesn't fit. defaults to true | |
| 341 # estimate: null | |
| 342 npdiv: $npdiv # number of polar pixel grid subdivisions, defaults to 2 | |
| 343 threshold: $threshold | |
| 344 | |
| 345 #set $tth = [] | |
| 346 #set $eta = [] | |
| 347 #set $omega = [] | |
| 348 #set refit = '[' + str($tolerance.refit) + ']' | |
| 349 #for $tol in $tolerance.tolerance_lists | |
| 350 #silent $tth.append(float($tol.tth)) | |
| 351 #silent $eta.append(float($tol.eta)) | |
| 352 #silent $omega.append(float($tol.omega)) | |
| 353 #end for | |
| 354 tolerance: | |
| 355 tth: $tth # tolerance lists must be identical length | |
| 356 eta: $eta | |
| 357 omega: $omega | |
| 358 | |
| 359 refit: $refit | |
| 360 #if $tolerance.max_tth.tth_max_value == 'entered': | |
| 361 tth_max: $tolerance.max_tth.tth_max # true, false, or a non-negative value, defaults to true | |
| 362 #else | |
| 363 tth_max: $tolerance.max_tth.tth_max_value # true, false, or a non-negative value, defaults to true | |
| 364 #end if | |
| 365 ]]></token> | |
| 366 <token name="@HEXRD_HELP@"><![CDATA[ | |
| 367 HEXRD_ provides analysis of x-ray diffraction data, especially high-energy x-ray diffraction. HEXRD is comprised of a library and API for writing scripts, a command line interface, and an interactive graphical user interface. | |
| 368 | |
| 369 .. _HEXRD: https://github.com/HEXRD/hexrd | |
| 370 ]]></token> | |
| 371 | |
| 372 <token name="@COMMON_INPUTS_HELP@"><![CDATA[ | |
| 373 | |
| 374 **INPUTS** | |
| 375 | |
| 376 - imageseries - Detector image files converted to sparse matrix compressed numpy arrays. | |
| 377 - instrument - A yaml file that decribes the instrument | |
| 378 - materials.hexrd - A "pickled" hexrd Materials object that desscribes the sample material | |
| 379 ]]></token> | |
| 380 <token name="@FIT_GRAIN_INPUTS_HELP@"><![CDATA[@COMMON_INPUTS_HELP@ | |
| 381 - analysis eta-ome_maps.npz from find_orientations | |
| 382 - accepted_orientations from find_orientations | |
| 383 | |
| 384 ]]></token> | |
| 385 | |
| 386 <token name="@COMMON_OUTPUTS_HELP@"><![CDATA[ | |
| 387 | |
| 388 **OUTPUTS** | |
| 389 | |
| 390 - config yaml - parameter for hexrd | |
| 391 - log - the hexrd logging output | |
| 392 - grains.out | |
| 393 ]]></token> | |
| 394 <token name="@FIND_ORIENTATIONS_OUTPUTS_HELP@"><![CDATA[@COMMON_OUTPUTS_HELP@ | |
| 395 - analysis eta-ome_maps.npz *(used as input for hexrd fit-grains)* | |
| 396 - analysis accepted_orientations_analysis.dat *(used as input for hexrd fit-grains)* | |
| 397 - analysis scored_orientations_analysis.npz | |
| 398 ]]></token> | |
| 399 <token name="@FIT_GRAINS_OUTPUTS_HELP@"><![CDATA[@COMMON_OUTPUTS_HELP@ | |
| 400 - Collection of spots.out | |
| 401 ]]></token> | |
| 402 | |
| 403 | |
| 404 </macros> |
