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

Function compute_current_source_density

mne/preprocessing/_csd.py:55–195  ·  view source on GitHub ↗

Get the current source density (CSD) transformation. Transformation based on spherical spline surface Laplacian :footcite:`PerrinEtAl1987,PerrinEtAl1989,Cohen2014,KayserTenke2015`. This function can be used to re-reference the signal using a Laplacian (LAP) "reference-free" transfo

(
    inst,
    sphere="auto",
    lambda2=1e-5,
    stiffness=4,
    n_legendre_terms=50,
    copy=True,
    *,
    verbose=None,
)

Source from the content-addressed store, hash-verified

53
54@verbose
55def compute_current_source_density(
56 inst,
57 sphere="auto",
58 lambda2=1e-5,
59 stiffness=4,
60 n_legendre_terms=50,
61 copy=True,
62 *,
63 verbose=None,
64):
65 """Get the current source density (CSD) transformation.
66
67 Transformation based on spherical spline surface Laplacian
68 :footcite:`PerrinEtAl1987,PerrinEtAl1989,Cohen2014,KayserTenke2015`.
69
70 This function can be used to re-reference the signal using a Laplacian
71 (LAP) "reference-free" transformation.
72
73 Parameters
74 ----------
75 inst : instance of Raw, Epochs or Evoked
76 The data to be transformed.
77 sphere : array-like, shape (4,) | str
78 The sphere, head-model of the form (x, y, z, r) where x, y, z
79 is the center of the sphere and r is the radius in meters.
80 Can also be "auto" to use a digitization-based fit.
81 lambda2 : float
82 Regularization parameter, produces smoothness. Defaults to 1e-5.
83 stiffness : float
84 Stiffness of the spline.
85 n_legendre_terms : int
86 Number of Legendre terms to evaluate.
87 copy : bool
88 Whether to overwrite instance data or create a copy.
89 %(verbose)s
90
91 Returns
92 -------
93 inst_csd : same type as the input data
94 The transformed data. Output type will match input type.
95
96 Notes
97 -----
98 .. versionadded:: 0.20
99
100 References
101 ----------
102 .. footbibliography::
103 """
104 _validate_type(inst, (BaseEpochs, BaseRaw, Evoked), "inst")
105 _check_preload(inst, "Computing CSD")
106
107 if inst.info["custom_ref_applied"] == FIFF.FIFFV_MNE_CUSTOM_REF_CSD:
108 raise ValueError("CSD already applied, should not be reapplied")
109
110 _validate_type(copy, (bool), "copy")
111 inst = inst.copy() if copy else inst
112

Callers 7

test_csd_matlabFunction · 0.90
test_csd_degenerateFunction · 0.90
test_csd_fifFunction · 0.90
test_csd_epochsFunction · 0.90
test_pick_types_csdFunction · 0.90

Calls 13

_validate_typeFunction · 0.85
_check_preloadFunction · 0.85
pick_typesFunction · 0.85
_ensure_intFunction · 0.85
fit_sphere_to_headshapeFunction · 0.85
_calc_gFunction · 0.85
_calc_hFunction · 0.85
_prepare_GFunction · 0.85
_compute_csdFunction · 0.85
normMethod · 0.80
_unlockMethod · 0.80
copyMethod · 0.45

Tested by 7

test_csd_matlabFunction · 0.72
test_csd_degenerateFunction · 0.72
test_csd_fifFunction · 0.72
test_csd_epochsFunction · 0.72
test_pick_types_csdFunction · 0.72