{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Measuring Synaptic Kinetics\n", "\n", "In this notebook we use the [Allen Institute synaptic physiology dataset](https://portal.brain-map.org/explore/connectivity/synaptic-physiology) to measure the kinetic properties of synaptic connections and the relationship to cell subclass.\n", "\n", "For an introduction to the Jupyter Notebook interface interface, try [Codeacademy: How To Use Jupyter Notebooks]( https://www.codecademy.com/articles/how-to-use-jupyter-notebooks) or [Jupyter Notebook Quick Start Guide](https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html).\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from aisynphys.database import SynphysDatabase\n", "from aisynphys.cell_class import CellClass" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Download and cache the sqlite file for the requested database\n", "# (for available versions, see SynphysDatabase.list_versions)\n", "db = SynphysDatabase.load_version('synphys_r1.0_2019-08-29_small.sqlite')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We are going to compare the strength of excitatory connectivity onto the three inhibitory cell subclassess -- Pvalb, Sst, and Vip.\n", "\n", "Begin by defining these subclasses:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "post_classes = {\n", " 'pvalb': CellClass(cre_type='pvalb'),\n", " 'sst': CellClass(cre_type='sst'),\n", " 'vip': CellClass(cre_type='vip'),\n", "}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Query the database to get all excitatory synapses with a specific postsynaptic cre type. We also filter here for specific project names \"mouse V1 coarse matrix\" and \"mouse V1 pre production\" in order to exclude other experiment types." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pvalb: 90 synapses\n", "sst: 71 synapses\n", "vip: 24 synapses\n" ] } ], "source": [ "# query once for each postsynaptic type, building up a Pandas dataframe\n", "\n", "pairs = None\n", "for name, post_class in post_classes.items():\n", " pair_query = db.pair_query(\n", " project_name=[\"mouse V1 coarse matrix\", \"mouse V1 pre production\"],\n", " post_class=post_class,\n", " synapse=True,\n", " synapse_type='ex',\n", " )\n", " pair_query = pair_query.add_columns(\n", " db.Synapse.latency,\n", " db.Synapse.psc_rise_time,\n", " db.Synapse.psc_decay_tau,\n", " db.Synapse.psp_amplitude,\n", " )\n", " df = pair_query.dataframe()\n", " df['post_class'] = name\n", " if pairs is None:\n", " pairs = df\n", " else:\n", " pairs = pairs.append(df)\n", " print(\"%s: %d synapses\" % (name, len(df)))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | id | \n", "experiment_id | \n", "pre_cell_id | \n", "post_cell_id | \n", "has_synapse | \n", "has_electrical | \n", "crosstalk_artifact | \n", "n_ex_test_spikes | \n", "n_in_test_spikes | \n", "distance | \n", "meta | \n", "latency | \n", "psc_rise_time | \n", "psc_decay_tau | \n", "psp_amplitude | \n", "post_class | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "43122 | \n", "1235 | \n", "7375 | \n", "7370 | \n", "True | \n", "False | \n", "None | \n", "12 | \n", "0 | \n", "0.000058 | \n", "None | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "pvalb | \n", "
1 | \n", "44106 | \n", "1264 | \n", "7546 | \n", "7550 | \n", "True | \n", "False | \n", "None | \n", "484 | \n", "60 | \n", "0.000052 | \n", "None | \n", "0.000937 | \n", "0.000547 | \n", "0.001353 | \n", "0.000436 | \n", "pvalb | \n", "
2 | \n", "44111 | \n", "1264 | \n", "7547 | \n", "7550 | \n", "True | \n", "False | \n", "None | \n", "196 | \n", "60 | \n", "0.000085 | \n", "None | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "pvalb | \n", "
3 | \n", "44116 | \n", "1264 | \n", "7548 | \n", "7550 | \n", "True | \n", "False | \n", "None | \n", "648 | \n", "60 | \n", "0.000110 | \n", "None | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "pvalb | \n", "
4 | \n", "44412 | \n", "1279 | \n", "7617 | \n", "7621 | \n", "True | \n", "False | \n", "None | \n", "480 | \n", "480 | \n", "0.000226 | \n", "None | \n", "0.000395 | \n", "NaN | \n", "NaN | \n", "0.000101 | \n", "pvalb | \n", "