MCPcopy
hub / github.com/mne-tools/mne-python / plot_csd

Function plot_csd

mne/viz/misc.py:1464–1576  ·  view source on GitHub ↗

Plot CSD matrices. A sub-plot is created for each frequency. If an info object is passed to the function, different channel types are plotted in different figures. Parameters ---------- csd : instance of CrossSpectralDensity The CSD matrix to plot. %(info)s

(
    csd, info=None, mode="csd", colorbar=True, cmap=None, n_cols=None, show=True
)

Source from the content-addressed store, hash-verified

1462
1463@fill_doc
1464def plot_csd(
1465 csd, info=None, mode="csd", colorbar=True, cmap=None, n_cols=None, show=True
1466):
1467 """Plot CSD matrices.
1468
1469 A sub-plot is created for each frequency. If an info object is passed to
1470 the function, different channel types are plotted in different figures.
1471
1472 Parameters
1473 ----------
1474 csd : instance of CrossSpectralDensity
1475 The CSD matrix to plot.
1476 %(info)s
1477 Used to split the figure by channel-type, if provided.
1478 By default, the CSD matrix is plotted as a whole.
1479 mode : 'csd' | 'coh'
1480 Whether to plot the cross-spectral density ('csd', the default), or
1481 the coherence ('coh') between the channels.
1482 colorbar : bool
1483 Whether to show a colorbar. Defaults to ``True``.
1484 cmap : str | None
1485 The matplotlib colormap to use. Defaults to None, which means the
1486 colormap will default to matplotlib's default.
1487 n_cols : int | None
1488 CSD matrices are plotted in a grid. This parameter controls how
1489 many matrix to plot side by side before starting a new row. By
1490 default, a number will be chosen to make the grid as square as
1491 possible.
1492 show : bool
1493 Whether to show the figure. Defaults to ``True``.
1494
1495 Returns
1496 -------
1497 fig : list of Figure
1498 The figures created by this function.
1499 """
1500 import matplotlib.pyplot as plt
1501
1502 if mode not in ["csd", "coh"]:
1503 raise ValueError('"mode" should be either "csd" or "coh".')
1504
1505 if info is not None:
1506 indices, titles, units, scalings, ch_types = _get_ch_type_metadata(
1507 info, csd.ch_names
1508 )
1509 else:
1510 indices = [np.arange(len(csd.ch_names))]
1511 units = [""]
1512 scalings = [1]
1513 ch_types = [None]
1514 if mode == "csd":
1515 titles = ["Cross-spectral density"]
1516 elif mode == "coh":
1517 titles = ["Coherence"]
1518
1519 n_freqs = len(csd.frequencies)
1520
1521 if n_cols is None:

Callers 2

test_plot_csdFunction · 0.90
plotMethod · 0.85

Calls 5

_get_ch_type_metadataFunction · 0.85
plt_showFunction · 0.85
sqrtMethod · 0.80
get_dataMethod · 0.45
appendMethod · 0.45

Tested by 1

test_plot_csdFunction · 0.72