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,
)
| 53 | |
| 54 | @verbose |
| 55 | def 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 |