Skip to content
Snippets Groups Projects
Commit 9dbd4ec1 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Tensor scaling factor working.

parent e7418505
No related branches found
No related tags found
No related merge requests found
...@@ -576,6 +576,7 @@ properties = TypeDict({ ...@@ -576,6 +576,7 @@ properties = TypeDict({
'TensorOpts.lighting' : 'Lighting effects', 'TensorOpts.lighting' : 'Lighting effects',
'TensorOpts.tensorResolution' : 'Ellipsoid quality', 'TensorOpts.tensorResolution' : 'Ellipsoid quality',
'TensorOpts.tensorScale' : 'Tensor size',
}) })
......
...@@ -377,6 +377,7 @@ _DISPLAY_PROPS = td.TypeDict({ ...@@ -377,6 +377,7 @@ _DISPLAY_PROPS = td.TypeDict({
spin=False, spin=False,
labels=[strings.choices['TensorOpts.tensorResolution.min'], labels=[strings.choices['TensorOpts.tensorResolution.min'],
strings.choices['TensorOpts.tensorResolution.max']]), strings.choices['TensorOpts.tensorResolution.max']]),
props.Widget('tensorScale', showLimits=False, spin=False),
props.Widget('xColour'), props.Widget('xColour'),
props.Widget('yColour'), props.Widget('yColour'),
props.Widget('zColour'), props.Widget('zColour'),
...@@ -385,6 +386,7 @@ _DISPLAY_PROPS = td.TypeDict({ ...@@ -385,6 +386,7 @@ _DISPLAY_PROPS = td.TypeDict({
props.Widget('suppressZ'), props.Widget('suppressZ'),
props.Widget('modulateImage', labels=_imageName), props.Widget('modulateImage', labels=_imageName),
props.Widget('clipImage', labels=_imageName), props.Widget('clipImage', labels=_imageName),
props.Widget('clipThreshold', props.Widget('clipThreshold',
showLimits=False, showLimits=False,
spin=False, spin=False,
......
...@@ -29,7 +29,8 @@ class TensorOpts(vectoropts.VectorOpts): ...@@ -29,7 +29,8 @@ class TensorOpts(vectoropts.VectorOpts):
:func:`.routines.unitSphere` function. :func:`.routines.unitSphere` function.
""" """
tensorScale = props.Real(minval=0.0, maxval=5.0, default=1.0)
tensorScale = props.Percentage(minval=50, maxval=600, default=100)
"""Scaling factor - by default, the tensor ellipsoids are scaled such that """Scaling factor - by default, the tensor ellipsoids are scaled such that
the biggest tensor (as defined by the first principal eigenvalue) fits the biggest tensor (as defined by the first principal eigenvalue) fits
inside a voxel. This parameter can be used to adjust this scale. inside a voxel. This parameter can be used to adjust this scale.
......
...@@ -181,11 +181,13 @@ def updateShaderState(self): ...@@ -181,11 +181,13 @@ def updateShaderState(self):
imageShape = np.array(self.image.shape[:3], dtype=np.float32) imageShape = np.array(self.image.shape[:3], dtype=np.float32)
resolution = opts.tensorResolution resolution = opts.tensorResolution
clipThreshold = opts.clipThreshold clipThreshold = opts.clipThreshold
tensorScale = opts.tensorScale
lighting = 1 if opts.lighting else 0 lighting = 1 if opts.lighting else 0
useSpline = 0 useSpline = 0
l1 = self.image.L1() l1 = self.image.L1()
eigValNorm = 0.5 / abs(l1.data).max() eigValNorm = 0.5 / abs(l1.data).max()
eigValNorm *= tensorScale / 100.0
invClipValXform = self.clipTexture .invVoxValXform invClipValXform = self.clipTexture .invVoxValXform
clipThreshold = clipThreshold * invClipValXform[0, 0] + \ clipThreshold = clipThreshold * invClipValXform[0, 0] + \
......
...@@ -58,6 +58,7 @@ class GLTensor(glvector.GLVector): ...@@ -58,6 +58,7 @@ class GLTensor(glvector.GLVector):
opts.addListener('lighting', name, shaderUpdate, weak=False) opts.addListener('lighting', name, shaderUpdate, weak=False)
opts.addListener('tensorResolution', name, shaderUpdate, weak=False) opts.addListener('tensorResolution', name, shaderUpdate, weak=False)
opts.addListener('tensorScale', name, shaderUpdate, weak=False)
def removeListeners(self): def removeListeners(self):
...@@ -71,6 +72,7 @@ class GLTensor(glvector.GLVector): ...@@ -71,6 +72,7 @@ class GLTensor(glvector.GLVector):
opts.removeListener('lighting', name) opts.removeListener('lighting', name)
opts.removeListener('tensorResolution', name) opts.removeListener('tensorResolution', name)
opts.removeListener('tensorScale', name)
def getDataResolution(self, xax, yax): def getDataResolution(self, xax, yax):
......
...@@ -121,7 +121,15 @@ def setFragmentProgramMatrix(index, matrix): ...@@ -121,7 +121,15 @@ def setFragmentProgramMatrix(index, matrix):
def getShaderVars(shaders, vertAtts, vertUniforms, fragUniforms): def getShaderVars(shaders, vertAtts, vertUniforms, fragUniforms):
""" """Gets the position indices for all vertex shader attributes, uniforms,
and fragment shader uniforms for the given shader programs.
:arg shaders:
:arg vertAtts:
:arg vertUniforms:
:arg fragUniforms:
:returns:
""" """
import OpenGL.GL as gl import OpenGL.GL as gl
......
...@@ -186,7 +186,21 @@ properties = TypeDict({ ...@@ -186,7 +186,21 @@ properties = TypeDict({
'setting defines the space, relative to the ' 'setting defines the space, relative to the '
'reference image, in which the model ' 'reference image, in which the model '
'coordinates are defined.', 'coordinates are defined.',
'TensorOpts.lighting' : 'If enabled, a simple lighting model is '
'used to highlight the tensor '
'orientations.',
'TensorOpts.tensorResolution' : 'This setting controls the number of '
'vertices used to render each tensor. '
'A higher value will result in better '
'looking tensors, but may reduce '
'performance.' ,
'TensorOpts.tensorScale' : 'By default, the tensor radii are scaled '
'the largest eigenvalue of the tensor '
'matrix, so that the largest tensor is '
'drawn to fit within a voxel. This '
'setting allows the tensor scale to be '
'adjusted.',
# SceneOpts # SceneOpts
'SceneOpts.showCursor' : 'Show/hide the cursor which highlights ' 'SceneOpts.showCursor' : 'Show/hide the cursor which highlights '
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment