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)¶ 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)¶ Creates an argument parser which accepts options for off-screen rendering. Uses the
fsleyes.parseargs
module to peform the actual parsing.Returns: An argparse.Namespace
object containing the parsed arguments.
-
fsleyes.render.
makeDisplayContext
(namespace)¶ Creates
OverlayList
,DisplayContext`
, andSceneOpts
instances which represent the scene to be rendered, as described by the arguments in the givennamespace
object.
-
fsleyes.render.
render
(namespace, overlayList, displayCtx, sceneOpts)¶ Renders the scene, and returns a tuple containing the bitmap and the background colour.
Parameters: - namespace –
argparse.Namespace
object containing command line arguments. - overlayList – The
OverlayList
instance. - displayCtx – The
DisplayContext
instance. - sceneOpts – The
SceneOpts
instance.
- namespace –
-
fsleyes.render.
createLightBoxCanvas
(namespace, width, height, overlayList, displayCtx, sceneOpts)¶ Creates, configures, and returns an
OffScreenLightBoxCanvas
.Parameters: - namespace –
argparse.Namespace
object. - width – Available width in pixels.
- height – Available height in pixels.
- overlayList – The
OverlayList
instance. - displayCtx – The
DisplayContext
instance. - sceneOpts – The
SceneOpts
instance.
- namespace –
-
fsleyes.render.
createOrthoCanvases
(namespace, width, height, overlayList, displayCtx, sceneOpts)¶ Creates, configures, and returns up to three
OffScreenSliceCanvas
instances, for rendering the scene.Parameters: - namespace –
argparse.Namespace
object. - width – Available width in pixels.
- height – Available height in pixels.
- overlayList – The
OverlayList
instance. - displayCtx – The
DisplayContext
instance. - sceneOpts – The
SceneOpts
instance.
- namespace –
-
fsleyes.render.
create3DCanvas
(namespace, width, height, overlayList, displayCtx, sceneOpts)¶ Creates, configures, and returns an
OffScreenScene3DCanvas
.Parameters: - namespace –
argparse.Namespace
object. - width – Available width in pixels.
- height – Available height in pixels.
- overlayList – The
OverlayList
instance. - displayCtx – The
DisplayContext
instance. - sceneOpts – The
SceneOpts
instance.
- namespace –
-
fsleyes.render.
buildColourBarBitmap
(overlayList, displayCtx, width, height, sceneOpts)¶ If the currently selected overlay has a display range, creates and returns a bitmap containing a colour bar. Returns
None
otherwise.Parameters: - overlayList – The
OverlayList
. - displayCtx – The
DisplayContext
. - width – Colour bar width in pixels.
- height – Colour bar height in pixels.
- sceneOpts –
SceneOpts
instance containing display settings.
- overlayList – The
-
fsleyes.render.
buildColourBarLayout
(canvasLayout, cbarBmp, cbarLocation, cbarLabelSide)¶ 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()
).
- canvasLayout – An object describing the canvas layout (see
-
fsleyes.render.
adjustSizeForColourBar
(width, height, showColourBar, colourBarLocation, fontSize)¶ 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 –
True
if a colour bar is to be shown,False
otherwise. - 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)¶ 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.- overlayList – The
-
fsleyes.render.
autocrop
(data, bgColour, border=0)¶ Crops the given bitmap image on all sides where the
bgColour
is the only colour present.If the image is completely empty. it is not cropped.
Parameters: - data –
numpy
array 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.
- data –
-
class
fsleyes.render.
MockSliceCanvas
¶ Bases:
object
Used in place of a
SliceCanvas
. Theparseargs
module needs access toSliceCanvas
instances to apply some command line options. However,render
callsparseargs.applySceneArgs()
before anySliceCanvas
instances have been created.Instances of this class are just used to capture those options, so they can later be applied to the real
SliceCanvas
instances.- The following arguments may be applied to this class.
--xcentre
--ycentre
--zcentre
-
__init__
()¶ Initialize self. See help(type(self)) for accurate signature.
-
centreDisplayAt
(x, y)¶
-
__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>})¶
-
__module__
= 'fsleyes.render'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
class
fsleyes.render.
MockCanvasPanel
(ncanvases)¶ Bases:
object
Used in place of a
CanvasPanel
. This is used as a container forMockSliceCanvas
instances.-
__init__
(ncanvases)¶ Initialize self. See help(type(self)) for accurate signature.
-
getGLCanvases
()¶
-
__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>})¶
-
__module__
= 'fsleyes.render'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-