current_source_density

current_source_density#

class braintools.metric.current_source_density(lfp_laminar, electrode_spacing, conductivity=1.0, axis=-1)#

Compute current source density (CSD) from laminar LFP recordings.

The CSD is the (negative, conductivity-scaled) second spatial derivative of the potential along the electrode axis:

\[\text{CSD}(z) \approx -\sigma\, \frac{\phi(z+h) - 2\phi(z) + \phi(z-h)}{h^2}\]
Parameters:
  • lfp_laminar (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Laminar LFP data. The electrode axis (selected by axis) must be ordered from superficial to deep and have at least 3 electrodes.

  • electrode_spacing (float | Quantity) – Spacing \(h\) between adjacent electrodes. A float is taken to be in mm; a Quantity is converted to mm. The CSD is therefore expressed in [lfp] / mm^2 (scaled by conductivity).

  • conductivity (float) – Tissue conductivity \(\sigma\) (assumed constant).

  • axis (int) – Axis along which electrodes are arranged. Use axis=0 for channels-first (n_electrodes, n_time) data, or the default axis=-1 for (n_time, n_electrodes) data.

Returns:

csd – Current source density with the electrode axis reduced by 2 (the boundary electrodes are dropped).

Return type:

Array

Raises:

ValueError – If fewer than 3 electrodes are present along axis.