diff --git a/fsl/fslview/controls/clusterpanel.py b/fsl/fslview/controls/clusterpanel.py index 20ba3e1a21e85f3b277da47fed8abcc9b888a999..8cd1d2d97a8be84bb960eb6944b8e5a36b914e4c 100644 --- a/fsl/fslview/controls/clusterpanel.py +++ b/fsl/fslview/controls/clusterpanel.py @@ -108,12 +108,13 @@ class ClusterPanel(fslpanel.FSLViewPanel): opts = self._displayCtx.getOpts(zstats) zthres = float(overlay.thresholds()['z']) - + + # Set some display parameters if + # we have a z value threshold if zthres is not None: absmax = max(map(abs, (opts.dataMin, opts.dataMax))) - # Set clipping range opts.cmap = 'Render3' opts.invertClipping = True opts.displayRange.x = -absmax, absmax diff --git a/fsl/fslview/gl/gl14/glvolume_frag.prog b/fsl/fslview/gl/gl14/glvolume_frag.prog index 4de3ebdece1915d5c16066d6c1aad06fff870beb..99d0e41ad6cca5a289173141308dc9771ba86885 100644 --- a/fsl/fslview/gl/gl14/glvolume_frag.prog +++ b/fsl/fslview/gl/gl14/glvolume_frag.prog @@ -31,8 +31,12 @@ # # program.local[5] - Vector containing clipping values - voxels with a # value below the low threshold (x), or above the -# high threshold (y) will not be shown. Assumed to -# be normalised to the image texture value range. +# high threshold (y) will not be shown. The (z) +# component determines the clipping direction - pass +# in -1 for the above behaviour, or +1 to invert +# this behaviour (i.e. to clip values that are within +# the range). Clipping values are assumed to be +# normalised to the image texture value range. # # # Outputs: @@ -43,7 +47,8 @@ # TEMP voxCoord; -TEMP voxClip; +TEMP voxClipLo; +TEMP voxClipHi; TEMP voxValue; PARAM imageShape = program.local[4]; @@ -67,16 +72,29 @@ MOV voxCoord, fragment.texcoord[1]; # from 3D image texture TEX voxValue, fragment.texcoord[0], texture[0], 3D; -# If the voxel value is outside the -# clipping range, don't draw it - # Test the low clipping range -SUB voxClip, voxValue.x, clipping.x; -KIL voxClip; +SUB voxClipLo, voxValue.x, clipping.x; # And the high clipping range -SUB voxClip, clipping.y, voxValue.x; -KIL voxClip; +SUB voxClipHi, voxValue.x, clipping.y; + +# Multiply the low/high results - after +# this, voxClipLo will be positive if +# the value is outside of the clipping +# range, or negative if the value is +# within the clipping range +MUL voxClipLo, voxClipLo, voxClipHi; + +# Multiply by the clipping.z setting - +# this will invert the sign if normal +# clipping is active +MUL voxClipLo, voxClipLo, clipping.z; + +# If the voxel value is outside +# the clipping range (or inside, +# if clipping is inverted), don't +# draw it +KIL voxClipLo; # Scale voxel value according # to the current display range diff --git a/fsl/fslview/gl/gl14/glvolume_funcs.py b/fsl/fslview/gl/gl14/glvolume_funcs.py index 0d42cd78be04ae5b7bebf65d2333e95ad46f75dc..1b998ac57cdfb0422c8896975934b3cebae30c7d 100644 --- a/fsl/fslview/gl/gl14/glvolume_funcs.py +++ b/fsl/fslview/gl/gl14/glvolume_funcs.py @@ -99,18 +99,19 @@ def updateShaderState(self): # And the clipping range, normalised # to the image texture value range - clipLo = opts.clippingRange[0] * \ + invClip = 1 if opts.invertClipping else -1 + clipLo = opts.clippingRange[0] * \ self.imageTexture.invVoxValXform[0, 0] + \ self.imageTexture.invVoxValXform[3, 0] - clipHi = opts.clippingRange[1] * \ + clipHi = opts.clippingRange[1] * \ self.imageTexture.invVoxValXform[0, 0] + \ self.imageTexture.invVoxValXform[3, 0] - + shaders.setVertexProgramVector( 0, shape + [0]) shaders.setFragmentProgramMatrix(0, voxValXform) shaders.setFragmentProgramVector(4, shape + [0]) - shaders.setFragmentProgramVector(5, [clipLo, clipHi, 0, 0]) + shaders.setFragmentProgramVector(5, [clipLo, clipHi, invClip, 0]) gl.glDisable(arbvp.GL_VERTEX_PROGRAM_ARB) gl.glDisable(arbfp.GL_FRAGMENT_PROGRAM_ARB)