# Avizo-Script-Object V3.0 # NO DEPRECATION WARNING ############################################################## # Script for Image Registration # # Performs operations for images registration # Can be used as a basis for alignment of two images. # As it is based on ActionStep2.scro in order to benefit from action based workflow, # user interaction is reduced # # Workflow: # - [optional] display with Ortho View before processing # Used to get three orthogonal views of the objetcs, in three 2D viewers. # - [optional] extracting subvolume and/or resampling (image to be transformed) # Uses Extract Subvolume module to define a limited region of interest. # - [optional] extracting subvolume and/or resampling (reference image) # Uses Extract Subvolume module to define a limited region of interest. # - alignment of images # Uses Register Images module on simplified lattices. The metric, the type of transformation and # the pre-alignment method can be defined by user. # # author: Amouda Joseph (ajoseph@fei.com) # (C) copyright 2015, FEI, SAS # ############################################################## #source ActionStep scro set file share/script-objects/ActionStep2.scro if [file readable $AMIRA_LOCAL/$file] { source $AMIRA_LOCAL/$file } else { source $AMIRA_ROOT/$file } # ########################################################################### # Add a reference connection port # ########################################################################### "$this" proc addReferencePort {} { "$this" newPortConnection reference HxLattice "$this" reference setLabel "Reference" "$this" reference reposition 1 } # ########################################################################### # Destructor # ########################################################################### "$this" proc destructor {} { # Remove modules set mainOrthoSlice ["$this" getVar mainOrthoSlice] set register ["$this" getVar registrationModule] set extractModSubvol ["$this" getVar modelExtractionModule] set extractRefSubvol ["$this" getVar refExtractionModule] remove $mainOrthoSlice remove $register remove $extractModSubvol remove $extractRefSubvol #Remove intermediate data if {[exists ["$this" getVar simplifiedModel]]} { set resampledModel ["$this" getVar simplifiedModel] remove $resampledModel } if {[exists ["$this" getVar simplifiedRef]]} { set resampledRef ["$this" getVar simplifiedRef] remove $resampledRef } } # ########################################################################### # Compute # ########################################################################### "$this" proc compute {} { # Step 1 : Disable Skip and Apply button if no reference if {["$this" getVar currentActionId] == 0} { set model ["$this" data source] set ref ["$this" reference source] if {$ref=="" || $model ==""} { "$this" action setSensitivity 1 0 "$this" action setSensitivity 2 0 } else { "$this" action setSensitivity 1 1 "$this" action setSensitivity 2 1 } } # Step 4 : Hide histogram range if Euclidean/Correlation metric is selected if {["$this" getVar currentActionId] == 3} { set metric ["$this" metricChoice getOptValue] if {$metric < 2} { "$this" refRange show "$this" modRange show } else { "$this" refRange hide "$this" modRange hide } } } # ########################################################################### # Initialize variables # ########################################################################### "$this" proc initVar {} { # Initialize module variables if { [lsearch ["$this" getVarNames] registrationModule] == -1} {"$this" setVar registrationModule {}} if { [lsearch ["$this" getVarNames] modelExtractionModule] == -1} {"$this" setVar modelExtractionModule {}} if { [lsearch ["$this" getVarNames] refExtractionModule] == -1} {"$this" setVar refExtractionModule {}} if { [lsearch ["$this" getVarNames] sliceC] == -1} {"$this" setVar sliceC {}} if { [lsearch ["$this" getVarNames] orthoViews] == -1} {"$this" setVar orthoViews {}} # Initialize data variables if { [lsearch ["$this" getVarNames] simplifiedModel] == -1} {"$this" setVar simplifiedModel {}} if { [lsearch ["$this" getVarNames] simplifiedRef] == -1} {"$this" setVar simplifiedRef {}} # Initialize variables for model/reference subsampling if { [lsearch ["$this" getVarNames] firstModelSubsampling] == -1} {"$this" setVar firstModelSubsampling 1} if { [lsearch ["$this" getVarNames] firstRefSubsampling] == -1} {"$this" setVar firstRefSubsampling 1} if { [lsearch ["$this" getVarNames] boxSizeModX] == -1} {"$this" setVar boxSizeModX 0} if { [lsearch ["$this" getVarNames] boxSizeModY] == -1} {"$this" setVar boxSizeModY 0} if { [lsearch ["$this" getVarNames] boxSizeModZ] == -1} {"$this" setVar boxSizeModZ 0} if { [lsearch ["$this" getVarNames] boxMinModX] == -1} {"$this" setVar boxMinModX 0} if { [lsearch ["$this" getVarNames] boxMinModY] == -1} {"$this" setVar boxMinModY 0} if { [lsearch ["$this" getVarNames] boxMinModZ] == -1} {"$this" setVar boxMinModZ 0} if { [lsearch ["$this" getVarNames] modelSubsample] == -1} {"$this" setVar modelSubsample 0} if { [lsearch ["$this" getVarNames] modelSubRateX] == -1} {"$this" setVar modelSubRateX 2} if { [lsearch ["$this" getVarNames] modelSubRateY] == -1} {"$this" setVar modelSubRateY 2} if { [lsearch ["$this" getVarNames] modelSubRateZ] == -1} {"$this" setVar modelSubRateZ 2} if { [lsearch ["$this" getVarNames] boxSizeRefX] == -1} {"$this" setVar boxSizeRefX 0} if { [lsearch ["$this" getVarNames] boxSizeRefY] == -1} {"$this" setVar boxSizeRefY 0} if { [lsearch ["$this" getVarNames] boxSizeRefZ] == -1} {"$this" setVar boxSizeRefZ 0} if { [lsearch ["$this" getVarNames] boxMinRefX] == -1} {"$this" setVar boxMinRefX 0} if { [lsearch ["$this" getVarNames] boxMinRefY] == -1} {"$this" setVar boxMinRefY 0} if { [lsearch ["$this" getVarNames] boxMinRefZ] == -1} {"$this" setVar boxMinRefZ 0} if { [lsearch ["$this" getVarNames] refSubsample] == -1} {"$this" setVar refSubsample 0} if { [lsearch ["$this" getVarNames] refSubRateX] == -1} {"$this" setVar refSubRateX 2} if { [lsearch ["$this" getVarNames] refSubRateY] == -1} {"$this" setVar refSubRateY 2} if { [lsearch ["$this" getVarNames] refSubRateZ] == -1} {"$this" setVar refSubRateZ 2} } # ########################################################################### # Defines all actions of this wizard # ########################################################################### "$this" proc defineActions {} { if {[exists "MainOrthoSlice"]} {"MainOrthoSlice" setViewerMask 0 "MainOrthoSlice" hideIcon} "$this" sliceNumber hide "$this" sliceOrientation hide "$this" addReferencePort "$this" newPortSeparator 1 # Set text for instruction ports "$this" setVar info1 "Make sure that the model and the reference images are set\nrespectively at Data port and Reference port.\nIf needed, click on Apply to show Ortho Views. Otherwise, click on Skip." "$this" setVar info2 "If the two volumes have a limited common region (overlapped volumes),\ndefine this region with the subvolume.\nIn case of high resolution volumes, subsample is required.\nPress 'Skip' if the whole image must be considered for alignment." "$this" setVar info3 "Select the metric, the transformation type and the pre-alignment method.\n(See documentation for more information)" ############################################################################# ## FIRST STEP : Display data ############################################################################# "$this" addAction DisplayData "Display data" initPorts { #FIRST STEP PORTS INITIALISATION #Information port "$this" newPortInfo instruction1 "$this" instruction1 setLabel "Instruction" "$this" instruction1 setValue ["$this" getVar info1] #Hide icon port "$this" newPortToggleList hideModule 1 "$this" hideModule setLabel "Hide Modules" "$this" hideModule setValue 0 1 } onSkipAction { # If the step is skipped, orthoview is disabled "$this" setVar orthoviewEnabled 0 } initAction { # Reposition the instruction port and the separator "$this" instruction1 reposition 7 } onApplyAction { global AMIRA_ROOT # In 'Apply' button is hit, orthoview is enabled "$this" setVar orthoviewEnabled 1 set ref ["$this" reference source] set model ["$this" data source] # If the model is not a LDA type, colormash cannot be connected to it. Orthoview is not enabled set modtype [$model getTypeId] if {"$modtype" != "HxVolumeDataObject"} { #Create ortho views if {![exists ["$this" getVar orthoViews]]} { set orthoViews [create HxOrthoViews "OrthoViews"] "$this" setVar orthoViews $orthoViews } set orthoViews ["$this" getVar orthoViews] #Connect orthoview to the reference $orthoViews data connect $ref set type [$ref getTypeId] if {"$type" == "HxVolumeDataObject"} { $orthoViews setBackgroundType HxOPsOrthoSliceLDM 1 } else { $orthoViews setBackgroundType HxOPsOrthoSlice 1 } $orthoViews setViewerMask 65535 $orthoViews fire #Create colored slice if {![exists ["$this" getVar sliceC]]} { set sliceC [create HxOPsObliqueSlice "SliceC"] "$this" setVar sliceC $sliceC } set sliceC ["$this" getVar sliceC] #Connect colored slice to the model $sliceC orthoPlanes connect $orthoViews $sliceC data connect $model #Select physics-transparent colormap if this colormap is loaded. Otherwise, use volrenPhysics. if {[exists "physics-transparent.am"]} {$sliceC colormap connect "physics-transparent.am"} else { [ load ${AMIRA_ROOT}/data/colormaps/volrenPhysics.am ] setLabel "volrenPhysics.am" "volrenPhysics.am" hideIcon $sliceC colormap connect "volrenPhysics.am"} if {[exists "Colormap Legend"]} {"Colormap Legend" setViewerMask 0} #Set colormap range to the model range set modelRange [$model getRange] $sliceC colormap setMinMax [lindex $modelRange 0] [lindex $modelRange 1] $sliceC transparency setValue 2 $sliceC setViewerMask 65535 $sliceC fire $orthoViews resetLayersOrder } else { #Case of LDA data type for model echo "WARNING - Cannot connect Orthoviews : model is LDA type" "$this" setVar orthoviewEnabled 0 } } ############################################################################# ## SECOND STEP : Extract region/Downsample the model ############################################################################# "$this" addAction SubsampleModel "Subsample and/or Extract Subvolume from the model volume" initPorts { #SECOND STEP PORTS INITIALISATION #Information port "$this" newPortInfo instruction2 "$this" instruction2 setLabel "Instruction" "$this" instruction2 setValue ["$this" getVar info2] #Extract subvolumes boxe "$this" newPortIntTextN boxMin 3 "$this" boxMin setLabel "Box Min \[px\]" "$this" boxMin setLabel 0 "i" "$this" boxMin setLabel 1 "j" "$this" boxMin setLabel 2 "k" "$this" boxMin setValue 0 0 "$this" boxMin setValue 1 0 "$this" boxMin setValue 2 0 "$this" newPortIntTextN boxSize 3 "$this" boxSize setLabel "Box Size \[px\]" "$this" boxSize setLabel 0 "i" "$this" boxSize setLabel 1 "j" "$this" boxSize setLabel 2 "k" "$this" newPortButtonList boxMax 3 "$this" boxMax setLabel "Box Max" "$this" boxMax setLabel 0 "Max width" "$this" boxMax setLabel 1 "Max height" "$this" boxMax setLabel 2 "Max depth" #Subsample checkbox "$this" newPortToggleList modelSubsample 1 "$this" modelSubsample setLabel "Subsample" "$this" modelSubsample setLabel 0 "" "$this" modelSubsample setValue 0 0 #Subsample rate "$this" newPortIntTextN modelSubRate 3 "$this" modelSubRate setLabel "Subsample Rate \[px\]" "$this" modelSubRate setLabel 0 "x" "$this" modelSubRate setLabel 1 "y" "$this" modelSubRate setLabel 2 "z" "$this" modelSubRate setValue 0 2 "$this" modelSubRate setValue 1 2 "$this" modelSubRate setValue 2 2 "$this" modelSubRate hide } onPortUpdate { #Show and hide subsample rate if subsample box is un-checked if {["$this" modelSubsample getValue 1]} { "$this" modelSubRate hide } else { "$this" modelSubRate show } } initAction { # Reposition instruction and separator port "$this" instruction2 reposition 7 # Connect the colored slice to the model if orthoview is enabled set model ["$this" data source] if {["$this" getVar orthoviewEnabled]} { set sliceC ["$this" getVar sliceC] if {[exists $sliceC]} { $sliceC data connect $model $sliceC fire} } # Create extract subvolume module for model and hide it if options "Hide module" is enabled if {![exists ["$this" getVar modelExtractionModule]]} { set extractModSubvol [create HxLatticeAccess extractModSubvol] "$this" setVar modelExtractionModule $extractModSubvol } if {["$this" hideModule getValue 0]} { ["$this" getVar modelExtractionModule] hideIcon } else { ["$this" getVar modelExtractionModule] showIcon } set extractModSubvol ["$this" getVar modelExtractionModule] set modDimX 0 set modDimY 0 set modDimZ 0 # If a model is connected, box values are updated if {$model != "" && [exists $model]} { set modDims [$model getDims] set modDimX [lindex $modDims 0] set modDimY [lindex $modDims 1] set modDimZ [lindex $modDims 2] "$this" modelSubsample setValue 0 0 "$this" modelSubRate setValue 0 2 "$this" modelSubRate setValue 1 2 "$this" modelSubRate setValue 2 2 "$this" boxSize setMinMax 0 0 $modDimX "$this" boxSize setMinMax 1 0 $modDimY "$this" boxSize setMinMax 2 0 $modDimZ "$this" boxMin setMinMax 0 0 $modDimX "$this" boxMin setMinMax 1 0 $modDimY "$this" boxMin setMinMax 2 0 $modDimZ } # Warning if reference data is not set. if {!["$this" getVar isNetworkLoading]} { if {["$this" reference source] == ""} { echo "WARNING - The reference data-set has not been set! Please select a data-set at the reference port." } } # Disconnect box port from extract subvolume module for reference if exists if {["$this" getVar refExtractionModule]!= ""} { set extractRefSubvol ["$this" getVar refExtractionModule] if {[exists $extractRefSubvol]} { $extractRefSubvol setViewerMask 0 $extractRefSubvol boxMin disconnect "$this" boxMin $extractRefSubvol boxMax disconnect "$this" boxMax $extractRefSubvol boxSize disconnect "$this" boxSize } } "$this" modelSubRate setMinMax 0 1 [expr $modDimX/2] "$this" modelSubRate setMinMax 1 1 [expr $modDimY/2] "$this" modelSubRate setMinMax 2 1 [expr $modDimZ/2] if {[exists $extractModSubvol] && [exists $model]} { $extractModSubvol data connect $model $extractModSubvol setViewerMask 65535 # If this step is played for the first time, # the default values are set if {["$this" getVar firstModelSubsampling]} { "$this" boxMin setValue 0 0 "$this" boxMin setValue 1 0 "$this" boxMin setValue 2 0 "$this" boxSize setValue 0 $modDimX "$this" boxSize setValue 1 $modDimY "$this" boxSize setValue 2 $modDimZ } else { # Else, we retrieve the last ports' states "$this" boxSize setValue 0 ["$this" getVar boxSizeModX] "$this" boxSize setValue 1 ["$this" getVar boxSizeModY] "$this" boxSize setValue 2 ["$this" getVar boxSizeModZ] "$this" boxMin setValue 0 ["$this" getVar boxMinModX] "$this" boxMin setValue 1 ["$this" getVar boxMinModY] "$this" boxMin setValue 2 ["$this" getVar boxMinModZ] "$this" modelSubsample setValue 0 ["$this" getVar modelSubsample] "$this" modelSubRate setValue 0 ["$this" getVar modelSubRateX] "$this" modelSubRate setValue 1 ["$this" getVar modelSubRateY] "$this" modelSubRate setValue 2 ["$this" getVar modelSubRateZ] } $extractModSubvol boxMin interconnect "$this" $extractModSubvol boxSize interconnect "$this" $extractModSubvol boxMax interconnect "$this" $extractModSubvol options setValue 1 0 } #Close connection editor "$this" closeConnectionEditor } onSkipAction { # Is action is skipped, in case of LDA data, the volume is automatically resampled with a rate of 4 set model ["$this" data source] set type [$model getTypeId] if {"$type" == "HxVolumeDataObject"} { echo "WARNING - Cannot skip this step for LDA object. Considering the whole data-set resampled with a factor 4" set modDims [$model getDims] set modDimX [lindex $modDims 0] set modDimY [lindex $modDims 1] set modDimZ [lindex $modDims 2] set extractModSubvol ["$this" getVar modelExtractionModule] $extractModSubvol boxMin disconnect "$this" boxMin $extractModSubvol boxMax disconnect "$this" boxMax $extractModSubvol boxSize disconnect "$this" boxSize $extractModSubvol boxMin setValue 0 0 $extractModSubvol boxMin setValue 1 0 $extractModSubvol boxMin setValue 2 0 $extractModSubvol boxSize setValue 0 $modDimX $extractModSubvol boxSize setValue 1 $modDimY $extractModSubvol boxSize setValue 2 $modDimZ $extractModSubvol options setValue 1 1 $extractModSubvol subsample setValue 0 4 $extractModSubvol subsample setValue 1 4 $extractModSubvol subsample setValue 2 4 $extractModSubvol action hit $extractModSubvol fire set resampledModel [$extractModSubvol getResult] $extractModSubvol data disconnect $resampledModel master disconnect "$this" setVar simplifiedModel $resampledModel if {["$this" hideModule getValue 0]} { $resampledModel hideIcon } else { $resampledModel showIcon } } } onApplyAction { set extractModSubvol ["$this" getVar modelExtractionModule] #Set the subsample option and values $extractModSubvol options setValue 1 ["$this" modelSubsample getValue 0] if {["$this" modelSubsample getValue 0] == 1} { $extractModSubvol fire $extractModSubvol subsample setValue 0 ["$this" modelSubRate getValue 0] $extractModSubvol subsample setValue 1 ["$this" modelSubRate getValue 1] $extractModSubvol subsample setValue 2 ["$this" modelSubRate getValue 2] } # Get volume dimension to compare with subsample options set model ["$this" data source] set type [$model getTypeId] set modDims [$model getDims] set modDimX [lindex $modDims 0] set modDimY [lindex $modDims 1] set modDimZ [lindex $modDims 2] # Save the states of all model subsampling ports "$this" setVar firstModelSubsampling 0 "$this" setVar boxSizeModX ["$this" boxSize getValue 0] "$this" setVar boxSizeModY ["$this" boxSize getValue 1] "$this" setVar boxSizeModZ ["$this" boxSize getValue 2] "$this" setVar boxMinModX ["$this" boxMin getValue 0] "$this" setVar boxMinModY ["$this" boxMin getValue 1] "$this" setVar boxMinModZ ["$this" boxMin getValue 2] "$this" setVar modelSubsample ["$this" modelSubsample getValue 0] "$this" setVar modelSubRateX ["$this" modelSubRate getValue 0] "$this" setVar modelSubRateY ["$this" modelSubRate getValue 1] "$this" setVar modelSubRateZ ["$this" modelSubRate getValue 2] #If the whole data is selected without subsampling, nothing is done if {["$this" boxMin getValue 0] == 0 && ["$this" boxMin getValue 1] == 0 && ["$this" boxMin getValue 2] == 0 && ["$this" boxSize getValue 0] == $modDimX && ["$this" boxSize getValue 1] == $modDimY && ["$this" boxSize getValue 2] == $modDimZ && ["$this" modelSubsample getValue 0] == 0 && "$type" != "HxVolumeDataObject"} { } else { $extractModSubvol action hit $extractModSubvol fire set resampledModel [$extractModSubvol getResult] "$this" setVar simplifiedModel $resampledModel $extractModSubvol data disconnect $resampledModel master disconnect if {["$this" hideModule getValue 0]} { $resampledModel hideIcon } else { $resampledModel showIcon } # Connect the colored slice to the new simplified model if {["$this" getVar orthoviewEnabled]} { set sliceC ["$this" getVar sliceC] if {[exists $sliceC]} { $sliceC data connect $resampledModel $sliceC fire} } } } ############################################################################# ## THIRD STEP : Extract region/Downsample the reference ############################################################################# "$this" addAction SubsampleReference "Subsample and/or Extract Subvolume from the reference volume" initPorts { # THIRD STEP PORTS INITIALISATION #Information port "$this" newPortInfo instruction3 "$this" instruction3 setLabel "Instruction" "$this" instruction3 setValue ["$this" getVar info2] #Extract subvolumes boxe "$this" boxMin setValue 0 0 "$this" boxMin setValue 1 0 "$this" boxMin setValue 2 0 # Subsample checkbox "$this" newPortToggleList refSubsample 1 "$this" refSubsample setLabel "Subsample" "$this" refSubsample setLabel 0 "" "$this" refSubsample setValue 0 0 # Subsample rate "$this" newPortIntTextN refSubRate 3 "$this" refSubRate setLabel "Subsample Rate \[px\]" "$this" refSubRate setLabel 0 "x" "$this" refSubRate setLabel 1 "y" "$this" refSubRate setLabel 2 "z" "$this" refSubRate setValue 0 2 "$this" refSubRate setValue 1 2 "$this" refSubRate setValue 2 2 "$this" refSubRate hide } initAction { #Reposition instruction "$this" instruction3 reposition 7 # Connect slice and orthoview to the model and reference set ref ["$this" reference source] if {["$this" getVar orthoviewEnabled]} { set orthoViews ["$this" getVar orthoViews] set sliceC ["$this" getVar sliceC] if {[exists $sliceC] && [exists $orthoViews]} { set sliceData [$sliceC data source] $orthoViews data connect $ref $orthoViews fire $sliceC data connect $sliceData $sliceC fire } } # Create 'Extract Subvolume' module for reference and connect ports if {![exists ["$this" getVar refExtractionModule]]} { set extractRefSubvol [create HxLatticeAccess extractRefSubvol] "$this" setVar refExtractionModule $extractRefSubvol } # Hide the created module is the option "hide module" is enabled if {["$this" hideModule getValue 0]} { ["$this" getVar refExtractionModule] hideIcon } else { ["$this" getVar refExtractionModule] showIcon } set ref ["$this" reference source] if {$ref == ""} { "$this" action setSensitivity 2 0 } #Mask the old ExtractSubvolume module set extractModSubvol ["$this" getVar modelExtractionModule] set extractRefSubvol ["$this" getVar refExtractionModule] #Connect the ExtractSubvolume Module to the reference if {[exists $extractRefSubvol] && [exists $ref]} { $extractRefSubvol data connect $ref $extractRefSubvol options setValue 1 0 $extractRefSubvol setViewerMask 65535 } if {[exists $extractModSubvol]} { $extractModSubvol setViewerMask 0 } "$this" boxMin show "$this" boxSize show "$this" boxMax show #Set boxes values depending on data dimension and type if {$ref != ""} { set type [$ref getTypeId] set refDims [$ref getDims] set refDimX [lindex $refDims 0] set refDimY [lindex $refDims 1] set refDimZ [lindex $refDims 2] #If LDA data, resample rate is set to 4 if {"$type" == "HxVolumeDataObject"} { "$this" refSubsample setValue 0 1 "$this" refSubRate setValue 0 4 "$this" refSubRate setValue 1 4 "$this" refSubRate setValue 2 4 } else { "$this" refSubsample setValue 0 0 "$this" refSubRate setValue 0 2 "$this" refSubRate setValue 1 2 "$this" refSubRate setValue 2 2 } "$this" boxMin setMinMax 0 0 $refDimX "$this" boxMin setMinMax 1 0 $refDimY "$this" boxMin setMinMax 2 0 $refDimZ "$this" boxSize setMinMax 0 0 $refDimX "$this" boxSize setMinMax 1 0 $refDimY "$this" boxSize setMinMax 2 0 $refDimZ "$this" refSubRate setMinMax 0 1 [expr $refDimX/2] "$this" refSubRate setMinMax 1 1 [expr $refDimY/2] "$this" refSubRate setMinMax 2 1 [expr $refDimZ/2] # If this step is played for the first time, the default values are set if {["$this" getVar firstRefSubsampling]} { "$this" boxMin setValue 0 0 "$this" boxMin setValue 1 0 "$this" boxMin setValue 2 0 "$this" boxSize setValue 0 $refDimX "$this" boxSize setValue 1 $refDimY "$this" boxSize setValue 2 $refDimZ } else { # Esle, we retrieve the last ports' states "$this" boxSize setValue 0 ["$this" getVar boxSizeRefX] "$this" boxSize setValue 1 ["$this" getVar boxSizeRefY] "$this" boxSize setValue 2 ["$this" getVar boxSizeRefZ] "$this" boxMin setValue 0 ["$this" getVar boxMinRefX] "$this" boxMin setValue 1 ["$this" getVar boxMinRefY] "$this" boxMin setValue 2 ["$this" getVar boxMinRefZ] "$this" refSubsample setValue 0 ["$this" getVar refSubsample] "$this" refSubRate setValue 0 ["$this" getVar refSubRateX] "$this" refSubRate setValue 1 ["$this" getVar refSubRateY] "$this" refSubRate setValue 2 ["$this" getVar refSubRateZ] } # Connect script's ports to the extract subvolume's ports if {[exists $extractRefSubvol] && [exists $extractModSubvol] && [exists $ref]} { $extractRefSubvol data connect $ref $extractRefSubvol options setValue 1 0 $extractModSubvol boxMin disconnect "$this" boxMin $extractModSubvol boxMax disconnect "$this" boxMax $extractModSubvol boxSize disconnect "$this" boxSize $extractRefSubvol boxMin interconnect "$this" $extractRefSubvol boxSize interconnect "$this" $extractRefSubvol boxMax interconnect "$this" $extractRefSubvol fire } set type [$ref getTypeId] if {"$type" == "HxVolumeDataObject"} {"$this" refSubsample setValue 0 1} } #Close connection editor "$this" closeConnectionEditor } onSkipAction { # Is action is skipped, in case of LDA data, the volume is automatically resampled with a rate of 4 set ref ["$this" reference source] set type [$ref getTypeId] if {"$type" == "HxVolumeDataObject"} { echo "WARNING - Cannot skip this step for LDA object. Considering the whole data-set resampled with a factor 4" set refDims [$ref getDims] set refDimX [lindex $refDims 0] set refDimY [lindex $refDims 1] set refDimZ [lindex $refDims 2] set extractRefSubvol ["$this" getVar refExtractionModule] $extractRefSubvol boxMin disconnect "$this" boxMin $extractRefSubvol boxMax disconnect "$this" boxMax $extractRefSubvol boxSize disconnect "$this" boxSize $extractRefSubvol boxMin setValue 0 0 $extractRefSubvol boxMin setValue 1 0 $extractRefSubvol boxMin setValue 2 0 $extractRefSubvol boxSize setValue 0 $refDimX $extractRefSubvol boxSize setValue 1 $refDimY $extractRefSubvol boxSize setValue 2 $refDimZ $extractRefSubvol options setValue 1 1 $extractRefSubvol subsample setValue 0 4 $extractRefSubvol subsample setValue 1 4 $extractRefSubvol subsample setValue 2 4 $extractRefSubvol action hit $extractRefSubvol fire $extractRefSubvol data disconnect set resampledRef [$extractRefSubvol getResult] "$this" setVar simplifiedRef $resampledRef $extractRefSubvol data disconnect $resampledRef master disconnect if {["$this" hideModule getValue 0]} { $resampledRef hideIcon } else { $resampledRef showIcon } } } onApplyAction { #THIRD STEP ACTION set ref ["$this" reference source] set extractRefSubvol ["$this" getVar refExtractionModule] #Set the subsample option and values $extractRefSubvol options setValue 1 ["$this" refSubsample getValue 0] if {["$this" refSubsample getValue 0] == 1} { $extractRefSubvol fire $extractRefSubvol subsample setValue 0 ["$this" refSubRate getValue 0] $extractRefSubvol subsample setValue 1 ["$this" refSubRate getValue 1] $extractRefSubvol subsample setValue 2 ["$this" refSubRate getValue 2] } #Get volume dimension set refDims [$ref getDims] set refDimX [lindex $refDims 0] set refDimY [lindex $refDims 1] set refDimZ [lindex $refDims 2] #Get volume type set type [$ref getTypeId] # Save the states of all model subsampling ports "$this" setVar firstRefSubsampling 0 "$this" setVar boxSizeRefX ["$this" boxSize getValue 0] "$this" setVar boxSizeRefY ["$this" boxSize getValue 1] "$this" setVar boxSizeRefZ ["$this" boxSize getValue 2] "$this" setVar boxMinRefX ["$this" boxMin getValue 0] "$this" setVar boxMinRefY ["$this" boxMin getValue 1] "$this" setVar boxMinRefZ ["$this" boxMin getValue 2] "$this" setVar refSubsample ["$this" refSubsample getValue 0] "$this" setVar refSubRateX ["$this" refSubRate getValue 0] "$this" setVar refSubRateY ["$this" refSubRate getValue 1] "$this" setVar refSubRateZ ["$this" refSubRate getValue 2] #If the whole data is selected without subsampling, nothing is done if {["$this" boxMin getValue 0] == 0 && ["$this" boxMin getValue 1] == 0 && ["$this" boxMin getValue 2] == 0 && ["$this" boxSize getValue 0] == $refDimX && ["$this" boxSize getValue 1] == $refDimY && ["$this" boxSize getValue 2] == $refDimZ && ["$this" refSubsample getValue 0] == 0 && "$type" != "HxVolumeDataObject"} { } else { $extractRefSubvol action hit $extractRefSubvol fire set resampledRef [$extractRefSubvol getResult] "$this" setVar simplifiedRef $resampledRef $extractRefSubvol data disconnect $resampledRef master disconnect if {["$this" hideModule getValue 0]} { $resampledRef hideIcon } else { $resampledRef showIcon } #If orthoviews is enabled, connect the orthoviews to the simplified reference if {["$this" getVar orthoviewEnabled]} { set orthoViews ["$this" getVar orthoViews] set sliceC ["$this" getVar sliceC] if {[exists $sliceC] && [exists $orthoViews]} { set sliceData [$sliceC data source] $orthoViews data connect $resampledRef $orthoViews fire $sliceC data connect $sliceData $sliceC fire } } } } ############################################################################# ## LAST STEP : Align center/principal axes and Register images ############################################################################# "$this" addAction RegisterImages "Register the (resampled) model with the (resampled) reference" initPorts { #LAST STEP PORTS INITIALISATION #Information port "$this" newPortInfo instruction4 "$this" instruction4 setLabel "Instruction" "$this" instruction4 setValue ["$this" getVar info3] #List of available metric "$this" newPortButtonMenu metricChoice 0 1 "$this" metricChoice setLabel "Metric" "$this" metricChoice setNumOptEntries 4 "$this" metricChoice setOptLabel 0 "Normalized Mutual Information" "$this" metricChoice setOptLabel 1 "Mutual Information" "$this" metricChoice setOptLabel 2 "Euclidean" "$this" metricChoice setOptLabel 3 "Correlation" "$this" metricChoice setOptValue 3 #Histogram range for mutual information metrics "$this" newPortIntTextN refRange 2 "$this" refRange setLabel "Histogram Range Reference" "$this" refRange setLabel 0 "Min" "$this" refRange setLabel 1 "Max" "$this" refRange setValue 0 0 "$this" refRange setValue 1 0 "$this" newPortIntTextN modRange 2 "$this" modRange setLabel "Histogram Range Model" "$this" modRange setLabel 0 "Min" "$this" modRange setLabel 1 "Max" "$this" modRange setValue 0 0 "$this" modRange setValue 1 0 #Different type of transformation "$this" newPortToggleList transformType 4 "$this" transformType setLabel "Transformation" "$this" transformType setLabel 0 "Rigid" "$this" transformType setLabel 1 "Iso-scale" "$this" transformType setLabel 2 "Aniso-scale" "$this" transformType setLabel 3 "Shear" "$this" transformType setValue 0 1 "$this" transformType setValue 1 0 "$this" transformType setValue 2 0 "$this" transformType setValue 3 0 #Choice between 2 pre-alignment : center or principal axis alignment "$this" newPortRadioBox alignType 3 "$this" alignType setLabel "Pre-Alignment" "$this" alignType setLabel 0 "Align Centers" "$this" alignType setLabel 1 "Align Principal Axes" "$this" alignType setLabel 2 "None" "$this" alignType setValue 1 } initAction { #Reposition instruction "$this" instruction4 reposition 7 set metric ["$this" metricChoice getOptValue] if {$metric < 2} { "$this" refRange show "$this" modRange show } else { "$this" refRange hide "$this" modRange hide } # Get model or simplified model name if exists set model ["$this" data source] set resampledModel $model if {[exists ["$this" getVar simplifiedModel]]} { set resampledModel ["$this" getVar simplifiedModel] } # Get reference or simplified reference name if exists set ref ["$this" reference source] set resampledRef $ref if {[exists ["$this" getVar simplifiedRef]]} { set resampledRef ["$this" getVar simplifiedRef] } #Create the Register Images module and hide icon if needed if {![exists ["$this" getVar registrationModule]]} { set register [create HxAffineRegistration register] "$this" setVar registrationModule $register } if {["$this" hideModule getValue 0]} { ["$this" getVar registrationModule] hideIcon } else { ["$this" getVar registrationModule] showIcon } # Hide extract subvolume dragger set extractRefSubvol ["$this" getVar refExtractionModule] if {[exists $extractRefSubvol]} { $extractRefSubvol setViewerMask 0 } "$this" boxMin hide "$this" boxSize hide "$this" boxMax hide #Set the min-max of histogram ranges if {!["$this" getVar isNetworkLoading]} { set modelRange [$resampledModel getRange] "$this" modRange setValue 0 [lindex $modelRange 0] "$this" modRange setValue 1 [lindex $modelRange 1] "$this" modRange setMinMax 0 [lindex $modelRange 0] [lindex $modelRange 1] "$this" modRange setMinMax 1 [lindex $modelRange 0] [lindex $modelRange 1] set referenceRange [$resampledRef getRange] "$this" refRange setValue 0 [lindex $referenceRange 0] "$this" refRange setValue 1 [lindex $referenceRange 1] "$this" refRange setMinMax 0 [lindex $referenceRange 0] [lindex $referenceRange 1] "$this" refRange setMinMax 1 [lindex $referenceRange 0] [lindex $referenceRange 1] } } onApplyAction { # Get the model and reference name set model ["$this" data source] set resampledModel $model if {[exists ["$this" getVar simplifiedModel]]} { set resampledModel ["$this" getVar simplifiedModel] } set ref ["$this" reference source] set resampledRef $ref if {[exists ["$this" getVar simplifiedRef]]} { set resampledRef ["$this" getVar simplifiedRef] eval $resampledRef setTransform [$ref getTransform] } set register ["$this" getVar registrationModule] #Connect the model and reference source for Register Images $register model connect $resampledModel $register reference connect $resampledRef #Options of Register Images set metricNumber ["$this" metricChoice getOptValue 0] $register metric setValue $metricNumber $register fire #If mutual information metric is selected if {$metricNumber == 0 || $metricNumber == 1} { $register histogramRangeRef setValue 0 ["$this" refRange getValue 0] $register histogramRangeRef setValue 1 ["$this" refRange getValue 1] $register histogramRangeMod setValue 0 ["$this" modRange getValue 0] $register histogramRangeMod setValue 1 ["$this" modRange getValue 1] $register fire } #Set transformation type $register transform setValue 0 ["$this" transformType getValue 0] $register transform setValue 1 ["$this" transformType getValue 1] $register transform setValue 2 ["$this" transformType getValue 2] $register transform setValue 3 ["$this" transformType getValue 3] #Register Images action set model ["$this" data source] set preAlign ["$this" alignType getValue] if ([expr $preAlign != 2]) { if {$preAlign == 0} { echo "------------------------ Align center ------------------------" } else { echo "-------------------- Align principal axes --------------------" } $register action setValue $preAlign $register fire } #Copy transformation to the original model if {$model != $resampledModel} { set trans [$resampledModel getTransform] eval $model setTransform $trans } echo "---------------------- Register Images ----------------------" $register doIt hit $register fire #Copy transformation to the original model if {$model != $resampledModel} { set trans [$resampledModel getTransform] eval $model setTransform $trans } #Reconnect orthoviews and slice to the initial model/ref, if orthoviews is enabled if {["$this" getVar orthoviewEnabled]} { "OrthoViews" data connect ["$this" reference source] "OrthoViews" fire "SliceC" data connect ["$this" data source] "SliceC" fire } } }