cedalion.vis package
Subpackages
- cedalion.vis.anatomy package
- Submodules
- cedalion.vis.anatomy.brain_and_scalp module
- cedalion.vis.anatomy.image_recon module
- cedalion.vis.anatomy.montage module
- cedalion.vis.anatomy.optode_selector module
OptodeSelectorOptodeSelector.surfaceOptodeSelector.pointsOptodeSelector.normalsOptodeSelector.plotterOptodeSelector.labelsOptodeSelector.actorsOptodeSelector.colorOptodeSelector.plot()OptodeSelector.on_pick()OptodeSelector.update_visualization()OptodeSelector.enable_picking()OptodeSelector.plot()OptodeSelector.on_pick()OptodeSelector.update_visualization()OptodeSelector.enable_picking()OptodeSelector.find_surface_normal()OptodeSelector.update_normals()
- cedalion.vis.anatomy.scalp_plot module
- cedalion.vis.anatomy.sensitivity_matrix module
- Module contents
plot_brain_in_axes()plot_brain_and_scalp()image_recon()image_recon_multi_view()image_recon_view()plot_montage3D()OptodeSelectorOptodeSelector.surfaceOptodeSelector.pointsOptodeSelector.normalsOptodeSelector.plotterOptodeSelector.labelsOptodeSelector.actorsOptodeSelector.colorOptodeSelector.plot()OptodeSelector.on_pick()OptodeSelector.update_visualization()OptodeSelector.enable_picking()OptodeSelector.enable_picking()OptodeSelector.find_surface_normal()OptodeSelector.on_pick()OptodeSelector.plot()OptodeSelector.update_normals()OptodeSelector.update_visualization()
scalp_plot()scalp_plot_gif()
- cedalion.vis.misc package
Submodules
cedalion.vis.blocks module
Blocks of plotting functionality to build visualizations.
- cedalion.vis.blocks.plot_stim_markers(
- ax,
- stim: DataFrame,
- fmt: dict[str, dict] | None = None,
- y: float = 0.03,
Add stimulus indicators to an Axes.
For each trial a Rectangle is plotted in x from onset to onset+duration. The height of the rectangle is specified in axes coordinates. In the default setting a small bar at bottom of the axes is drawn. By setting y to 1. the stimulus marker covers the full height of the axes.
- Parameters:
ax – the matplotlib axes to operate on
stim – a stimulas data frame
fmt – for each trial_type a dictioniary of keyword arguments can be provided. These kwargs are passed to matplotlib.patches.Rectangle to format the stimulus indicator.
y – the height of the Rectangle in axes coordinates.
- Initial Contributors:
Eike Middell | middell@tu-berlin.de | 2024
- cedalion.vis.blocks.plot_segments(
- ax,
- segments: list[tuple[float, float]],
- fmt: dict | None = None,
- y: float = 1.0,
- label: str | None = None,
Highlight time segments in line plots.
- cedalion.vis.blocks.plot_surface(
- plotter: pv.Plotter,
- surface: cdc.Surface,
- color: pv.ColorLike | ArrayLike | None = None,
- opacity: float = 1.0,
- pick_landmarks: list[str] | bool = False,
- **kwargs,
Plots a surface mesh with optional landmark picking in a PyVista plotter.
- Parameters:
plotter – A PyVista plotter instance used for rendering the surface.
surface – The surface object to be plotted.
color – Color of the mesh.
opacity – Opacity of the mesh, ranging from 0 (transparent) to 1 (opaque). Default is 1.0.
pick_landmarks – If True, enables interactive picking of landmarks (‘Nz’, ‘Iz’, ‘Cz’, ‘Lpa’, ‘Rpa’) on the surface. If a list of strings is provided, these are used as the landmark labels instead. Default is False.
**kwargs – Additional keyword arguments are passed to pv.add_mesh.
- Returns:
If pick_landmarks is True, returns a function that when called, provides the current picked points and their labels. This function prints warnings if some labels are missing or are repeated.
- Return type:
function
- Initial Contributors:
Eike Middell | middell@tu-berlin.de | 2024
Masha Iudina | mashayudi@gmail.com | 2024
- cedalion.vis.blocks.plot_labeled_points(
- plotter: pv.Plotter,
- points: cdt.LabeledPoints,
- color: pv.ColorLike | None = None,
- show_labels: bool = False,
- ppoints: bool = None,
- labels: list[str] | None = None,
- meas_list: xr.DataArray | None = None,
Plots LabeledPoints with optional interaction for picking points.
This function visualizes a point cloud where each point can have a label. Points can be interactively picked if enabled. Picked point is indicated by increased radius.
- Parameters:
plotter – A PyVista plotter instance used for rendering the points.
points – A labeled point cloud data structure containing points and optional labels.
color – Override color for all points. If None, colors are assigned based on point types.
show_labels – If True, labels are displayed next to the points.
ppoints – A list to store indices of picked points, enables picking if not None.
labels – List of labels to show if show_labels is True. If None and show_labels is True, the labels from points are used.
meas_list – A DataArray containing channel information for plotting channels as lines between sources and detectors.
- Initial Contributors:
Eike Middell | middell@tu-berlin.de | 2024
- cedalion.vis.blocks.plot_vector_field(
- plotter: Plotter,
- points: cdt.LabeledPoints,
- vectors: DataArray,
- ppoints=None,
Plots a vector field on a PyVista plotter.
- Parameters:
plotter (pv.Plotter) – A PyVista plotter instance used for rendering the vector field.
points (cdt.LabeledPoints) – A labeled point cloud data structure containing point coordinates.
vectors (xr.DataArray) – A data array containing the vector field.
ppoints (list, optional) – A list to store indices of picked points, enables picking if not None. Default is None.
- cedalion.vis.blocks.camera_at_cog(
- plt: Plotter,
- surface: Surface,
- rpos: tuple[float, float, float],
- fp_offset: tuple[float, float, float] = (0, 0, 0),
- up: tuple[float, float, float] = (0, 0, 1),
- fit_scene: bool = False,
Point the camera at the center of gravity of the surface vertices.
- Parameters:
plt – the pyvista plotter
surface – the surface from which the COG should be calculated
rpos – positin of the camera relative to the COG
fp_offset – offset from the COG to calculate the focal point
up – direction of upwards.
fit_scene – if True the camera is moved along the position-to-focal-point line to fit all objects in the scene into the view.
cedalion.vis.colors module
Color and colormap definitions.
- cedalion.vis.colors.segmented_cmap(
- name: str,
- vmin: float,
- vmax: float,
- segments: list[tuple[float, tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]],
- over: None | tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] = None,
- under: None | tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] = None,
- bad: None | tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] = None,
Create a linear segmented colormap from (value, color) breakpoints.
- Parameters:
name – Name for the colormap (used by matplotlib internally).
vmin – Data value corresponding to the bottom of the colormap.
vmax – Data value corresponding to the top of the colormap.
segments – List of
(value, color)pairs defining the colour breakpoints. Values are normalised byvmin/vmaxbefore being passed toLinearSegmentedColormap.over – Color for out-of-range values above
vmax(optional).under – Color for out-of-range values below
vmin(optional).bad – Color for masked/NaN values (optional).
- Returns:
Tuple
(norm, cmap)— aNormalizeinstance and the constructedLinearSegmentedColormap.
- cedalion.vis.colors.p_values_cmap() tuple[Normalize, LinearSegmentedColormap][source]
A colormap for log10(p-values).
Gray for p>0.05 and with different colors for common thresholds.
- cedalion.vis.colors.threshold_cmap(
- name,
- vmin,
- vmax,
- threshold,
- higher_is_better=True,
- colors=['#000000', '#DC3220', '#5D3A9B', '#0C7BDC'],
Create a red-and-blue colormap with a sharp break at a quality threshold.
- Parameters:
name – Colormap name.
vmin – Minimum data value.
vmax – Maximum data value.
threshold – Value at which the colour transitions sharply.
higher_is_better – If
True(default), colours below the threshold are “bad” (warm) and colours above are “good” (cool). Reversed whenFalse.colors – Four colours
[vmin, threshold-, threshold+, vmax].
- Returns:
Tuple
(norm, cmap)— aNormalizeand the constructedLinearSegmentedColormap.
- cedalion.vis.colors.mask_cmap(
- true_is_good=True,
- colors=['#DC3220', '#DC3220', '#0C7BDC', '#0C7BDC'],
Create a binary red/blue colormap for boolean quality masks.
- Parameters:
true_is_good – If
True(default),Truevalues are shown in blue (good) andFalsevalues in red (bad). Reversed whenFalse.colors – Four colours defining the two-level step (
[0, 0.5, 0.5, 1]breakpoints).
- Returns:
Tuple
(norm, cmap)— aNormalizefor[0, 1]and the constructedLinearSegmentedColormap.
cedalion.vis.quality module
Tools for visualizing signal quality metrics and masks.
- cedalion.vis.quality.plot_quality_mask(
- mask,
- cb_label: str,
- bool_labels=['TAINTED', 'CLEAN'],
- true_is_good=True,
- figsize=(12, 10),
Plot a boolean quality mask as a colour-coded channel × time heatmap.
- Parameters:
mask – Boolean DataArray with
"channel"and"time"dimensions.cb_label – Label for the colorbar.
bool_labels – Two-element list giving the colorbar tick labels for
FalseandTruevalues respectively (default:["TAINTED", "CLEAN"]).true_is_good – Passed to
mask_cmap(); ifTrue(default),Trueis rendered in blue (good).figsize – Matplotlib figure size tuple.
cedalion.vis.timeseries module
Tools for plotting temporal data.