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)[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.parseargs
module to peform the actual parsing.- Returns
An
argparse.Namespace
object containing the parsed arguments.
-
fsleyes.render.
makeDisplayContext
(namespace)[source]¶ 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)[source]¶ 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.
-
fsleyes.render.
createLightBoxCanvas
(namespace, width, height, overlayList, displayCtx, sceneOpts)[source]¶ 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.
-
fsleyes.render.
createOrthoCanvases
(namespace, width, height, overlayList, displayCtx, sceneOpts)[source]¶ 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.
-
fsleyes.render.
create3DCanvas
(namespace, width, height, overlayList, displayCtx, sceneOpts)[source]¶ 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.
-
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
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.
-
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 –
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)[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
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.
-
class
fsleyes.render.
MockSliceCanvas
[source]¶ 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
-
__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)[source]¶ Bases:
object
Used in place of a
CanvasPanel
. This is used as a container forMockSliceCanvas
instances.-
__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)
-