809 lines
210 KiB
Plaintext
809 lines
210 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"%load_ext autoreload\n",
|
||
|
"%autoreload 2"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"16:15:36 [I] klustakwik KlustaKwik2 version 0.2.6\n",
|
||
|
"/home/mikkel/.virtualenvs/expipe/lib/python3.6/site-packages/ipykernel_launcher.py:25: TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0\n",
|
||
|
"Please use `tqdm.notebook.*` instead of `tqdm._tqdm_notebook.*`\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"%matplotlib inline\n",
|
||
|
"import spatial_maps as sp\n",
|
||
|
"import septum_mec.analysis.data_processing as dp\n",
|
||
|
"import septum_mec.analysis.registration\n",
|
||
|
"import expipe\n",
|
||
|
"import os\n",
|
||
|
"import pathlib\n",
|
||
|
"import scipy\n",
|
||
|
"import scipy.signal\n",
|
||
|
"import numpy as np\n",
|
||
|
"import exdir\n",
|
||
|
"import pandas as pd\n",
|
||
|
"import optogenetics as og\n",
|
||
|
"import quantities as pq\n",
|
||
|
"import shutil\n",
|
||
|
"from distutils.dir_util import copy_tree\n",
|
||
|
"import elephant as el\n",
|
||
|
"import neo\n",
|
||
|
"from scipy.signal import find_peaks\n",
|
||
|
"from scipy.interpolate import interp1d\n",
|
||
|
"from matplotlib import mlab\n",
|
||
|
"\n",
|
||
|
"from tqdm import tqdm_notebook as tqdm\n",
|
||
|
"from tqdm._tqdm_notebook import tqdm_notebook\n",
|
||
|
"tqdm_notebook.pandas()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"data_loader = dp.Data()\n",
|
||
|
"actions = data_loader.actions\n",
|
||
|
"project = data_loader.project"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"output = pathlib.Path('output/stimulus-spike-lfp-response-reduced-transient-cut')\n",
|
||
|
"(output / 'data').mkdir(parents=True, exist_ok=True)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"identify_neurons = actions['identify-neurons']\n",
|
||
|
"# sessions = pd.read_csv(identify_neurons.data_path('sessions'))\n",
|
||
|
"units = pd.read_csv(identify_neurons.data_path('units'))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def get_lim(action_id):\n",
|
||
|
" stim_times = data_loader.stim_times(action_id)\n",
|
||
|
" if stim_times is None:\n",
|
||
|
" return [0, np.inf]\n",
|
||
|
" stim_times = np.array(stim_times)\n",
|
||
|
" return [stim_times.min(), stim_times.max()]\n",
|
||
|
"\n",
|
||
|
"def get_mask(lfp, lim):\n",
|
||
|
" return (lfp.times >= lim[0]) & (lfp.times <= lim[1])\n",
|
||
|
"\n",
|
||
|
"def zscore(a):\n",
|
||
|
" return (a - a.mean(0)) / a.std(0)\n",
|
||
|
"\n",
|
||
|
"def compute_stim_freq(action_id):\n",
|
||
|
" stim_times = data_loader.stim_times(action_id)\n",
|
||
|
" if stim_times is None:\n",
|
||
|
" return np.nan\n",
|
||
|
" stim_times = np.array(stim_times)\n",
|
||
|
" return 1 / np.mean(np.diff(stim_times))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def signaltonoise(a, axis=0, ddof=0):\n",
|
||
|
" a = np.asanyarray(a)\n",
|
||
|
" m = a.mean(axis)\n",
|
||
|
" sd = a.std(axis=axis, ddof=ddof)\n",
|
||
|
" return np.where(sd == 0, 0, m / sd)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def compute_energy(p, f, f1, f2):\n",
|
||
|
" if np.isnan(f1) or np.all(np.isnan(p)):\n",
|
||
|
" return np.nan\n",
|
||
|
" mask = (f > f1) & (f < f2)\n",
|
||
|
" df = f[1] - f[0]\n",
|
||
|
" return np.sum(p[mask]) * df"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def find_theta_peak(p, f, f1, f2):\n",
|
||
|
" if np.all(np.isnan(p)):\n",
|
||
|
" return np.nan, np.nan\n",
|
||
|
" mask = (f > f1) & (f < f2)\n",
|
||
|
" p_m = p[mask]\n",
|
||
|
" f_m = f[mask]\n",
|
||
|
" peaks, _ = find_peaks(p_m)\n",
|
||
|
" idx = np.argmax(p_m[peaks])\n",
|
||
|
" return f_m[peaks[idx]], p_m[peaks[idx]]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def compute_half_width(p, f, m_p, m_f):\n",
|
||
|
" if np.isnan(m_p):\n",
|
||
|
" return np.nan, np.nan\n",
|
||
|
" m_p_half = m_p / 2\n",
|
||
|
" half_p = p - m_p_half\n",
|
||
|
" idx_f = np.where(f <= m_f)[0].max()\n",
|
||
|
" idxs_p1, = np.where(np.diff(half_p[:idx_f + 1] > 0) == 1)\n",
|
||
|
" if len(idxs_p1) == 0:\n",
|
||
|
" return np.nan, np.nan\n",
|
||
|
" m1 = idxs_p1.max()\n",
|
||
|
" idxs_p2, = np.where(np.diff(half_p[idx_f:] > 0) == 1)\n",
|
||
|
" m2 = idxs_p2.min() + idx_f\n",
|
||
|
" assert p[m1] < m_p_half < p[m1+1], (p[m1], m_p_half, p[m1+1])\n",
|
||
|
" assert p[m2] > m_p_half > p[m2+1], (p[m2], m_p_half, p[m2+1])\n",
|
||
|
" \n",
|
||
|
" f1 = interp1d([half_p[m1], half_p[m1 + 1]], [f[m1], f[m1 + 1]])(0)\n",
|
||
|
" f2 = interp1d([half_p[m2], half_p[m2 + 1]], [f[m2], f[m2 + 1]])(0)\n",
|
||
|
" return f1, f2"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# p = np.load('debug_p.npy')\n",
|
||
|
"# f = np.load('debug_f.npy')\n",
|
||
|
"# compute_half_width(p, f, 0.01038941, 30.30187709636872)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# plt.plot(f, p)\n",
|
||
|
"# plt.xlim(29.9,30.6)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def compute_stim_peak(p, f, s_f):\n",
|
||
|
" if np.isnan(s_f):\n",
|
||
|
" return np.nan\n",
|
||
|
" return interp1d(f, p)(s_f)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def compute_spike_lfp_coherence(anas, sptr, NFFT):\n",
|
||
|
"\n",
|
||
|
" sigs, freqs = el.sta.spike_field_coherence(anas, sptr, **{'nperseg': NFFT})\n",
|
||
|
" return sigs, freqs"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def butter_bandpass(lowcut, highcut, fs, order=5):\n",
|
||
|
" nyq = 0.5 * fs\n",
|
||
|
" low = lowcut / nyq\n",
|
||
|
" high = highcut / nyq\n",
|
||
|
" b, a = scipy.signal.butter(order, [low, high], btype='band')\n",
|
||
|
" return b, a\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"def butter_bandpass_filter(data, lowcut, highcut, fs, order=5):\n",
|
||
|
" b, a = butter_bandpass(lowcut, highcut, fs, order=order)\n",
|
||
|
" y = scipy.signal.filtfilt(b, a, data)\n",
|
||
|
" return y\n",
|
||
|
"\n",
|
||
|
"# def compute_spike_phase_func(lfp, times, return_degrees=False):\n",
|
||
|
"# x_a = hilbert(lfp)\n",
|
||
|
"# x_phase = np.angle(x_a)\n",
|
||
|
"# if return_degrees:\n",
|
||
|
"# x_phase = x_phase * 180 / np.pi\n",
|
||
|
"# return interp1d(times, x_phase)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"def vonmises_kde(data, kappa=100, n_bins=100):\n",
|
||
|
" from scipy.special import i0\n",
|
||
|
" bins = np.linspace(-np.pi, np.pi, n_bins)\n",
|
||
|
" x = np.linspace(-np.pi, np.pi, n_bins)\n",
|
||
|
" # integrate vonmises kernels\n",
|
||
|
" kde = np.exp(kappa * np.cos(x[:, None] - data[None, :])).sum(1) / (2 * np.pi * i0(kappa))\n",
|
||
|
" kde /= np.trapz(kde, x=bins)\n",
|
||
|
" return bins, kde\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"def spike_phase_score(phase_bins, density):\n",
|
||
|
" import math\n",
|
||
|
" import pycircstat as pc\n",
|
||
|
" ang = pc.mean(phase_bins, w=density)\n",
|
||
|
" vec_len = pc.resultant_vector_length(phase_bins, w=density)\n",
|
||
|
" # ci_lim = pc.mean_ci_limits(head_angle_bins, w=rate)\n",
|
||
|
" return ang, vec_len"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def compute_clean_lfp(anas, width=50, threshold=2):\n",
|
||
|
" anas = np.array(anas)\n",
|
||
|
" idxs, = np.where(abs(anas) > threshold)\n",
|
||
|
" for idx in idxs:\n",
|
||
|
" anas[idx-width:idx+width] = 0 # TODO AR model prediction\n",
|
||
|
" percentage_removed = len(idxs) * width * 2 / len(anas)\n",
|
||
|
" return anas, idxs, percentage_removed\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"def compute_clean_spikes(spikes, idxs, times, width=50):\n",
|
||
|
"\n",
|
||
|
" for idx in idxs:\n",
|
||
|
" t0 = times[idx-width]\n",
|
||
|
" stop = idx + width\n",
|
||
|
" if stop > len(times) - 1:\n",
|
||
|
" stop = len(times) - 1 \n",
|
||
|
" t1 = times[stop]\n",
|
||
|
" mask = (spikes > t0) & (spikes < t1)\n",
|
||
|
" spikes = spikes[~mask]\n",
|
||
|
" spikes = spikes[spikes <= times[-1]]\n",
|
||
|
" return spikes\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"def prepare_spike_lfp(anas, sptr, t_start, t_stop):\n",
|
||
|
"\n",
|
||
|
" t_start = t_start * pq.s if t_start is not None else 0 * pq.s\n",
|
||
|
" sampling_rate = anas.sampling_rate\n",
|
||
|
" units = anas.units\n",
|
||
|
" times = anas.times\n",
|
||
|
" if t_start is not None and t_stop is not None:\n",
|
||
|
" t_stop = t_stop * pq.s\n",
|
||
|
" mask = (times > t_start) & (times < t_stop)\n",
|
||
|
" anas = np.array(anas)[mask,:]\n",
|
||
|
" times = times[mask]\n",
|
||
|
" \n",
|
||
|
" # take best channel from other drive\n",
|
||
|
" best_channel = np.argmax(signaltonoise(anas))\n",
|
||
|
"# best_channel = np.random.choice(anas.shape[1])\n",
|
||
|
" \n",
|
||
|
" cleaned_anas, idxs, percentage_removed = compute_clean_lfp(anas[:, best_channel])\n",
|
||
|
" cleaned_anas = neo.AnalogSignal(\n",
|
||
|
" signal=cleaned_anas * units, sampling_rate=sampling_rate, t_start=t_start\n",
|
||
|
" )\n",
|
||
|
" \n",
|
||
|
" spike_units = sptr.units\n",
|
||
|
" spike_times = sptr.times\n",
|
||
|
" spike_times = compute_clean_spikes(spike_times, idxs, times)\n",
|
||
|
"\n",
|
||
|
" sptr = neo.SpikeTrain(\n",
|
||
|
" spike_times[(spike_times > t_start) & (spike_times < times[-1])], units=spike_units,\n",
|
||
|
" t_start=t_start, t_stop=times[-1]\n",
|
||
|
" )\n",
|
||
|
"\n",
|
||
|
" return cleaned_anas, sptr, best_channel, percentage_removed"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def compute_spike_phase_func(lfp, times, return_degrees=False):\n",
|
||
|
" from scipy.fftpack import next_fast_len\n",
|
||
|
" x_a = scipy.signal.hilbert(\n",
|
||
|
" lfp, next_fast_len(len(lfp)))[:len(lfp)]\n",
|
||
|
"# x_a = hilbert(lfp)\n",
|
||
|
" x_phase = np.angle(x_a, deg=return_degrees)\n",
|
||
|
" return interp1d(times, x_phase)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"def compute_spike_phase(lfp, spikes, flim=[6,10]):\n",
|
||
|
" \n",
|
||
|
" sample_rate = lfp.sampling_rate.magnitude\n",
|
||
|
" \n",
|
||
|
" # sometimes the position is recorded after LFP recording is ended\n",
|
||
|
" times = np.arange(lfp.shape[0]) / sample_rate\n",
|
||
|
" \n",
|
||
|
" spikes = np.array(spikes)\n",
|
||
|
" spikes = spikes[(spikes > times.min()) & (spikes < times.max())]\n",
|
||
|
" \n",
|
||
|
" filtered_lfp = butter_bandpass_filter(\n",
|
||
|
" lfp.magnitude.ravel(), *flim, fs=sample_rate, order=3)\n",
|
||
|
"\n",
|
||
|
" spike_phase_func = compute_spike_phase_func(filtered_lfp, times)\n",
|
||
|
" \n",
|
||
|
" return spike_phase_func(spikes), filtered_lfp"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 18,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"(0, 100)"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 18,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA6AAAAIHCAYAAACBqzFTAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOzdZ2Bb5fn38Z88shNnJ2SHDIfsbbtQ4E8pdPDQUqClLWWXsqEUCqUMszel7D3SsDdlhhIgJHhkOluJM5zhOIkznHgP6XkhS9Y4ko62bH8/L8CWzrgj65xzX/e4bovdbhcAAAAAALGWkugCAAAAAADaBwJQAAAAAEBcEIACAAAAAOKCABQAAAAAEBcEoAAAAACAuCAABQAAAADERVq8TpSVlWUfPHhwvE4HAAAAAIiTXr16aeHChV9ardafBdoubgHo4MGD9f7778frdAAAAACAOMrMzOwbbBuG4AIAAAAA4oIAFAAAAAAQ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SIABQAAiBGGugKAJwJQAAAAAG0SibeSDwEoACAidp7ubRJ/1+TGXwcIjVF2XG5ziUEACgAwZDaVPc9vwD+WhAAATwSgAAAAAIC4IAAFAAQV7qL3AAAA7ghAAQAAWhnmrgForQhAAQAA2gniVrQXzpE7fOeTDwEoAABAK1Pf1BTR/iRHQttl/OXmK5880sLZKTMzM13SS5JGSOoo6S6r1fpxFMsFAGglGAoIxF9FTUOiiwC0CiwplXzC7QE9W9I+q9X6Y0k/k/RE9IoEAAAAANF
|
||
|
"text/plain": [
|
||
|
"<Figure size 1152x648 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA74AAAIUCAYAAAA9jvA9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOzdd5wcd334/9fMbLm9vd7UTl3ySbLlhivGBmOMcQg4gQAJEFqAFAIBEn/z45tAQgmJIYCTkFC+pveODSbuNnJHslwkSzpJp3pF12/vbm/blN8fn5nZXeksnaSTPqfV+/l46LGzs21Ws7s373m/P++P4XkeQgghhBBCCCFEpTJ1b4AQQgghhBBCCHEqSeArhBBCCCGEEKKiSeArhBBCCCGEEKKiSeArhBBCCCGEEKKiSeArhBBCCCGEEKKiSeArhBBCCCGEEKKiRXRvwGy59NJLvcWLF+veDCFOSj6fJxaL6d4MIU6afJZFpZDPsqgE8jkWleL5558f6uzsbD2Rx1ZM4Nva2srPf/5z3ZshxEnZvn07a9eu1b0ZQpw0+SyLSiGfZVEJ5HMsKkVHR8f+E32slDoLIYQQQgghhKhoEvgKIYQQQgghhKhoEvgKIYQQQgghh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l9/xyWsnld75KMNgzXz64hFyv9LGqtVgBuULwdjfBuTMVKZAiPpPFN5h4X1CQzD4BM3nYvteHzrsX3hPL/NNTEMw2BhQ4LesQyP7h6itirCB65bTbbgsr2vMkqDswWXqOFQRZ5swdW9OULMGfXffRWvvf9lujdDCCGEEOKsVTGBr2f643RzEwxMqAZXpaXO8YjFV992CS9
|
||
|
"text/plain": [
|
||
|
"<Figure size 1152x648 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"plt.figure(figsize=(16,9))\n",
|
||
|
"lfp = data_loader.lfp('1833-200619-2', 6)\n",
|
||
|
"# lfp = data_loader.lfp('1834-220319-3', 6)\n",
|
||
|
"# lfp = data_loader.lfp('1849-010319-4', 6)\n",
|
||
|
"times = np.arange(lfp.shape[0]) / lfp.sampling_rate.magnitude\n",
|
||
|
"clean_lfp, _, _ = compute_clean_lfp(lfp.magnitude[:, 0], threshold=2)\n",
|
||
|
"plt.plot(times,lfp[:,0])\n",
|
||
|
"plt.plot(times,clean_lfp)\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(16,9))\n",
|
||
|
"plt.psd(lfp[:,0].ravel(), Fs=1000, NFFT=10000)\n",
|
||
|
"plt.psd(clean_lfp, Fs=1000, NFFT=10000)\n",
|
||
|
"plt.xlim(0,100)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# plt.figure(figsize=(16,9))\n",
|
||
|
"\n",
|
||
|
"# plt.plot(times,lfp[:,0])\n",
|
||
|
"# # plt.plot(clean_lfp*100)\n",
|
||
|
"# plt.plot(times[:-1], np.diff(lfp[:,0].magnitude.ravel()))\n",
|
||
|
"# plt.xlim(64.5,65.5)\n",
|
||
|
"# # plt.ylim(-250,250)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 20,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7fd29009a710>]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 20,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAD3CAYAAAD7VehMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO3dd3hUZfrw8e+UZNILhBJ6fwClCQpIERVWigWxrhVdrOuuZX+uuqvvdnUL9rWsZS1YUbCCrgWQKtJB4IFQEwiQ3pOp7x9nJgwhIZPJZDJJ7s915UrmtHnm5My5z9NNHo8HIYQQbZO5uRMghBCi+UgQEEKINkyCgBBCtGESBIQQog2TICCEEG2YtbkT4DN69GhP165dmzsZQgjRYvz000+5WusOjTlGxASBrl27smDBguZOhhBCtBhKqQONPUa9QUApZQaeB4YBVcAcrXWG3/pfArMBD/AvrfUHSikTkAXs9m62Wmv9UGMTK4QQIrQCyQnMBGK01mOVUmOAucAlAEqpNOAOYAQQA2xXSs0H+gIbtNYXNU2yhRBChEIgFcPjgS8BtNZrgFG+FVrrXGC41toBdAYqtdYeYCTQVSm1RCm1SCmlQp90IYQQjRVIEEgCivxeu5RS1TkIrbVTKXUXsAaY512cDTymtT4XeNRvuRBCiAgSSBAoBhL999FaO/030Fo/B6QDE5VS5wLrgE+861YAXbz1BEIIISJIIEFgJTAdwFsnsNW3QhkWeG/wDoyKYzfwB+Ae7zbDgExvMZEQQogIEkjF8EJgilJq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
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAARIAAAEMCAYAAAAI6znIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nOydd3xT9frHP0m6m66kKy1tKSOHPQoKLVMREBwsBRTwulBQ4V4UERUVxcFyXpwo4LhOVFSGcrmggj9QkSF2pCPdO23TZo9znt8fIbGFjuScdKB5v17fFzTN+Z4nzTnP+X6fKSIi+PDhw4cQxN0tgA8fPi59fIrEhw8fgvEpEh8+fAjGp0h8+PAhGJ8i8eHDh2B8isSHDx+C8etuAXz0PBiGCQSwE0AfAE0A7gUgB/AyADuAgyqV6kmGYSIAvH/+sCUqlaqxO+T10f34FImP1lgKQK9SqcYyDMMA2AYgDsA8AGoA+xiGGQmgL4AtcKxsrwLweTfJ66Ob8W1tfLTGIAAHAEClUqkAXAYgUKVSFahUKgLwHRyK478AVgO4H8ChbpLVRw/AtyLx0RpnAFzLMMweAGMARAAoaPZ7HYA+57cys7pBPh89DN+KxEdr7IDDNnIUwBwAZwGENvt9GABtN8jlo4fiUyQ+WuMyAP9TqVTjAXwGIBeAlWGYvgzDiABMh0PJ+PABABD5kvZ8XAjDMNEAPoZjFaIFcAeAZAAvAZDA4bV5tPsk9NHT8CkSHz58CMa3tfHhw4dgfIrEhw8fgvEpEh8+fAjGp0h8+PAhGJ8i8eHDh2B8isSHDx+C8SkSHz58CManSHz48CEYnyLx4cOHYHzZvz4AAAzDBACIB6AAoPDz8+sVEhIiF4vFAWKxOEAikQSIRCJ/ABIishGRjeM4C8uyVrvdbjYYDO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faoj2vDRHBbre7FJNzWCwWWCwWEBECAwMRHByMkJAQhISEICAgQPBn9CaNjY149NFHtadOnfq1rq5ukUqlqu1umS4JuntJdCkPpVIZnp6e/uktt9xSX11dTUJ56aWXCABt3LiR9xwsy5JWq6WysjJSqVSUmZlJarWaqqqqqKmpiRy1hojsdjt98MEHxDAMASClUknr1q2jM2fOtLtdEWIj4TiOzGYz1dfXU1lZGeXm5lJmZiYVFBRQdXU1GY3GHrNVOnTokH38+PHVw4cPX0g94Frr6eOSXJEwDDMGwCaVSjWZYZhBAN4CIAKQB+BOlUplZxjmZQDjAejOHzYLQB8ALwI4o1Kp/iVEhsGDB0+LjIzc+eCDD8bMmjWL9yrEyeHDhzF9+nRce+21+OKLL9zeBhARzGYzGhsb0dTUBJZlIZVKERYWhtDQUPj7+7d7PMuy+PTTT7F9+3b88MMP4DgOffv2xbx583DDDTfgwkhbb8eROOXX6/XQ6XQwm80IDg5GREQEwsPD4efXfdVAtVot1q1bpz116tQv51cnXgu5ZxgmFsBvAKYCCAawF47rFwBeB/A5gF0A4uC4pou9de7O4JJTJAzDrAGwBIBBpVKNZRhmD4AXVCrVjwzD7ALwlUql+pJhmGMAZjf/8hmGeQ7ABgAPAtimUqnqeJw/XC6Xv9WvX7+pW7dulcXGxgr+TD/88ANmzpyJPn364NixY4iIiGj3/UQEg8GAhoYG6HQ6BAYGIjIyEuHh4R0qjvaoqanBV199hd27d+Pw4cOw2+0YMGAA1q1bh4ULF0IikXR6QBoRwWg0oqmpCY2NjRCLxYiMjERUVJSgzyaEQ4cOsU8++aSmqalp5dmzZz8VOh/DMP4APgUwGMD1cDzwIlQq1fPN3jMawEAAPwK4ofnveiKXoiKZB+B3AO+fVyQSlUrFni9e/DWAzQC+h6M
|
||
|
"text/plain": [
|
||
|
"<Figure size 432x288 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {
|
||
|
"needs_background": "light"
|
||
|
},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# action_id_0, channel_0, unit_0 = '1833-200619-1', 6, 163\n",
|
||
|
"# action_id_1, channel_1, unit_1 = '1833-200619-2', 6, 28\n",
|
||
|
"action_id_0, channel_0, unit_0 = '1834-220319-3', 2, 46\n",
|
||
|
"action_id_1, channel_1, unit_1 = '1834-220319-4', 2, 60\n",
|
||
|
"\n",
|
||
|
"# change data loader to get all LFPs and then selecte the best form the other\n",
|
||
|
"lfp_0 = data_loader.lfp(action_id_0, channel_0)\n",
|
||
|
"lfp_1 = data_loader.lfp(action_id_1, channel_1)\n",
|
||
|
"\n",
|
||
|
"sample_rate_0 = lfp_0.sampling_rate\n",
|
||
|
"sample_rate_1 = lfp_1.sampling_rate\n",
|
||
|
"\n",
|
||
|
"lim_0 = get_lim(action_id_0)\n",
|
||
|
"lim_1 = get_lim(action_id_1)\n",
|
||
|
"\n",
|
||
|
"sptrs_0 = data_loader.spike_trains(action_id_0, channel_0)\n",
|
||
|
"\n",
|
||
|
"sptrs_1 = data_loader.spike_trains(action_id_1, channel_1)\n",
|
||
|
"\n",
|
||
|
"cleaned_lfps_0, sptr_0, best_channel_0, percentage_removed_0 = prepare_spike_lfp(lfp_0, sptrs_0[unit_0], *lim_0)\n",
|
||
|
"\n",
|
||
|
"cleaned_lfps_1, sptr_1, best_channel_1, percentage_removed_1 = prepare_spike_lfp(lfp_1, sptrs_1[unit_1], *lim_1)\n",
|
||
|
"\n",
|
||
|
"coher_0, freq_0 = compute_spike_lfp_coherence(cleaned_lfps_0, sptr_0, 4096)\n",
|
||
|
"\n",
|
||
|
"coher_1, freq_1 = compute_spike_lfp_coherence(cleaned_lfps_1, sptr_1, 4096)\n",
|
||
|
"\n",
|
||
|
"spike_phase_0, filtered_lfp_0 = compute_spike_phase(cleaned_lfps_0, sptrs_0[unit_0], flim=[6,10])\n",
|
||
|
"\n",
|
||
|
"spike_phase_1, filtered_lfp_1 = compute_spike_phase(cleaned_lfps_1, sptrs_1[unit_1], flim=[6,10])\n",
|
||
|
"\n",
|
||
|
"# spike_phase_1_stim, filtered_lfp_1_stim = compute_spike_phase(cleaned_lfps_1, sptrs_1[unit_1], flim=[10.5,11.5])\n",
|
||
|
"spike_phase_1_stim, filtered_lfp_1_stim = compute_spike_phase(cleaned_lfps_1, sptrs_1[unit_1], flim=[29.5,30.5])\n",
|
||
|
"\n",
|
||
|
"plt.figure()\n",
|
||
|
"plt.plot(freq_0, coher_0.ravel())\n",
|
||
|
"plt.plot(freq_1, coher_1.ravel())\n",
|
||
|
"plt.xlim(0,20)\n",
|
||
|
"\n",
|
||
|
"plt.figure()\n",
|
||
|
"bins_0, kde_0 = vonmises_kde(spike_phase_0, 100)\n",
|
||
|
"ang_0, vec_len_0 = spike_phase_score(bins_0, kde_0)\n",
|
||
|
"plt.polar(bins_0, kde_0, color='b')\n",
|
||
|
"plt.polar([ang_0, ang_0], [0, vec_len_0], color='b')\n",
|
||
|
"\n",
|
||
|
"bins_1, kde_1 = vonmises_kde(spike_phase_1, 100)\n",
|
||
|
"ang_1, vec_len_1 = spike_phase_score(bins_1, kde_1)\n",
|
||
|
"plt.polar(bins_1, kde_1, color='r')\n",
|
||
|
"plt.polar([ang_1, ang_1], [0, vec_len_1], color='r')\n",
|
||
|
"\n",
|
||
|
"bins_1_stim, kde_1_stim = vonmises_kde(spike_phase_1_stim, 100)\n",
|
||
|
"ang_1_stim, vec_len_1_stim = spike_phase_score(bins_1_stim, kde_1_stim)\n",
|
||
|
"plt.polar(bins_1_stim, kde_1_stim, color='k')\n",
|
||
|
"plt.polar([ang_1_stim, ang_1_stim], [0, vec_len_1_stim], color='k')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 21,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"0.0"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 21,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"percentage_removed_1"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 22,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# TODO fix artefact stuff from phase precession"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 23,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"NFFT = 8192\n",
|
||
|
"theta_band_f1, theta_band_f2 = 6, 10 "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 24,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"coherence_data, freqency_data = {}, {}\n",
|
||
|
"theta_kde_data, theta_bins_data = {}, {}\n",
|
||
|
"stim_kde_data, stim_bins_data = {}, {}\n",
|
||
|
"\n",
|
||
|
"def process(row):\n",
|
||
|
" action_id = row['action']\n",
|
||
|
" channel_group = row['channel_group']\n",
|
||
|
" unit_name = row['unit_name']\n",
|
||
|
" \n",
|
||
|
" name = f'{action_id}_{channel_group}_{unit_name}'\n",
|
||
|
" \n",
|
||
|
" # select \n",
|
||
|
" lfp = data_loader.lfp(action_id, channel_group) # TODO consider choosing strongest stim response\n",
|
||
|
" \n",
|
||
|
" sptr = data_loader.spike_train(action_id, channel_group, unit_name)\n",
|
||
|
" \n",
|
||
|
" lim = get_lim(action_id)\n",
|
||
|
" \n",
|
||
|
" cleaned_lfp, sptr, best_channel, percentage_removed = prepare_spike_lfp(lfp, sptr, *lim)\n",
|
||
|
" \n",
|
||
|
" p_xys, freq = compute_spike_lfp_coherence(cleaned_lfp, sptr, NFFT=NFFT)\n",
|
||
|
" \n",
|
||
|
" p_xy = p_xys.magnitude.ravel()\n",
|
||
|
" freq = freq.magnitude\n",
|
||
|
" \n",
|
||
|
" theta_f, theta_p_max = find_theta_peak(p_xy, freq, theta_band_f1, theta_band_f2)\n",
|
||
|
" \n",
|
||
|
" theta_energy = compute_energy(p_xy, freq, theta_band_f1, theta_band_f2) # theta band 6 - 10 Hz\n",
|
||
|
" \n",
|
||
|
" theta_half_f1, theta_half_f2 = compute_half_width(p_xy, freq, theta_p_max, theta_f)\n",
|
||
|
" \n",
|
||
|
" theta_half_width = theta_half_f2 - theta_half_f1\n",
|
||
|
" \n",
|
||
|
" theta_half_energy = compute_energy(p_xy, freq, theta_half_f1, theta_half_f2) # theta band 6 - 10 Hz\n",
|
||
|
" \n",
|
||
|
" theta_spike_phase, _ = compute_spike_phase(cleaned_lfp, sptr, flim=[theta_band_f1, theta_band_f2])\n",
|
||
|
" theta_bins, theta_kde = vonmises_kde(theta_spike_phase)\n",
|
||
|
" theta_ang, theta_vec_len = spike_phase_score(theta_bins, theta_kde)\n",
|
||
|
" theta_kde_data.update({name: theta_kde})\n",
|
||
|
" theta_bins_data.update({name: theta_bins})\n",
|
||
|
"\n",
|
||
|
" # stim\n",
|
||
|
" \n",
|
||
|
" stim_freq = compute_stim_freq(action_id)\n",
|
||
|
" \n",
|
||
|
" stim_p_max = compute_stim_peak(p_xy, freq, stim_freq)\n",
|
||
|
" \n",
|
||
|
" stim_half_f1, stim_half_f2 = compute_half_width(p_xy, freq, stim_p_max, stim_freq)\n",
|
||
|
" stim_half_width = stim_half_f2 - stim_half_f1\n",
|
||
|
" \n",
|
||
|
" stim_energy = compute_energy(p_xy, freq, stim_half_f1, stim_half_f2)\n",
|
||
|
" \n",
|
||
|
" if np.isnan(stim_freq):\n",
|
||
|
" stim_spike_phase, stim_bins, stim_kde, stim_ang, stim_vec_len = [np.nan] * 5\n",
|
||
|
" else:\n",
|
||
|
" stim_spike_phase, _ = compute_spike_phase(cleaned_lfp, sptr, flim=[stim_freq - .5, stim_freq + .5])\n",
|
||
|
" stim_bins, stim_kde = vonmises_kde(stim_spike_phase)\n",
|
||
|
" stim_ang, stim_vec_len = spike_phase_score(stim_bins, stim_kde)\n",
|
||
|
" stim_kde_data.update({name: stim_kde})\n",
|
||
|
" stim_bins_data.update({name: stim_bins})\n",
|
||
|
" \n",
|
||
|
" coherence_data.update({name: p_xy})\n",
|
||
|
" freqency_data.update({name: freq})\n",
|
||
|
" \n",
|
||
|
" result = pd.Series({\n",
|
||
|
" 'percentage_removed': percentage_removed,\n",
|
||
|
" 'best_channel': best_channel,\n",
|
||
|
" 'theta_freq': theta_f,\n",
|
||
|
" 'theta_peak': theta_p_max,\n",
|
||
|
" 'theta_energy': theta_energy,\n",
|
||
|
" 'theta_half_f1': theta_half_f1, \n",
|
||
|
" 'theta_half_f2': theta_half_f2,\n",
|
||
|
" 'theta_half_width': theta_half_width,\n",
|
||
|
" 'theta_half_energy': theta_half_energy,\n",
|
||
|
" 'theta_ang': theta_ang, \n",
|
||
|
" 'theta_vec_len': theta_vec_len,\n",
|
||
|
" 'stim_freq': stim_freq,\n",
|
||
|
" 'stim_p_max': stim_p_max,\n",
|
||
|
" 'stim_half_f1': stim_half_f1, \n",
|
||
|
" 'stim_half_f2': stim_half_f2,\n",
|
||
|
" 'stim_half_width': stim_half_width,\n",
|
||
|
" 'stim_energy': stim_energy,\n",
|
||
|
" 'stim_ang': stim_ang, \n",
|
||
|
" 'stim_vec_len': stim_vec_len\n",
|
||
|
" })\n",
|
||
|
" return result"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"application/vnd.jupyter.widget-view+json": {
|
||
|
"model_id": "6dfdc93cb0b546f28867b3134d582205",
|
||
|
"version_major": 2,
|
||
|
"version_minor": 0
|
||
|
},
|
||
|
"text/plain": [
|
||
|
"HBox(children=(IntProgress(value=0, max=1284), HTML(value='')))"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/home/mikkel/.virtualenvs/expipe/lib/python3.6/site-packages/scipy/signal/spectral.py:1577: RuntimeWarning: invalid value encountered in true_divide\n",
|
||
|
" Cxy = np.abs(Pxy)**2 / Pxx / Pyy\n",
|
||
|
"/home/mikkel/.virtualenvs/expipe/lib/python3.6/site-packages/ipykernel_launcher.py:28: RuntimeWarning: invalid value encountered in true_divide\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"results = units.merge(\n",
|
||
|
" units.progress_apply(process, axis=1), \n",
|
||
|
" left_index=True, right_index=True)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"pd.DataFrame(coherence_data).to_feather(output / 'data' / 'coherence.feather')\n",
|
||
|
"pd.DataFrame(freqency_data).to_feather(output / 'data' / 'freqs.feather')\n",
|
||
|
"pd.DataFrame(theta_kde_data).to_feather(output / 'data' / 'theta_kde.feather')\n",
|
||
|
"pd.DataFrame(theta_bins_data).to_feather(output / 'data' / 'theta_bins.feather')\n",
|
||
|
"pd.DataFrame(stim_kde_data).to_feather(output / 'data' / 'stim_kde.feather')\n",
|
||
|
"pd.DataFrame(stim_bins_data).to_feather(output / 'data' / 'stim_bins.feather')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Save to expipe"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"action = project.require_action(\"stimulus-spike-lfp-response-reduced-transient-cut\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"action.modules['parameters'] = {\n",
|
||
|
" 'NFFT': NFFT,\n",
|
||
|
" 'theta_band_f1': theta_band_f1,\n",
|
||
|
" 'theta_band_f2': theta_band_f2\n",
|
||
|
"}"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"action.data['results'] = 'results.csv'\n",
|
||
|
"results.to_csv(action.data_path('results'), index=False)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"copy_tree(output, str(action.data_path()))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"septum_mec.analysis.registration.store_notebook(action, \"10-calculate-stimulus-spike-lfp-response-reduced-transient-cut.ipynb\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.6.8"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 4
|
||
|
}
|