diff --git a/fsl/fslview/gl/gl14/gltensor_frag.prog b/fsl/fslview/gl/gl14/gltensor_frag.prog index c97343333f95cb95f73787d3cb1278e73754c0d5..72c5604176e87f2d60c08fa1579eaa3f360411c5 100644 --- a/fsl/fslview/gl/gl14/gltensor_frag.prog +++ b/fsl/fslview/gl/gl14/gltensor_frag.prog @@ -54,13 +54,15 @@ TEX voxValue, normVoxCoord, texture[0], 3D; ADD voxValue, voxValue, { 0.0, 0.0, 0.0, 1.0 }; # Look up the modulation value -# from the modulation texture +# from the modulation texture - +# initialise modValue transparency +# to 1.0, so it doesn't corrupt +# our voxel colour value later on +MOV modValue, { 0.0, 0.0, 0.0, 1.0 }; TEX modValue, normVoxCoord, texture[1], 3D; -ADD modValue, modValue, { 0.0, 0.0, 0.0, 1.0 }; -# Use those values to look up -# the colours for each xyz -# direction +# Use those values to look up the +# colours for each xyz direction TEX xColour, voxValue.x, texture[2], 1D; TEX yColour, voxValue.y, texture[3], 1D; TEX zColour, voxValue.z, texture[4], 1D; @@ -71,7 +73,7 @@ MOV voxColour, xColour; ADD voxColour, voxColour, yColour; ADD voxColour, voxColour, zColour; -# But take the average of the alpha channel +# Take the average of the alpha channel MUL voxColour, voxColour, { 1.0, 1.0, 1.0, 0.333333 }; # Apply the modulation factor diff --git a/fsl/fslview/gl/gl14/gltensor_line_funcs.py b/fsl/fslview/gl/gl14/gltensor_line_funcs.py index 37ea8033e12edf9ae9ecc1f14f35fdc8da2fde3f..54569aa3562aa2dab0f28aff3ef942e5f515d4b2 100644 --- a/fsl/fslview/gl/gl14/gltensor_line_funcs.py +++ b/fsl/fslview/gl/gl14/gltensor_line_funcs.py @@ -121,6 +121,7 @@ def draw(self, zpos, xform=None): # Transform the world coordinates to # floating point voxel coordinates dToVMat = display.displayToVoxMat + vToDMat = display.voxToDisplayMat voxCoords = transform.transform(worldCoords, dToVMat).transpose() imageData = image.data @@ -157,23 +158,17 @@ def draw(self, zpos, xform=None): # make a bunch of vertices which represent lines # (two vertices per line), centered at the origin # and scaled appropriately - vecs[:, xax] *= 0.5 * self.xpixdim - vecs[:, yax] *= 0.5 * self.ypixdim + vecs *= 0.5 + vecs = np.hstack((-vecs, vecs)).reshape((2 * nVoxels, 3)) - # Flatten on the depth axis - vecs[:, zax] = 0.0 - vecs = np.hstack((-vecs, vecs)).reshape((2 * nVoxels, 3)) - - # - # TODO The above code assumes a correspondence - # between the image array axes and the display - # coordinate system axes. I'm not currently - # sure how to get around this. - # + # Offset each of those vertices by + # their original voxel coordinates + vecs += voxCoords.T.repeat(2, 0) # Translate the world coordinates # by those line vertices - worldCoords = worldCoords.repeat(2, 0) + vecs + worldCoords = transform.transform(vecs, vToDMat) + worldCoords[:, zax] = zpos worldCoords = np.array(worldCoords, dtype=np.float32).ravel('C') # Draw all the lines! diff --git a/fsl/utils/transform.py b/fsl/utils/transform.py index f8d427ca3bc09276442ded2312020db754b64969..b77526f25ae9a5704fdf7c59996d9d15b6323ed8 100644 --- a/fsl/utils/transform.py +++ b/fsl/utils/transform.py @@ -44,8 +44,8 @@ def scaleOffsetXform(scales, offsets): xform[2, 2] = scales[2] xform[3, 0] = offsets[0] - xform[3, 1] = offsets[0] - xform[3, 2] = offsets[0] + xform[3, 1] = offsets[1] + xform[3, 2] = offsets[2] return xform