VolumePlot: Whole-brain contacts
Use VolumePlot to see contacts in the context of the whole brain. Here,
translucent fsaverage pial surfaces provide the anatomical background.
1. Draw the background
Fetch both hemispheres to build the translucent background. VolumePlot
draws these surfaces, rather than image voxels.
from anatplot import VolumePlot, datasets
surfaces = datasets.fetch_surfaces(
template="fsaverage",
surface="pial",
density="10k",
)
plot = VolumePlot(
left=surfaces["left"],
right=surfaces["right"],
)
fig = plot.to_figure()
2. Add contacts
Next, add contacts on both sides of the brain, using red and blue to distinguish the two groups.
# Coordinates in the fsaverage surface's RAS millimetre frame.
xyz = [
[-28, -18, -12],
[-28, -22, -12],
[-28, -26, -12],
[28, -18, -12],
[28, -22, -12],
[28, -26, -12],
]
plot.add_contacts(
xyz,
radius=2.0,
color=["crimson", "crimson", "crimson", "royalblue", "royalblue", "royalblue"],
)
fig = plot.to_figure()
VolumePlot keeps the supplied coordinates rather than projecting them onto
the surface. If contacts lie outside the view, call
plot.plotter.reset_camera() before to_figure() to fit the whole scene.
3. Save and share
Finally, save the contact figure as a PNG and export the scene as interactive HTML.
fig.savefig("brain.png", dpi=300)
plot.export_html("brain.html")
plot.close()