%load_ext autoreload
%autoreload 2
import logging
# Set logging to only show warnings and errors
logging.getLogger().setLevel(logging.WARNING)
import warnings
# Suppress specific warnings (e.g., RuntimeWarnings)
warnings.filterwarnings('ignore', category=RuntimeWarning)
%config InlineBackend.figure_format = 'svg'Cortical Recording During Behavior
Electrophysiology
Methods
Analysis pipeline for cortical LFP recordings across behavioral contexts.
from neurotools import nlabimport matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns# Create a 20 Hz sinusoidal signal
fs = 200 # Sampling frequency in Hz
t = np.arange(0, 10, 1/fs) # 1 second time vector
freq = 2 # Frequency in Hz
sinusoid = np.sin(2 * np.pi * freq * t)
fig, ax = plt.subplots(figsize=(8, 3))
ax.plot(t, sinusoid)
ax.set_title('20 Hz Sinusoidal Signal')
ax.set_xlabel('Time (s)')
ax.set_ylabel('Amplitude')
ax.grid(True)
nlab.roundx(to=5)
nlab.hsigbar(1.1, 1.5, 0.8,dx=0.1,lw=1,color='red')nlab.stderrplot(sinusoid, 0.1, color='blue', alpha=0.3)
plt.xlim(0, 1000)ax= nlab.yscalebar(0.5, 0.2,'cat',x = 0.2, color='black')
nlab.addspikes(0.2,)
nlab.inhibition_arrow(0.1, 0.1,0.2,0.2, ax=ax, width=1,color='k')
nlab.figurebox(color='red')nlab.boxplot<function matplotlib.pyplot.boxplot(x: 'ArrayLike | Sequence[ArrayLike]', *, notch: 'bool | None' = None, sym: 'str | None' = None, vert: 'bool | None' = None, orientation: "Literal['vertical', 'horizontal']" = 'vertical', whis: 'float | tuple[float, float] | None' = None, positions: 'ArrayLike | None' = None, widths: 'float | ArrayLike | None' = None, patch_artist: 'bool | None' = None, bootstrap: 'int | None' = None, usermedians: 'ArrayLike | None' = None, conf_intervals: 'ArrayLike | None' = None, meanline: 'bool | None' = None, showmeans: 'bool | None' = None, showcaps: 'bool | None' = None, showbox: 'bool | None' = None, showfliers: 'bool | None' = None, boxprops: 'dict[str, Any] | None' = None, tick_labels: 'Sequence[str] | None' = None, flierprops: 'dict[str, Any] | None' = None, medianprops: 'dict[str, Any] | None' = None, meanprops: 'dict[str, Any] | None' = None, capprops: 'dict[str, Any] | None' = None, whiskerprops: 'dict[str, Any] | None' = None, manage_ticks: 'bool' = True, autorange: 'bool' = False, zorder: 'float | None' = None, capwidths: 'float | ArrayLike | None' = None, label: 'Sequence[str] | None' = None, data=None) -> 'dict[str, Any]'>