# Avizo-Script-Object V3.0 # NO DEPRECATION WARNING # ######################################################################### # Deprecated. # ######################################################################### ############################################################## # Avizo Fire Shading Correction # # action step based workflow # # This example performs a shading correction using Avizo Fire shading_cor module # The workflow is : # # - create a mask with a threshold defining the background used for shading correction # - create the background image using bkgimg # - create the corrected image with shading_cor # # It uses ActionStep2.scro to dramatically simplify user interactions ############################################################## # ######################################################################### # Load ActionStep2.scro file which contains some definition of procedures # ######################################################################### set file share/script-objects/ActionStep2.scro if [file readable $AMIRA_LOCAL/$file] { source $AMIRA_LOCAL/$file } else { source $AMIRA_ROOT/$file } # ######################################################################### # Destructor # ######################################################################### "$this" proc destructor {} { set mainOrthoSlice ["$this" getVar mainOrthoSlice] set maskThresholdModule ["$this" getVar maskThresholdModule] remove "$mainOrthoSlice" remove "$maskThresholdModule" } # ######################################################################### # Define all action of this wizard # ######################################################################### "$this" proc defineActions {} { "$this" addAction "Shading Correction" "Threshold Mask for background computation" initPorts { "$this" newPortRangeSlider maskThreshold "$this" maskThreshold setLabel "Mask Threshold" "$this" maskThreshold setTooltip "threshold defining the background used for shading correction" "$this" newPortIntTextN normalizationFactor 1 "$this" normalizationFactor setLabel "Normalization Factor" "$this" normalizationFactor setTooltip "normalization factor" "$this" normalizationFactor setValue 200 } initAction { set data ["$this" getVar currentData] if {$data != ""} { # Connect MainOrthoSlice "$this" attachMainOrthoSlice $data set maskThresholdModule ["$this" getVar maskThresholdModule] if {$maskThresholdModule == ""} { set maskThresholdModule [create HxInteractiveThreshold maskThreshold] "$maskThresholdModule" hideIcon "$maskThresholdModule" data connect $data "$maskThresholdModule" sliceNumber interconnect "$this" sliceNumber "$this" sliceOrientation connectTo "$maskThresholdModule" orientation "$this" maskThreshold connectTo "$maskThresholdModule" threshold "$maskThresholdModule" rendering setValue 0 "$maskThresholdModule" fire "$this" setVar maskThresholdModule "$maskThresholdModule" } set maskThresholdModule ["$this" getVar maskThresholdModule] "$maskThresholdModule" setViewerMask 1 "$maskThresholdModule" fire # Close connection editor "$this" closeConnectionEditor } } onApplyAction { set data ["$this" getVar currentData] if {$data != ""} { global hideNewModules set hideNewModules 1 set maskThresholdModule ["$this" getVar maskThresholdModule] "$maskThresholdModule" doIt hit "$maskThresholdModule" fire "$maskThresholdModule" setViewerMask 0 set thresholdedData ["$maskThresholdModule" getResult] set bkgimg [moduleApply bkgimg inputImage "$data" inputImageMask "$thresholdedData"] set bkgimgData ["$bkgimg" getResult] remove $bkgimg remove $thresholdedData set normalizationFactor ["$this" normalizationFactor getValue] set result [$this getResult] if {"$result" == ""} { # rename result after 'moduleApply' to avoid the connection of an unrelated data named "$data.corrected" which would not be our result. set shading_corimage [moduleApply shading_corimage inputImage "$data" whiteReference "$bkgimgData" normalizationFactor $normalizationFactor ] [$shading_corimage getResult] setLabel "$data.corrected" } else { set shading_corimage [moduleApply shading_corimage inputImage "$data" whiteReference "$bkgimgData" normalizationFactor $normalizationFactor resultSlot "$result" ] } set result [$shading_corimage getResult] "$result" showIcon "$this" setResult "$result" remove $shading_corimage remove "$bkgimgData" # Connect MainOrthoSlice "$this" attachMainOrthoSlice "$result" set hideNewModules 0 } } } # ######################################################################### # Initialize variables # ######################################################################### "$this" proc initVar {} { # Initialize module variables if { [lsearch ["$this" getVarNames] maskThresholdModule] == -1} {"$this" setVar maskThresholdModule {}} }