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 byaxis) 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; aQuantityis converted to mm. The CSD is therefore expressed in[lfp] / mm^2(scaled byconductivity).conductivity (
float) – Tissue conductivity \(\sigma\) (assumed constant).axis (
int) – Axis along which electrodes are arranged. Useaxis=0for channels-first(n_electrodes, n_time)data, or the defaultaxis=-1for(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.