Set up a custom scene using the FSLeyes API via a custom Python script.
The scene consists of two Ortho views, one with a T2w sagittal image and the second with a T2w axial image. For the T2w sagittal image, only the sagittal plane is shown. Similarly, for the T2w axial image, only the axial plane is shown.
Moreover, the display space for the T2w axial image is changed from T2w sagittal to T2w axial to prevent a "zig-zag" artifact due to the tilt of the T2w axial image. Note that the cursor between both images is still synchronized.
$ fsleyes -S -r custom_script.py $SCT_DIR/data/course_london20/single_subject/data/t2/t2.nii.gz $SCT_DIR/data/course_london20/single_subject/data/t2s/t2s.nii.gz
# Show two OrthoPanels next to each other
ortho_left = frame.addViewPanel(OrthoPanel)
ortho_left.defaultLayout()
ortho_right = frame.addViewPanel(OrthoPanel)
ortho_right.defaultLayout()
# Keep only sagittal plane for the ortho_left containing sagittal image
ortho_left.sceneOpts.showYCanvas = False
ortho_left.sceneOpts.showZCanvas = False
# Keep only axial plane for the ortho_right containing axial image
ortho_right.sceneOpts.showXCanvas = False
ortho_right.sceneOpts.showYCanvas = False
# Get list of loaded overlays
# Assuming that you only have two images loaded
t2sag, t2ax = overlayList
# Get Display objects for each image and for each view
t2sag_leftdisplay = ortho_left .displayCtx.getDisplay(t2sag)
t2sag_rightdisplay = ortho_right.displayCtx.getDisplay(t2sag)
t2ax_leftdisplay = ortho_left .displayCtx.getDisplay(t2ax)
t2ax_rightdisplay = ortho_right.displayCtx.getDisplay(t2ax)
# Show t2sag in left, show t2ax in right
t2sag_leftdisplay.enabled = True
t2ax_leftdisplay.enabled = False
t2sag_rightdisplay.enabled = False
t2ax_rightdisplay.enabled = True
# Change display space for the right OrthoPanel to t2ax
ortho_right.displayCtx.displaySpace = t2ax
Note: the settings for each overlay are contained in two objects:
# Display object - general settings (brightness, contrast, opacity, etc)
print(ortho_left.displayCtx)
# DIsplayOpts object - overlay type-specific settings (clipping range, colour map, etc).
print(ortho_left.displayCtx.getOpts(t1))
Credit: Paul McCarthy (University of Oxford)
Useful resources: