|
@@ -2,7 +2,7 @@
|
|
"cells": [
|
|
"cells": [
|
|
{
|
|
{
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
- "execution_count": 1,
|
|
|
|
|
|
+ "execution_count": 4,
|
|
"metadata": {},
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"outputs": [],
|
|
"source": [
|
|
"source": [
|
|
@@ -16,7 +16,7 @@
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
- "execution_count": 2,
|
|
|
|
|
|
+ "execution_count": 5,
|
|
"metadata": {},
|
|
"metadata": {},
|
|
"outputs": [
|
|
"outputs": [
|
|
{
|
|
{
|
|
@@ -43,7 +43,7 @@
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
- "execution_count": 3,
|
|
|
|
|
|
+ "execution_count": 10,
|
|
"metadata": {},
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"outputs": [],
|
|
"source": [
|
|
"source": [
|
|
@@ -54,23 +54,25 @@
|
|
"#session, = '008229_hippoSIT_2022-05-16_20-36-44', None\n",
|
|
"#session, = '008229_hippoSIT_2022-05-16_20-36-44', None\n",
|
|
"#session, = '008229_hippoSIT_2022-05-20_15-54-39', None\n",
|
|
"#session, = '008229_hippoSIT_2022-05-20_15-54-39', None\n",
|
|
"#session, = '008229_hippoSIT_2022-05-18_14-36-18', None\n",
|
|
"#session, = '008229_hippoSIT_2022-05-18_14-36-18', None\n",
|
|
- "session, pellet_unit = '009265_hippoSIT_2023-03-05_11-52-17', '4-2'\n",
|
|
|
|
- "session, pellet_unit = '009266_hippoSIT_2023-04-24_16-56-55', '1-2'\n",
|
|
|
|
|
|
+ "#session, pellet_unit = '009265_hippoSIT_2023-03-05_11-52-17', '4-2'\n",
|
|
|
|
+ "#session, pellet_unit = '009266_hippoSIT_2023-04-24_16-56-55', '1-2'\n",
|
|
|
|
+ "session, pellet_unit = '009266_hippoSIT_2023-04-17_09-06-10', None\n",
|
|
"\n",
|
|
"\n",
|
|
- "animal = session.split('_')[0]\n",
|
|
|
|
|
|
+ "animal = session.split('_')[0]\n",
|
|
"sessionpath = os.path.join(source, animal, session)\n",
|
|
"sessionpath = os.path.join(source, animal, session)\n",
|
|
- "h5name = os.path.join(source, animal, session, session + '.h5')"
|
|
|
|
|
|
+ "h5_file = os.path.join(source, animal, session, session + '.h5')\n",
|
|
|
|
+ "aeps_file = os.path.join(source, animal, session, 'aeps.h5')"
|
|
]
|
|
]
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
- "execution_count": 4,
|
|
|
|
|
|
+ "execution_count": 11,
|
|
"metadata": {},
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"outputs": [],
|
|
"source": [
|
|
"source": [
|
|
"s_rate = 100 # Hz\n",
|
|
"s_rate = 100 # Hz\n",
|
|
"\n",
|
|
"\n",
|
|
- "with h5py.File(h5name, 'r') as f:\n",
|
|
|
|
|
|
+ "with h5py.File(h5_file, 'r') as f:\n",
|
|
" tl = np.array(f['processed']['timeline']) # time, X, Y, speed, etc.\n",
|
|
" tl = np.array(f['processed']['timeline']) # time, X, Y, speed, etc.\n",
|
|
" trials = np.array(f['processed']['trial_idxs']) # t_start_idx, t_end_idx, x_tgt, y_tgt, r_tgt, result"
|
|
" trials = np.array(f['processed']['trial_idxs']) # t_start_idx, t_end_idx, x_tgt, y_tgt, r_tgt, result"
|
|
]
|
|
]
|
|
@@ -84,7 +86,7 @@
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
- "execution_count": 5,
|
|
|
|
|
|
+ "execution_count": 12,
|
|
"metadata": {},
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"outputs": [],
|
|
"source": [
|
|
"source": [
|
|
@@ -140,7 +142,7 @@
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
- "execution_count": 6,
|
|
|
|
|
|
+ "execution_count": 15,
|
|
"metadata": {},
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"outputs": [],
|
|
"source": [
|
|
"source": [
|
|
@@ -160,31 +162,28 @@
|
|
" \n",
|
|
" \n",
|
|
" for idx in idxs_pel_start:\n",
|
|
" for idx in idxs_pel_start:\n",
|
|
" pellet_ev[idx:idx + 1*s_rate] = 1 # pellet chewing will be 1 second\n",
|
|
" pellet_ev[idx:idx + 1*s_rate] = 1 # pellet chewing will be 1 second\n",
|
|
- " pellet_onset[idxs_pel_start] = 1"
|
|
|
|
|
|
+ " pellet_onset[idxs_pel_start] = 1\n",
|
|
|
|
+ " \n",
|
|
|
|
+ " print('Detected %s pellet events for %s successful trials' % (idxs_pel_start.shape[0], idxs_reward.shape[0]))"
|
|
]
|
|
]
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
- "execution_count": 7,
|
|
|
|
|
|
+ "execution_count": null,
|
|
"metadata": {},
|
|
"metadata": {},
|
|
- "outputs": [
|
|
|
|
- {
|
|
|
|
- "name": "stdout",
|
|
|
|
- "output_type": "stream",
|
|
|
|
- "text": [
|
|
|
|
- "Detected 69 pellet events for 21 successful trials\n"
|
|
|
|
- ]
|
|
|
|
- }
|
|
|
|
- ],
|
|
|
|
|
|
+ "outputs": [],
|
|
"source": [
|
|
"source": [
|
|
- "print('Detected %s pellet events for %s successful trials' % (idxs_pel_start.shape[0], idxs_reward.shape[0]))"
|
|
|
|
|
|
+ "# AEP events\n",
|
|
|
|
+ "with h5py.File(aeps_file, 'r') as f:\n",
|
|
|
|
+ " aeps = np.array(f['aeps'])\n",
|
|
|
|
+ " aeps_events = np.array(f['aeps_events'])"
|
|
]
|
|
]
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"cell_type": "markdown",
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"metadata": {},
|
|
"source": [
|
|
"source": [
|
|
- "## Read neuronal data"
|
|
|
|
|
|
+ "## Read assembly data"
|
|
]
|
|
]
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -236,6 +235,13 @@
|
|
"assembly_weights"
|
|
"assembly_weights"
|
|
]
|
|
]
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ "cell_type": "markdown",
|
|
|
|
+ "metadata": {},
|
|
|
|
+ "source": [
|
|
|
|
+ "## Read units"
|
|
|
|
+ ]
|
|
|
|
+ },
|
|
{
|
|
{
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
"execution_count": 24,
|
|
"execution_count": 24,
|
|
@@ -299,14 +305,15 @@
|
|
"#to_plot = {key: assembly_activity[key] for key in (1, 3, 4, 6, 5)}\n",
|
|
"#to_plot = {key: assembly_activity[key] for key in (1, 3, 4, 6, 5)}\n",
|
|
"to_plot = single_units\n",
|
|
"to_plot = single_units\n",
|
|
"\n",
|
|
"\n",
|
|
- "titles = ['Background', 'Noise', 'Target', 'Reward', 'Pellet']"
|
|
|
|
|
|
+ "#titles = ['Background', 'Noise', 'Target', 'Reward', 'Pellet']\n",
|
|
|
|
+ "titles = ['Background', 'Noise', 'Target', 'Reward']"
|
|
]
|
|
]
|
|
},
|
|
},
|
|
{
|
|
{
|
|
"cell_type": "code",
|
|
"cell_type": "code",
|
|
"execution_count": 27,
|
|
"execution_count": 27,
|
|
"metadata": {
|
|
"metadata": {
|
|
- "scrolled": true
|
|
|
|
|
|
+ "scrolled": false
|
|
},
|
|
},
|
|
"outputs": [
|
|
"outputs": [
|
|
{
|
|
{
|
|
@@ -368,6 +375,64 @@
|
|
"fig.tight_layout()"
|
|
"fig.tight_layout()"
|
|
]
|
|
]
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ "cell_type": "markdown",
|
|
|
|
+ "metadata": {},
|
|
|
|
+ "source": [
|
|
|
|
+ "## Cross-AEPs"
|
|
|
|
+ ]
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ "cell_type": "code",
|
|
|
|
+ "execution_count": null,
|
|
|
|
+ "metadata": {},
|
|
|
|
+ "outputs": [],
|
|
|
|
+ "source": [
|
|
|
|
+ "fig = plt.figure(figsize=(14, 3*len(to_plot)))\n",
|
|
|
|
+ "\n",
|
|
|
|
+ "t_lag = 30 # seconds\n",
|
|
|
|
+ "j = 0\n",
|
|
|
|
+ "\n",
|
|
|
|
+ "for ass_id, i_rate in to_plot.items():\n",
|
|
|
|
+ " for i, var_all in enumerate([\n",
|
|
|
|
+ " (sound_bg, backgr_onset), \n",
|
|
|
|
+ " (sound_ns, noise_onset), \n",
|
|
|
|
+ " (sound_tg, target_onset), \n",
|
|
|
|
+ " (reward_tl, reward_onset),\n",
|
|
|
|
+ " (pellet_ev, pellet_ev)\n",
|
|
|
|
+ " ]):\n",
|
|
|
|
+ " ax = fig.add_subplot(len(to_plot), 5, i+1 + 5*j)\n",
|
|
|
|
+ "\n",
|
|
|
|
+ " for k, var_tl in enumerate(var_all[1:2]):\n",
|
|
|
|
+ " corr = signal.correlate(i_rate, var_tl)\n",
|
|
|
|
+ " lags = signal.correlation_lags(len(var_tl), len(i_rate))\n",
|
|
|
|
+ "\n",
|
|
|
|
+ " idx_l, idx_r = int(len(lags)/2) - t_lag*s_rate, int(len(lags)/2) + t_lag*s_rate\n",
|
|
|
|
+ " y_min = 0.8*corr[idx_l:idx_r].min()\n",
|
|
|
|
+ " y_max = 1.2*corr[idx_l:idx_r].max()\n",
|
|
|
|
+ "\n",
|
|
|
|
+ " ax.plot(lags[idx_l:idx_r]/100, corr[idx_l:idx_r], color='blue' if k==0 else 'orange')\n",
|
|
|
|
+ "\n",
|
|
|
|
+ " if i == 0:\n",
|
|
|
|
+ " ax.set_ylabel(ass_id, fontsize=14)\n",
|
|
|
|
+ " if i == 2:\n",
|
|
|
|
+ " ax.axvline(5, color='green', ls='--')\n",
|
|
|
|
+ " if i == 3:\n",
|
|
|
|
+ " ax.axvline(-5, color='green', ls='--')\n",
|
|
|
|
+ "\n",
|
|
|
|
+ " ax.axvline(0, color='black')\n",
|
|
|
|
+ " ax.set_xlim(-t_lag, t_lag)\n",
|
|
|
|
+ " ax.set_ylim(y_min, y_max)\n",
|
|
|
|
+ " if j == 0:\n",
|
|
|
|
+ " ax.set_title(titles[i], fontsize=14)\n",
|
|
|
|
+ " if j == len(to_plot) - 1:\n",
|
|
|
|
+ " ax.set_xlabel('Time, sec', fontsize=14)\n",
|
|
|
|
+ " ax.grid()\n",
|
|
|
|
+ " j += 1\n",
|
|
|
|
+ " \n",
|
|
|
|
+ "fig.tight_layout()"
|
|
|
|
+ ]
|
|
|
|
+ },
|
|
{
|
|
{
|
|
"cell_type": "markdown",
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"metadata": {},
|