fsleyes.render¶
The render module is a program which provides off-screen rendering
capability for scenes which can otherwise be displayed via FSLeyes.
-
fsleyes.render.main(args=None, hook=None)[source]¶ Entry point for
render.Creates and renders an OpenGL scene, and saves it to a file, according to the specified command line arguments (which default to
sys.argv[1:]).
-
fsleyes.render.parseArgs(argv)[source]¶ Creates an argument parser which accepts options for off-screen rendering. Uses the
fsleyes.parseargsmodule to peform the actual parsing.- Returns
An
argparse.Namespaceobject containing the parsed arguments.
-
fsleyes.render.makeDisplayContext(namespace)[source]¶ Creates
OverlayList,DisplayContext`, andSceneOptsinstances which represent the scene to be rendered, as described by the arguments in the givennamespaceobject.
-
fsleyes.render.render(namespace, overlayList, displayCtx, sceneOpts, hook=None)[source]¶ Renders the scene, and returns a tuple containing the bitmap and the background colour.
- Parameters
namespace –
argparse.Namespaceobject containing command line arguments.overlayList – The
OverlayListinstance.displayCtx – The
DisplayContextinstance.sceneOpts – The
SceneOptsinstance.hook – Function which is called after the canvases have been created, but before the scene is rendered. Can be used to perform any configuration/drawing in addition to that specified via
namespace.
Note
The
hookargument was added for testing purposes, but may be useful in other situations.
-
fsleyes.render.createLightBoxCanvas(namespace, width, height, overlayList, displayCtx, sceneOpts)[source]¶ Creates, configures, and returns an
OffScreenLightBoxCanvas.- Parameters
namespace –
argparse.Namespaceobject.width – Available width in pixels.
height – Available height in pixels.
overlayList – The
OverlayListinstance.displayCtx – The
DisplayContextinstance.sceneOpts – The
SceneOptsinstance.
-
fsleyes.render.createOrthoCanvases(namespace, width, height, overlayList, displayCtx, sceneOpts)[source]¶ Creates, configures, and returns up to three
OffScreenSliceCanvasinstances, for rendering the scene.- Parameters
namespace –
argparse.Namespaceobject.width – Available width in pixels.
height – Available height in pixels.
overlayList – The
OverlayListinstance.displayCtx – The
DisplayContextinstance.sceneOpts – The
SceneOptsinstance.
-
fsleyes.render.create3DCanvas(namespace, width, height, overlayList, displayCtx, sceneOpts)[source]¶ Creates, configures, and returns an
OffScreenScene3DCanvas.- Parameters
namespace –
argparse.Namespaceobject.width – Available width in pixels.
height – Available height in pixels.
overlayList – The
OverlayListinstance.displayCtx – The
DisplayContextinstance.sceneOpts – The
SceneOptsinstance.
-
fsleyes.render.buildColourBarBitmap(overlayList, displayCtx, width, height, sceneOpts)[source]¶ If the currently selected overlay has a display range, creates and returns a bitmap containing a colour bar. Returns
Noneotherwise.- Parameters
overlayList – The
OverlayList.displayCtx – The
DisplayContext.width – Colour bar width in pixels.
height – Colour bar height in pixels.
sceneOpts –
SceneOptsinstance containing display settings.
-
fsleyes.render.buildColourBarLayout(canvasLayout, cbarBmp, cbarLocation, cbarLabelSide)[source]¶ Given a layout object containing the rendered canvas bitmaps, creates a new layout which incorporates the given colour bar bitmap.
- Parameters
canvasLayout – An object describing the canvas layout (see
fsleyes_widgets.utils.layout)cbarBmp – A bitmap containing a rendered colour bar.
cbarLocation – Colour bar location (see
buildColourBarBitmap()).cbarLabelSide – Colour bar label side (see
buildColourBarBitmap()).
-
fsleyes.render.adjustSizeForColourBar(width, height, showColourBar, colourBarLocation, fontSize)[source]¶ Calculates the widths and heights of the image display space, and the colour bar if it is enabled.
- Parameters
width – Desired width in pixels
height – Desired height in pixels
showColourBar –
Trueif a colour bar is to be shown,Falseotherwise.colourBarLocation – Colour bar location (see
buildColourBarBitmap()).
:arg fontSize Font size (points) used in colour bar labels.
- Returns
Two tuples - the first tuple contains the
(width, height)of the available canvas space, and the second contains the(width, height)of the colour bar.
-
fsleyes.render.calculateOrthoCanvasSizes(overlayList, displayCtx, width, height, canvasAxes, layout)[source]¶ Calculates the sizes, in pixels, for each canvas to be displayed in an orthographic layout.
- Parameters
overlayList – The
OverlayList.displayCtx – The
DisplayContext.width – Available width in pixels.
height – Available height in pixels.
canvasAxes – A sequence of
(xax, yax)indices, one for each bitmap incanvasBmps.layout – Either
'horizontal','vertical', or'grid', describing the canvas layout.
- Returns
A list of
(width, height)tuples, one for each canvas, each specifying the canvas width and height in pixels.
-
fsleyes.render.autocrop(data, bgColour, border=0)[source]¶ Crops the given bitmap image on all sides where the
bgColouris the only colour present.If the image is completely empty. it is not cropped.
- Parameters
data –
numpyarray of shape(w, h, 4)containing the image.bgColour – Sequence of length 4 containing the background colour to crop.
border – Number of pixels to leave around each side.
-
class
fsleyes.render.MockSliceCanvas[source]¶ Bases:
objectUsed in place of a
SliceCanvas. Theparseargsmodule needs access toSliceCanvasinstances to apply some command line options. However,rendercallsparseargs.applySceneArgs()before anySliceCanvasinstances have been created.Instances of this class are just used to capture those options, so they can later be applied to the real
SliceCanvasinstances.- The following arguments may be applied to this class.
--xcentre--ycentre--zcentre
-
__dict__= mappingproxy({'__module__': 'fsleyes.render', '__doc__': 'Used in place of a :class:`.SliceCanvas`. The :mod:`.parseargs` module\n needs access to ``SliceCanvas`` instances to apply some command line\n options. However, ``render`` calls :func:`.parseargs.applySceneArgs`\n before any ``SliceCanvas`` instances have been created.\n\n Instances of this class are just used to capture those options, so they\n can later be applied to the real ``SliceCanvas`` instances.\n\n The following arguments may be applied to this class.\n - ``--xcentre``\n - ``--ycentre``\n - ``--zcentre``\n ', '__init__': <function MockSliceCanvas.__init__>, 'centreDisplayAt': <function MockSliceCanvas.centreDisplayAt>, '__dict__': <attribute '__dict__' of 'MockSliceCanvas' objects>, '__weakref__': <attribute '__weakref__' of 'MockSliceCanvas' objects>, '__annotations__': {}})¶
-
__module__= 'fsleyes.render'¶
-
__weakref__¶ list of weak references to the object (if defined)
-
class
fsleyes.render.MockCanvasPanel(ncanvases)[source]¶ Bases:
objectUsed in place of a
CanvasPanel. This is used as a container forMockSliceCanvasinstances.-
__dict__= mappingproxy({'__module__': 'fsleyes.render', '__doc__': 'Used in place of a :class:`.CanvasPanel`. This is used as a container\n for :class:`MockSliceCanvas` instances.\n ', '__init__': <function MockCanvasPanel.__init__>, 'getGLCanvases': <function MockCanvasPanel.getGLCanvases>, '__dict__': <attribute '__dict__' of 'MockCanvasPanel' objects>, '__weakref__': <attribute '__weakref__' of 'MockCanvasPanel' objects>, '__annotations__': {}})¶
-
__module__= 'fsleyes.render'¶
-
__weakref__¶ list of weak references to the object (if defined)
-
-
class
fsleyes.render.MockOrthoPanel(canvases)[source]¶ Bases:
objectUsed in place of an
OrthoPanel. This is used as a container for threeSliceCanvasinstances.-
__dict__= mappingproxy({'__module__': 'fsleyes.render', '__doc__': 'Used in place of an :class:`.OrthoPanel`. This is used as a container\n for three :class:`SliceCanvas` instances.\n ', '__init__': <function MockOrthoPanel.__init__>, 'getGLCanvases': <function MockOrthoPanel.getGLCanvases>, 'getXCanvas': <function MockOrthoPanel.getXCanvas>, 'getYCanvas': <function MockOrthoPanel.getYCanvas>, 'getZCanvas': <function MockOrthoPanel.getZCanvas>, '__dict__': <attribute '__dict__' of 'MockOrthoPanel' objects>, '__weakref__': <attribute '__weakref__' of 'MockOrthoPanel' objects>, '__annotations__': {}})¶
-
__module__= 'fsleyes.render'¶
-
__weakref__¶ list of weak references to the object (if defined)
-