# Template HX Script # NO DEPRECATION WARNING module -name "Compare Images Template" \ -category "Templates" \ -customHelp "compareImagesTemplate.html" \ -icon "TVDefScriptObject" \ -proc \ { # Set template related stuff: name and input types _template begin "Compare Images" _template input "Image A" "Image B" _template types 0 HxUniformScalarField3 HxStackedScalarField3 HxRegColorField3 HxMultiChannelField3 _template types 1 HxUniformScalarField3 HxStackedScalarField3 HxRegColorField3 HxMultiChannelField3 _template submodules 0 HxOrthoSlice _template submodules 1 HxOrthoSlice # Names of data/modules in the template set helpMod "Press F1 for help" set grayScaleCmap "grayScale.am" set volrenCmap "volrenWhite.am" set imageAOS "Ortho Slice Image A" set imageBOS "Ortho Slice Image B" set surimpMod "Color Wash" set vrs1 "Volume Rendering Settings Image A" set vr1 "Volume Rendering Image A" set vrs2 "Volume Rendering Settings Image B" set vr2 "Volume Rendering Image B" # Create the blue module for help set hideNewModules 0 create HxScriptObject $helpMod $helpMod script hide $helpMod data hide $helpMod setVar "CustomHelp" {compareImagesTemplate.html} $helpMod select # Open the dialog for inputs set _continue [_template prompt] if $_continue { if {[catch { remove_tmpio # Get the names of the input set imageA [_template var 0] set imageB [_template var 1] set imageADims [ $imageA getDims ] set imageBDims [ $imageB getDims ] # Create two vertical viewers viewer setVertical 1 viewer 0 setTransparencyType 6 viewer 0 setAutoRedraw 0 viewer 0 show viewer 1 setTransparencyType 6 viewer 1 setAutoRedraw 0 viewer 1 show mainWindow show # Load necessary colormaps set hideNewModules 1 if { [_template duplicate_colormaps] || ! [exists $grayScaleCmap] } { set grayScaleCmap [ [ load "${AMIRA_ROOT}/data/colormaps/grayScale.am" ] setLabel $grayScaleCmap ] $grayScaleCmap setNoRemoveAll 1 } if { [_template duplicate_colormaps] || ! [exists $volrenCmap] } { set volrenCmap [ [ load "${AMIRA_ROOT}/data/colormaps/volrenWhite.am" ] setLabel $volrenCmap ] $volrenCmap setNoRemoveAll 1 } # Display the orthoslice connected to image A set hideNewModules 0 set imageAOS [ [ moduleApply HxOrthoSlice data "$imageA" colormap $grayScaleCmap options "0 1" ] setLabel $imageAOS ] $imageAOS fire $imageAOS setViewerMask 65533 $imageAOS colormap setPin 1 if { [ lindex $imageADims 2 ] != 1 } { $imageAOS sliceNumber setPin 1 $imageAOS sliceOrientation setPin 1 } # Display the color wash set hideNewModules 0 set surimpMod [ [ moduleApply HxColorwash data "$imageB" module $imageAOS colormap $grayScaleCmap ] setLabel $surimpMod ] $surimpMod fire $surimpMod weightFactor setPin 1 # Display the orthoslice connected to image B set hideNewModules 0 set imageBOS [ [ moduleApply HxOrthoSlice data "$imageB" colormap $grayScaleCmap options "0 1" ] setLabel $imageBOS ] $imageBOS fire $imageBOS setViewerMask 65534 # For 3D images, add hidden volume rendering if { [ lindex $imageADims 2 ] != 1 } { set hideNewModules 0 set vr1 [ [ moduleApply HxVolumeRender2 volumeRenderingSettings [ [ moduleApply HxVolumeRenderingSettings data $imageA ] setLabel $vrs1 ] colormap $volrenCmap ] setLabel $vr1 ] $vr1 setViewerMask 0 $vr1 fire } if { [ lindex $imageBDims 2 ] != 1 } { set hideNewModules 0 set vr2 [ [ moduleApply HxVolumeRender2 volumeRenderingSettings [ [ moduleApply HxVolumeRenderingSettings data $imageB ] setLabel $vrs2 ] colormap $volrenCmap ] setLabel $vr2 ] $vr2 setViewerMask 0 $vr2 fire } viewer 0 linkViewer 1 viewer 0 setAutoRedraw 1 viewer 1 setAutoRedraw 1 viewer 0 redraw viewer 1 redraw viewer view 2 viewer setViewingMode 4 viewer 0 viewAll $imageAOS sliceOrientation interconnect $imageBOS sliceOrientation $imageAOS options interconnect $imageBOS options $imageAOS mappingType interconnect $imageBOS mappingType $imageAOS colormap interconnect $surimpMod colormap $imageAOS sliceNumber interconnect $imageBOS sliceNumber $imageAOS colormap interconnect $imageBOS colormap } errmsg]} { echo "Error while executing template compare-image: $errmsg" remove $helpMod } } _template end }