fsleyes.displaycontext.shopts

This module provides the SHOpts class, a VectorOpts class for rendering Image instances which contain fibre orientation distributions (FODs) in the form of spherical harmonic (SH) coefficients.

fsleyes.displaycontext.shopts.SH_COEFFICIENT_TYPE = {1: ('asym', 0), 6: ('sym', 2), 9: ('asym', 2), 15: ('sym', 4), 25: ('asym', 4), 28: ('sym', 6), 45: ('sym', 8), 49: ('asym', 6), 66: ('sym', 10), 81: ('asym', 8), 91: ('sym', 12), 120: ('sym', 14), 121: ('asym', 10), 153: ('sym', 16), 169: ('asym', 12), 225: ('asym', 14), 289: ('asym', 16)}

Image files which contain SH coefficients may be symmetric (only containing coefficients for even spherical functions) or asymmetric (containing coefficients for odd and even functions). This dictionary provides mappings from the number coefficients (the volumes contained in the image), to the file type (either symmetric ['sym'] or asymmetric ['asym'), and the maximum SH order that was used in generating the coefficients.

class fsleyes.displaycontext.shopts.SHOpts(*args, **kwargs)

Bases: fsleyes.displaycontext.vectoropts.VectorOpts

The SHOpts is used for rendering Image instances which contain fibre orientation distributions (FODs) in the form of spherical harmonic (SH) coefficients. A SHOpts instance will be used for Image overlays with a Displaty.overlayType set to 'sh'.

A collection of pre-calculated SH basis function parameters are stored in the assets/sh/ directory. Depending on the SH order that was used in the fibre orientation, and the desired display resolution (controlled by shResolution), a different set of parameters needs to be used. The getSHParameters() method will load and return the corrrect set of parameters.

shResolution = <MagicMock name='mock.Int()' id='140735846123216'>

Resolution of the sphere used to display the FODs at each voxel. The value is equal to the number of iterations that an isocahedron, starting with 12 vertices, is tessellated. The resulting number of vertices is as follows:

Number of iterations

Number of vertices

3

92

4

162

5

252

6

362

7

492

8

642

9

812

10

1002

size = <MagicMock name='mock.Percentage()' id='140735841619344'>

Display size - this is simply a linear scaling factor.

lighting = <MagicMock name='mock.Boolean()' id='140735851538640'>

Apply a simple directional lighting model to the FODs.

radiusThreshold = <MagicMock name='mock.Real()' id='140735894843600'>

FODs with a maximum radius that is below this threshold are not shown.

normalise = <MagicMock name='mock.Boolean()' id='140735851538640'>

If True, the size of each FOD is scaled to fit within a voxel. Otherwise the size of each FOD is scaled relative to the entire image.

colourMode = <MagicMock name='mock.Choice()' id='140735848912272'>

How to colour each FOD. This property is overridden if the VectorOpts.colourImage is set.

  • 'direction' The vertices of an FOD are coloured according to their

    x/y/z location (see xColour, yColour, and zColour).

  • 'radius' The vertices of an FOD are coloured according to their

    distance from the FOD centre (see colourMap).

__init__(*args, **kwargs)

Create a VectorOpts instance for the given image. All arguments are passed through to the NiftiOpts constructor.

__module__ = 'fsleyes.displaycontext.shopts'
shOrder = <MagicMock name='mock.Choice()' id='140735848912272'>

Maximum spherical harmonic order to visualise. This is populated in __init__().

property shType

Returns either 'sym' or 'asym', depending on the type of the SH coefficients contained in the file.

property maxOrder

Returns the maximum SH order that was used to generate the coefficients of the SH image.

getSHParameters()

Load and return a numpy array containing pre-calculated SH function parameters for the curert maximum SH order and display resolution. The returned array has the shape (N, C), where N is the number of vertices used to represent each FOD, and C is the number of SH coefficients.

getVertices()

Loads and returns a numpy array of shape (N, 3), containing N vertices of a tessellated sphere.

getIndices()

Loads and returns a 1D numpy array, containing indices into the vertex array, specifying the order in which they are to be drawn as triangles.