Topology in neuroscience
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1308 lines
610 KiB

2 years ago
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Brain Observatory dataset"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import scipy\n",
"import pickle as pkl\n",
"import ipywidgets as widgets\n",
"from mpl_toolkits import mplot3d\n",
"from scipy import sparse\n",
"import sys\n",
"sys.path.insert(0, '../model/')\n",
"sys.path.insert(0, 'model')\n",
"\n",
"import collections\n",
"collections.Callable = collections.abc.Callable"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"with open('dump.pkl', 'rb') as f:\n",
" gl = pkl.load(f)\n",
" for key in gl:\n",
" globals()[key] = gl[key]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open('masks.pkl', 'rb') as f:\n",
" masks = pkl.load(f)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['__name__', '__doc__', '__package__', '__loader__', '__spec__', '__builtin__', '__builtins__', '_ih', '_oh', '_dh', 'In', 'Out', 'get_ipython', 'exit', 'quit', '_', '__', '___', 'sys', 'os', '__vsc_ipynb_file__', '_i', '_ii', '_iii', '_i1', 'f', '_i2', 'np', 'plt', 'pd', 'scipy', 'pkl', 'widgets', 'mplot3d', 'sparse', 'collections', '_i3', '_i4', '_i5', 'dill', 'gl', 'key', '_i6', '_i7', 'Axes3D', 'fig', 'ax', '_i8', 'ncomp_umap', '_i9', 'UMAP', '_i10', '_i11', '_i12', '_i13', '_i14', 'BrainObservatoryCache', 'pprint', 'boc', 'targeted_structures', '_i15', 'stim_info', 'exp_noise', 'exp_scenes', 'exp_gratings', '_i16', 'LocallySparseNoise', 'noise_data', '_i17', 'cont_ids_noise', 'cont_ids_scenes', 'cells_noise', 'cells_scenes', 'cell_ids', 'cells', 'specimen_ids', 'cells_by_specimen', '_17', '_i18', 'cont_ids_gratings', 'cells_gratings', '_i19', '_19', '_i20', '_20', '_i21', 'get_cell', 'get_noise_exp_for_cell', 'get_scene_exp_for_cell', 'get_grating_exp_for_cell', '_i22', 'exp_1', '_i23', 'NaturalScenes', '_i24', 'exp_1_', '_i25', '_i26', '_i27', 'resp_nat', '_i28', '_28', '_i29', 'ids_exp_1', '_i30', '_i31', 'first_cell_ids', '_i32', '_i33', '_i34', '_i35', 'masks', 'broken_exps', 'cell_id', 'exp_id', 'exp', 'cell_ids_exp', 'masks_for_exp', 'i', 'cell_id_', '_i36', 'roi_centers', '_i37', 'exp_conts', 'cells_by_exp', '_i38'])"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"globals().keys()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"with open('dump.pkl', 'wb') as f:\n",
" pickle.dump({k: globals()[k] for k in [\n",
" 'boc', 'exp_noise', 'exp_scenes', 'exp_gratings', 'noise_data', 'cont_ids_noise', 'cont_ids_scenes', \n",
" 'cells_noise', 'cells_scenes', 'cell_ids', 'cells', 'specimen_ids', 'cont_ids_gratings', 'cells_gratings', 'exp_1', 'exp_1_', 'resp_nat', 'ids_exp_1', \n",
" 'first_cell_ids', 'broken_exps', 'cell_ids_exp', 'masks_for_exp', 'roi_centers', 'exp_conts', 'cells_by_exp',\n",
" 'cells_by_exp_and_region', 'max_exp_id', 'cells_chosen', 'resp_gr', 'exp_ch_gratings', \n",
" 'exp_ch_scenes', 'exp_ch_scenes_', 'embed', 'ch_cells_inds', 'resp_gr_flat',\n",
" 'resp_nat', 'stim_table', 'stim_ori', 'stim_ph', 'stim_freq', 'embed_gr', 'embed_nat'\n",
" ]}, f)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"all targeted structures: ['VISal', 'VISam', 'VISl', 'VISp', 'VISpm', 'VISrl']\n"
]
}
],
"source": [
"from allensdk.core.brain_observatory_cache import BrainObservatoryCache\n",
"import pprint\n",
"\n",
"# This class uses a 'manifest' to keep track of downloaded data and metadata. \n",
"# All downloaded files will be stored relative to the directory holding the manifest\n",
"# file. If 'manifest_file' is a relative path (as it is below), it will be \n",
"# saved relative to your working directory. It can also be an absolute path.\n",
"boc = BrainObservatoryCache()\n",
"\n",
"# Download a list of all targeted areas\n",
"targeted_structures = boc.get_all_targeted_structures()\n",
"print(\"all targeted structures: \" + str(targeted_structures))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"all cre lines:\n",
"\n",
"['Cux2-CreERT2',\n",
" 'Emx1-IRES-Cre',\n",
" 'Fezf2-CreER',\n",
" 'Nr5a1-Cre',\n",
" 'Ntsr1-Cre_GN220',\n",
" 'Pvalb-IRES-Cre',\n",
" 'Rbp4-Cre_KL100',\n",
" 'Rorb-IRES2-Cre',\n",
" 'Scnn1a-Tg3-Cre',\n",
" 'Slc17a7-IRES2-Cre',\n",
" 'Sst-IRES-Cre',\n",
" 'Tlx3-Cre_PL56',\n",
" 'Vip-IRES-Cre']\n"
]
}
],
"source": [
"cre_lines = boc.get_all_cre_lines()\n",
"print(\"all cre lines:\\n\")\n",
"pprint.pprint(cre_lines)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Experiment with scenes: 456, with noise: 76\n",
"{'acquisition_age_days': 98,\n",
" 'cre_line': 'Cux2-CreERT2',\n",
" 'donor_name': '225037',\n",
" 'experiment_container_id': 511510699,\n",
" 'fail_eye_tracking': True,\n",
" 'id': 502974807,\n",
" 'imaging_depth': 275,\n",
" 'reporter_line': 'Ai93(TITL-GCaMP6f)',\n",
" 'session_type': 'three_session_C',\n",
" 'specimen_name': 'Cux2-CreERT2;Camk2a-tTA;Ai93-225037',\n",
" 'targeted_structure': 'VISp'}\n",
"{'acquisition_age_days': 124,\n",
" 'cre_line': 'Slc17a7-IRES2-Cre',\n",
" 'donor_name': '361636',\n",
" 'experiment_container_id': 662358769,\n",
" 'fail_eye_tracking': False,\n",
" 'id': 663488086,\n",
" 'imaging_depth': 175,\n",
" 'reporter_line': 'Ai93(TITL-GCaMP6f)',\n",
" 'session_type': 'three_session_B',\n",
" 'specimen_name': 'Slc17a7-IRES2-Cre;Camk2a-tTA;Ai93-361636',\n",
" 'targeted_structure': 'VISl'}\n"
]
}
],
"source": [
"import allensdk.brain_observatory.stimulus_info as stim_info\n",
"\n",
"# pick one of the cux2 experiment containers\n",
"# cux2_ec_id = cux2_ecs[-1]['id']\n",
"\n",
"exp_noise = boc.get_ophys_experiments(stimuli=[stim_info.LOCALLY_SPARSE_NOISE])\n",
"exp_scenes = boc.get_ophys_experiments(stimuli=[stim_info.NATURAL_SCENES])\n",
"exp_gratings = boc.get_ophys_experiments(stimuli=[stim_info.STATIC_GRATINGS])\n",
"print(f\"Experiment with scenes: {len(exp_scenes)}, with noise: {len(exp_noise)}\")\n",
"pprint.pprint(exp_noise[0])\n",
"pprint.pprint(exp_scenes[0])"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"from allensdk.brain_observatory.locally_sparse_noise import LocallySparseNoise\n",
"\n",
"noise_data = np.array([LocallySparseNoise(exp['id']) for exp in exp_noise])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/home/ennucore/dev/amgen/exp/Allen.ipynb Cell 10\u001b[0m in \u001b[0;36m<cell line: 3>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000009?line=0'>1</a>\u001b[0m cont_ids_noise \u001b[39m=\u001b[39m [exp[\u001b[39m'\u001b[39m\u001b[39mexperiment_container_id\u001b[39m\u001b[39m'\u001b[39m] \u001b[39mfor\u001b[39;00m exp \u001b[39min\u001b[39;00m exp_noise]\n\u001b[1;32m <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000009?line=1'>2</a>\u001b[0m cont_ids_scenes \u001b[39m=\u001b[39m [exp[\u001b[39m'\u001b[39m\u001b[39mexperiment_container_id\u001b[39m\u001b[39m'\u001b[39m] \u001b[39mfor\u001b[39;00m exp \u001b[39min\u001b[39;00m exp_scenes]\n\u001b[0;32m----> <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000009?line=2'>3</a>\u001b[0m cells_noise \u001b[39m=\u001b[39m boc\u001b[39m.\u001b[39;49mget_cell_specimens(experiment_container_ids\u001b[39m=\u001b[39;49mcont_ids_noise)\n\u001b[1;32m <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000009?line=3'>4</a>\u001b[0m cells_scenes \u001b[39m=\u001b[39m boc\u001b[39m.\u001b[39mget_cell_specimens(experiment_container_ids\u001b[39m=\u001b[39mcont_ids_scenes)\n\u001b[1;32m <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000009?line=4'>5</a>\u001b[0m cell_ids \u001b[39m=\u001b[39m np\u001b[39m.\u001b[39marray(\u001b[39mlist\u001b[39m(\u001b[39mset\u001b[39m(cell[\u001b[39m'\u001b[39m\u001b[39mcell_specimen_id\u001b[39m\u001b[39m'\u001b[39m] \u001b[39mfor\u001b[39;00m cell \u001b[39min\u001b[39;00m cells_noise)\u001b[39m.\u001b[39mintersection(\u001b[39mset\u001b[39m(cell[\u001b[39m'\u001b[39m\u001b[39mcell_specimen_id\u001b[39m\u001b[39m'\u001b[39m] \u001b[39mfor\u001b[39;00m cell \u001b[39min\u001b[39;00m cells_scenes))))\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/allensdk-2.13.4-py3.10.egg/allensdk/core/brain_observatory_cache.py:435\u001b[0m, in \u001b[0;36mBrainObservatoryCache.get_cell_specimens\u001b[0;34m(self, file_name, ids, experiment_container_ids, include_failed, simple, filters)\u001b[0m\n\u001b[1;32m 394\u001b[0m \u001b[39m\"\"\" Return cell specimens that have certain properies.\u001b[39;00m\n\u001b[1;32m 395\u001b[0m \n\u001b[1;32m 396\u001b[0m \u001b[39mParameters\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 430\u001b[0m \u001b[39mlist of dictionaries\u001b[39;00m\n\u001b[1;32m 431\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 433\u001b[0m file_name \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mget_cache_path(file_name, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mCELL_SPECIMENS_KEY)\n\u001b[0;32m--> 435\u001b[0m cell_specimens \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mapi\u001b[39m.\u001b[39;49mget_cell_metrics(path\u001b[39m=\u001b[39;49mfile_name,\n\u001b[1;32m 436\u001b[0m strategy\u001b[39m=\u001b[39;49m\u001b[39m'\u001b[39;49m\u001b[39mlazy\u001b[39;49m\u001b[39m'\u001b[39;49m,\n\u001b[1;32m 437\u001b[0m pre\u001b[39m=\u001b[39;49m \u001b[39mlambda\u001b[39;49;00m x: [y \u001b[39mfor\u001b[39;49;00m y \u001b[39min\u001b[39;49;00m x],\n\u001b[1;32m 438\u001b[0m \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mCache\u001b[39m.\u001b[39;49mcache_json())\n\u001b[1;32m 440\u001b[0m cell_specimens \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mapi\u001b[39m.\u001b[39mfilter_cell_specimens(cell_specimens,\n\u001b[1;32m 441\u001b[0m ids\u001b[39m=\u001b[39mids,\n\u001b[1;32m 442\u001b[0m experiment_container_ids\u001b[39m=\u001b[39mexperiment_container_ids,\n\u001b[1;32m 443\u001b[0m include_failed\u001b[39m=\u001b[39minclude_failed,\n\u001b[1;32m 444\u001b[0m filters\u001b[39m=\u001b[39mfilters)\n\u001b[1;32m 446\u001b[0m \u001b[39m# drop the thumbnail columns\u001b[39;00m\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/allensdk-2.13.4-py3.10.egg/allensdk/api/warehouse_cache/cache.py:661\u001b[0m, in \u001b[0;36mcacheable.<locals>.decor.<locals>.w\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 658\u001b[0m \u001b[39mif\u001b[39;00m decor\u001b[39m.\u001b[39mpost \u001b[39mand\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39m'\u001b[39m\u001b[39mpost in kwargs\u001b[39m\u001b[39m'\u001b[39m:\n\u001b[1;32m 659\u001b[0m kwargs[\u001b[39m'\u001b[39m\u001b[39mpost\u001b[39m\u001b[39m'\u001b[39m] \u001b[39m=\u001b[39m decor\u001b[39m.\u001b[39mpost\n\u001b[0;32m--> 661\u001b[0m result \u001b[39m=\u001b[39m Cache\u001b[39m.\u001b[39;49mcacher(func,\n\u001b[1;32m 662\u001b[0m \u001b[39m*\u001b[39;49margs,\n\u001b[1;32m 663\u001b[0m \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 664\u001b[0m \u001b[39mreturn\u001b[39;00m result\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/allensdk-2.13.4-py3.10.egg/allensdk/api/warehouse_cache/cache.py:390\u001b[0m, in \u001b[0;36mCache.cacher\u001b[0;34m(fn, *args, **kwargs)\u001b[0m\n\u001b[1;32m 387\u001b[0m data \u001b[39m=\u001b[39m fn(\u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n\u001b[1;32m 389\u001b[0m \u001b[39mif\u001b[39;00m reader:\n\u001b[0;32m--> 390\u001b[0m data \u001b[39m=\u001b[39m reader(path)\n\u001b[1;32m 392\u001b[0m \u001b[39m# Note: don't provide post if fn or reader doesn't return data\u001b[39;00m\n\u001b[1;32m 393\u001b[0m \u001b[39mif\u001b[39;00m post:\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/allensdk-2.13.4-py3.10.egg/allensdk/core/json_utilities.py:60\u001b[0m, in \u001b[0;36mread\u001b[0;34m(file_name)\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mlen\u001b[39m(json_string)\u001b[39m==\u001b[39m\u001b[39m0\u001b[39m: \u001b[39m# If empty file\u001b[39;00m\n\u001b[1;32m 59\u001b[0m json_string\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39m{}\u001b[39;00m\u001b[39m'\u001b[39m \u001b[39m# Create a string that will give an empty JSON object instead of an error\u001b[39;00m\n\u001b[0;32m---> 60\u001b[0m json_obj \u001b[39m=\u001b[39m json\u001b[39m.\u001b[39;49mloads(json_string)\n\u001b[1;32m 62\u001b[0m \u001b[39mreturn\u001b[39;00m json_obj\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/simplejson/__init__.py:525\u001b[0m, in \u001b[0;36mloads\u001b[0;34m(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw)\u001b[0m\n\u001b[1;32m 477\u001b[0m \u001b[39m\"\"\"Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON\u001b[39;00m\n\u001b[1;32m 478\u001b[0m \u001b[39mdocument) to a Python object.\u001b[39;00m\n\u001b[1;32m 479\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 519\u001b[0m \n\u001b[1;32m 520\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 521\u001b[0m \u001b[39mif\u001b[39;00m (\u001b[39mcls\u001b[39m \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m encoding \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m object_hook \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m\n\u001b[1;32m 522\u001b[0m parse_int \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m parse_float \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m\n\u001b[1;32m 523\u001b[0m parse_constant \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m \u001b[39mand\u001b[39;00m object_pairs_hook \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 524\u001b[0m \u001b[39mand\u001b[39;00m \u001b[39mnot\u001b[39;00m use_decimal \u001b[39mand\u001b[39;00m \u001b[39mnot\u001b[39;00m kw):\n\u001b[0;32m--> 525\u001b[0m \u001b[39mreturn\u001b[39;00m _default_decoder\u001b[39m.\u001b[39;49mdecode(s)\n\u001b[1;32m 526\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mcls\u001b[39m \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 527\u001b[0m \u001b[39mcls\u001b[39m \u001b[39m=\u001b[39m JSONDecoder\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/simplejson/decoder.py:370\u001b[0m, in \u001b[0;36mJSONDecoder.decode\u001b[0;34m(self, s, _w, _PY3)\u001b[0m\n\u001b[1;32m 368\u001b[0m \u001b[39mif\u001b[39;00m _PY3 \u001b[39mand\u001b[39;00m \u001b[39misinstance\u001b[39m(s, \u001b[39mbytes\u001b[39m):\n\u001b[1;32m 369\u001b[0m s \u001b[39m=\u001b[39m \u001b[39mstr\u001b[39m(s, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mencoding)\n\u001b[0;32m--> 370\u001b[0m obj, end \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mraw_decode(s)\n\u001b[1;32m 371\u001b[0m end \u001b[39m=\u001b[39m _w(s, end)\u001b[39m.\u001b[39mend()\n\u001b[1;32m 372\u001b[0m \u001b[39mif\u001b[39;00m end \u001b[39m!=\u001b[39m \u001b[39mlen\u001b[39m(s):\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/simplejson/decoder.py:400\u001b[0m, in \u001b[0;36mJSONDecoder.raw_decode\u001b[0;34m(self, s, idx, _w, _PY3)\u001b[0m\n\u001b[1;32m 398\u001b[0m \u001b[39melif\u001b[39;00m ord0 \u001b[39m==\u001b[39m \u001b[39m0xef\u001b[39m \u001b[39mand\u001b[39;00m s[idx:idx \u001b[39m+\u001b[39m \u001b[39m3\u001b[39m] \u001b[39m==\u001b[39m \u001b[39m'\u001b[39m\u001b[39m\\xef\u001b[39;00m\u001b[39m\\xbb\u001b[39;00m\u001b[39m\\xbf\u001b[39;00m\u001b[39m'\u001b[39m:\n\u001b[1;32m 399\u001b[0m idx \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m \u001b[39m3\u001b[39m\n\u001b[0;32m--> 400\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mscan_once(s, idx\u001b[39m=\u001b[39;49m_w(s, idx)\u001b[39m.\u001b[39;49mend())\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"cont_ids_noise = [exp['experiment_container_id'] for exp in exp_noise]\n",
"cont_ids_scenes = [exp['experiment_container_id'] for exp in exp_scenes]\n",
"cells_noise = boc.get_cell_specimens(experiment_container_ids=cont_ids_noise)\n",
"cells_scenes = boc.get_cell_specimens(experiment_container_ids=cont_ids_scenes)\n",
"cell_ids = np.array(list(set(cell['cell_specimen_id'] for cell in cells_noise).intersection(set(cell['cell_specimen_id'] for cell in cells_scenes))))\n",
"cells = [c for c in cells_noise if c['cell_specimen_id'] in cell_ids]\n",
"specimen_ids = list(sorted(set([c['cell_specimen_id'] for c in cells])))\n",
"cells_by_specimen = [[c for c in cells if c['cell_specimen_id'] == specimen_id] for specimen_id in specimen_ids]\n",
"len(cells)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"cont_ids_gratings = [exp['experiment_container_id'] for exp in exp_gratings]\n",
"cells_gratings = boc.get_cell_specimens(experiment_container_ids=cont_ids_gratings)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(76, 456, 17546, 63251, 17546, 17546)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(exp_noise), len(exp_scenes), len(cells_noise), len(cells_scenes), len(set(cell['cell_specimen_id'] for cell in cells_noise).intersection(set(cell['cell_specimen_id'] for cell in cells_scenes))), len(cell_ids)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(76, 456, 456, 76)"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(cont_ids_noise), len(cont_ids_scenes), len(cont_ids_gratings), len(set(cont_ids_noise).intersection(set(cont_ids_scenes).intersection(set(cont_ids_gratings))))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['all_stim', 'area', 'cell_specimen_id', 'donor_full_genotype', 'dsi_dg', 'experiment_container_id', 'failed_experiment_container', 'g_dsi_dg', 'g_osi_dg', 'g_osi_sg', 'image_sel_ns', 'imaging_depth', 'osi_dg', 'osi_sg', 'p_dg', 'p_ns', 'p_run_mod_dg', 'p_run_mod_ns', 'p_run_mod_sg', 'p_sg', 'peak_dff_dg', 'peak_dff_ns', 'peak_dff_sg', 'pref_dir_dg', 'pref_image_ns', 'pref_ori_sg', 'pref_phase_sg', 'pref_sf_sg', 'pref_tf_dg', 'reliability_dg', 'reliability_nm1_a', 'reliability_nm1_b', 'reliability_nm1_c', 'reliability_nm2', 'reliability_nm3', 'reliability_ns', 'reliability_sg', 'rf_area_off_lsn', 'rf_area_on_lsn', 'rf_center_off_x_lsn', 'rf_center_off_y_lsn', 'rf_center_on_x_lsn', 'rf_center_on_y_lsn', 'rf_chi2_lsn', 'rf_distance_lsn', 'rf_overlap_index_lsn', 'run_mod_dg', 'run_mod_ns', 'run_mod_sg', 'sfdi_sg', 'specimen_id', 'tfdi_dg', 'time_to_peak_ns', 'time_to_peak_sg', 'tld1_id', 'tld1_name', 'tld2_id', 'tld2_name', 'tlr1_id', 'tlr1_name'])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cells_noise[0].keys()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"get_cell = lambda cell_id: [c for c in cells if c['cell_specimen_id'] == cell_id][0]\n",
"get_noise_exp_for_cell = lambda cell_id: exp_noise[cont_ids_noise.index(get_cell(cell_id)['experiment_container_id'])]\n",
"get_scene_exp_for_cell = lambda cell_id: exp_scenes[cont_ids_scenes.index(get_cell(cell_id)['experiment_container_id'])]\n",
"get_grating_exp_for_cell = lambda cell_id: exp_gratings[cont_ids_gratings.index(get_cell(cell_id)['experiment_container_id'])]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get receptive field centers"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"exp_1 = boc.get_ophys_experiment_data(get_noise_exp_for_cell(cell_ids[0])['id'])"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.where(cell_ids == cell_ids[0])[0][0]"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"first_cell_ids = [cell['cell_specimen_id'] for cell in cells if cell['experiment_container_id'] == cells[0]['experiment_container_id']]"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(254, 254)"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"first_cell_ids = list(set(exp_1.get_cell_specimen_ids()).intersection(cell_ids))\n",
"len(first_cell_ids), len(exp_1.get_cell_specimen_ids())"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"exp_conts = list(set([cell['experiment_container_id'] for cell in cells]))\n",
"cells_by_exp = [[c for c in cells if c['experiment_container_id'] == exp_cont] for exp_cont in exp_conts]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"ename": "ValueError",
"evalue": "Cell specimen not found (589168640 is not in list)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/allensdk-2.13.4-py3.10.egg/allensdk/core/brain_observatory_nwb_data_set.py:416\u001b[0m, in \u001b[0;36mBrainObservatoryNwbDataSet.get_cell_specimen_indices\u001b[0;34m(self, cell_specimen_ids)\u001b[0m\n\u001b[1;32m 415\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 416\u001b[0m inds \u001b[39m=\u001b[39m [\u001b[39mlist\u001b[39m(all_cell_specimen_ids)\u001b[39m.\u001b[39mindex(i)\n\u001b[1;32m 417\u001b[0m \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m cell_specimen_ids]\n\u001b[1;32m 418\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mValueError\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/allensdk-2.13.4-py3.10.egg/allensdk/core/brain_observatory_nwb_data_set.py:416\u001b[0m, in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 415\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 416\u001b[0m inds \u001b[39m=\u001b[39m [\u001b[39mlist\u001b[39;49m(all_cell_specimen_ids)\u001b[39m.\u001b[39;49mindex(i)\n\u001b[1;32m 417\u001b[0m \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m cell_specimen_ids]\n\u001b[1;32m 418\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mValueError\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n",
"\u001b[0;31mValueError\u001b[0m: 589168640 is not in list",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/home/ennucore/dev/amgen/exp/Allen.ipynb Cell 21\u001b[0m in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000020?line=0'>1</a>\u001b[0m first_masks \u001b[39m=\u001b[39m exp_1\u001b[39m.\u001b[39;49mget_roi_mask(cell_specimen_ids\u001b[39m=\u001b[39;49mfirst_cell_ids)\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/allensdk-2.13.4-py3.10.egg/allensdk/core/brain_observatory_nwb_data_set.py:707\u001b[0m, in \u001b[0;36mBrainObservatoryNwbDataSet.get_roi_mask\u001b[0;34m(self, cell_specimen_ids)\u001b[0m\n\u001b[1;32m 705\u001b[0m inds \u001b[39m=\u001b[39m \u001b[39mrange\u001b[39m(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mnumber_of_cells)\n\u001b[1;32m 706\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 707\u001b[0m inds \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mget_cell_specimen_indices(cell_specimen_ids)\n\u001b[1;32m 709\u001b[0m roi_array \u001b[39m=\u001b[39m []\n\u001b[1;32m 710\u001b[0m \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m inds:\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/allensdk-2.13.4-py3.10.egg/allensdk/core/brain_observatory_nwb_data_set.py:419\u001b[0m, in \u001b[0;36mBrainObservatoryNwbDataSet.get_cell_specimen_indices\u001b[0;34m(self, cell_specimen_ids)\u001b[0m\n\u001b[1;32m 416\u001b[0m inds \u001b[39m=\u001b[39m [\u001b[39mlist\u001b[39m(all_cell_specimen_ids)\u001b[39m.\u001b[39mindex(i)\n\u001b[1;32m 417\u001b[0m \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m cell_specimen_ids]\n\u001b[1;32m 418\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mValueError\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n\u001b[0;32m--> 419\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mValueError\u001b[39;00m(\u001b[39m\"\u001b[39m\u001b[39mCell specimen not found (\u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m)\u001b[39m\u001b[39m\"\u001b[39m \u001b[39m%\u001b[39m \u001b[39mstr\u001b[39m(e))\n\u001b[1;32m 421\u001b[0m \u001b[39mreturn\u001b[39;00m inds\n",
"\u001b[0;31mValueError\u001b[0m: Cell specimen not found (589168640 is not in list)"
]
}
],
"source": [
"first_masks = exp_1.get_roi_mask(cell_specimen_ids=first_cell_ids)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7fef273c77c0>"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png":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VFXrqmoDcAFwfVW9B7gBOL9N2wxc1cY72zJt/fVVXtYnLSULuY7hw8AHk8wxOIdwWatfBpzQ6h8Eti2sRUmL7YhuoqqqbwLfbOP7ge7jhqrqp8A7x9CbpCnxykdJHYNBUsdgkNQxGCR1DAZJHYNBUsdgkNQxGCR1DAZJHYNBUsdgkNQxGCR1DAZJHYNBUsdgkNQxGCR1DAZJHYNBUsdgkNQxGCR1DAZJHYNBUsdgkNQxGCR1DAZJHYNBUsdgkNQxGCR1DAZJHYNBUsdgkNQxGCR1DAZJHYNBUmekYEjyQJI7k9yWZFerHZ/k2iT3tecXt3qSXJpkLskdSU6f5DcgafyOZI/h96rqtKra1Ja3AddV1UbgurYM8FZgY3tsBT41rmYlLY6FHEqcC+xo4x3AeUP1z9TAjcCaJCcvYDuSFtmowVDAvyW5JcnWVjupqh5u40eAk9p4LfDQ0Gv3tNozJNmaZFeSXQfYfxStS5qU5SPOe2NV7U3yK8C1Sf5reGVVVZI6kg1X1XZgO8CxOf6IXitpskbaY6iqve15H/BV4LXA9w8dIrTnfW36XmD90MvXtZqkJWLeYEjygiQvOjQG3gLcBewENrdpm4Gr2ngn8N727sQZwBNDhxySloBRDiVOAr6a5ND8z1fV15LcDFyZZAvwIPCuNv8a4BxgDngSeN/Yu5Y0Uama/uF9kh8D9067jxG9BPjBtJsYwVLpE5ZOr0ulTzh8ry+rqhNHefGoJx8n7d6h6yNmWpJdS6HXpdInLJ1el0qfsPBevSRaUsdgkNSZlWDYPu0GjsBS6XWp9AlLp9el0icssNeZOPkoabbMyh6DpBky9WBIcnaSe9tt2tvmf8VEe7k8yb4kdw3VZvL28iTrk9yQ5J4kdyd
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.imshow(first_masks[199].get_mask_plane())"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-08-02 22:22:11,323 allensdk.api.api.retrieve_file_over_http INFO Downloading URL: http://api.brain-map.org/api/v2/well_known_file_download/514427284\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m/home/ennucore/dev/amgen/exp/Allen.ipynb Cell 23\u001b[0m in \u001b[0;36m<cell line: 3>\u001b[0;34m()\u001b[0m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000018?line=11'>12</a>\u001b[0m \u001b[39mcontinue\u001b[39;00m\n\u001b[1;32m <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000018?line=12'>13</a>\u001b[0m cell_ids_exp \u001b[39m=\u001b[39m exp\u001b[39m.\u001b[39mget_cell_specimen_ids()\n\u001b[0;32m---> <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000018?line=13'>14</a>\u001b[0m masks_for_exp \u001b[39m=\u001b[39m exp\u001b[39m.\u001b[39;49mget_roi_mask(cell_specimen_ids\u001b[39m=\u001b[39;49mcell_ids_exp)\n\u001b[1;32m <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000018?line=14'>15</a>\u001b[0m \u001b[39mfor\u001b[39;00m i, cell_id_ \u001b[39min\u001b[39;00m \u001b[39menumerate\u001b[39m(cell_ids_exp):\n\u001b[1;32m <a href='vscode-notebook-cell:/home/ennucore/dev/amgen/exp/Allen.ipynb#ch0000018?line=15'>16</a>\u001b[0m masks[cell_id_] \u001b[39m=\u001b[39m masks_for_exp[i]\u001b[39m.\u001b[39mget_mask_plane()\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/allensdk-2.13.4-py3.10.egg/allensdk/core/brain_observatory_nwb_data_set.py:712\u001b[0m, in \u001b[0;36mBrainObservatoryNwbDataSet.get_roi_mask\u001b[0;34m(self, cell_specimen_ids)\u001b[0m\n\u001b[1;32m 710\u001b[0m \u001b[39mfor\u001b[39;00m i \u001b[39min\u001b[39;00m inds:\n\u001b[1;32m 711\u001b[0m v \u001b[39m=\u001b[39m roi_list[i]\n\u001b[0;32m--> 712\u001b[0m roi_mask \u001b[39m=\u001b[39m mask_loc[v][\u001b[39m\"\u001b[39;49m\u001b[39mimg_mask\u001b[39;49m\u001b[39m\"\u001b[39;49m][()]\n\u001b[1;32m 713\u001b[0m m \u001b[39m=\u001b[39m roi\u001b[39m.\u001b[39mcreate_roi_mask(roi_mask\u001b[39m.\u001b[39mshape[\u001b[39m1\u001b[39m], roi_mask\u001b[39m.\u001b[39mshape[\u001b[39m0\u001b[39m],\n\u001b[1;32m 714\u001b[0m [\u001b[39m0\u001b[39m, \u001b[39m0\u001b[39m, \u001b[39m0\u001b[39m, \u001b[39m0\u001b[39m], roi_mask\u001b[39m=\u001b[39mroi_mask, label\u001b[39m=\u001b[39mv)\n\u001b[1;32m 715\u001b[0m roi_array\u001b[39m.\u001b[39mappend(m)\n",
"File \u001b[0;32mh5py/_objects.pyx:54\u001b[0m, in \u001b[0;36mh5py._objects.with_phil.wrapper\u001b[0;34m()\u001b[0m\n",
"File \u001b[0;32mh5py/_objects.pyx:55\u001b[0m, in \u001b[0;36mh5py._objects.with_phil.wrapper\u001b[0;34m()\u001b[0m\n",
"File \u001b[0;32m/usr/lib/python3.10/site-packages/h5py/_hl/dataset.py:741\u001b[0m, in \u001b[0;36mDataset.__getitem__\u001b[0;34m(self, args, new_dtype)\u001b[0m\n\u001b[1;32m 739\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_fast_read_ok \u001b[39mand\u001b[39;00m (new_dtype \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m):\n\u001b[1;32m 740\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 741\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_fast_reader\u001b[39m.\u001b[39;49mread(args)\n\u001b[1;32m 742\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mTypeError\u001b[39;00m:\n\u001b[1;32m 743\u001b[0m \u001b[39mpass\u001b[39;00m \u001b[39m# Fall back to Python read pathway below\u001b[39;00m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
"source": [
"masks = dict()\n",
"broken_exps = []\n",
"for cell_id in cell_ids:\n",
" if masks.get(cell_id) is None:\n",
" exp_id = get_noise_exp_for_cell(cell_id)['id']\n",
" if exp_id in broken_exps:\n",
" continue\n",
" try:\n",
" exp = boc.get_ophys_experiment_data(exp_id)\n",
" except:\n",
" broken_exps.append(exp_id)\n",
" continue\n",
" cell_ids_exp = exp.get_cell_specimen_ids()\n",
" masks_for_exp = exp.get_roi_mask(cell_specimen_ids=cell_ids_exp)\n",
" for i, cell_id_ in enumerate(cell_ids_exp):\n",
" masks[cell_id_] = masks_for_exp[i].get_mask_plane()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"import pickle\n",
"with open('masks.pkl', 'wb') as f:\n",
" pickle.dump(masks, f)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"6264"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(masks)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"42"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"exp_cont_ids_masks = list(set([get_cell(k)['experiment_container_id'] for k in masks]))\n",
"len(exp_cont_ids_masks)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"roi_centers = {cell_id: np.unravel_index(np.argmax(masks[cell_id], axis=None), masks[cell_id].shape) for cell_id in masks}"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.collections.PathCollection at 0x7fef260a9c90>"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAArJ0lEQVR4nO2df4xe1Xnnvw/jgQw0y/DDtZwxjqmCbDXNYodRIHL+gMkmJjgNViCh3aillSX/sekq0MplsrvaNKtKmQipTqKtonqXqmSXDU5wYihkl7DYqFproZ2Jza9ihBvjwJTETrDpFhsY28/+8d7Xef3O/XHuvefHc859PpLl971z58655z7nOc+vcy4xMxRFUZR0OS90AxRFURS3qKJXFEVJHFX0iqIoiaOKXlEUJXFU0SuKoiTOktANAIDLL7+cV61aFboZiqIoUTE3N/dzZl5adZ4IRb9q1SrMzs6GboaiKEpUENFhk/M0dKMoipI4qugVRVESRxW9oihK4hgpeiJ6mYieJaL9RDSbHbuUiB4jopey/y/JjhMRfYOIDhLRM0T0QZc3oCiKopRTx6K/gZnXMvNk9n0awOPMfBWAx7PvAPAJAFdl/7YA+KatxiqKoij1aVN1czOA67PP9wJ4AsBd2fFvcW+3tCeJaJyIljPza20aqoRh17553P3oi/jH4yfxnvExbN2wGpvWTYRulqIoNTBV9Azgh0TEAP6CmbcDWDagvH8KYFn2eQLAKwO/+2p27BxFT0Rb0LP4sXLlymatV5yya988vvi9Z3Fy4TQAYP74SXzxe88CgCp7x+gEq9jEVNF/hJnniehXATxGRAcGf8jMnE0CxmSTxXYAmJyc1L2SBXL3oy+eVfJ9Ti6cxt2PvqhKxyE6wepEZxujGD0zz2f/HwHwfQAfAvAzIloOANn/R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MvmWkkdQqiHO2b/EN5OTkzw7Oxu6GYrSCluKL2/30bHRESfeUdO/5bONSjFENMfMk1XnaehGUSxgs8zWZwisaUms9FLaGPC5B46GbhJF3Wq/2E6g+gqBNc0HSMojxIjvyipji56IRohoHxE9nH2/koieIqKDRLSDiM7Pjl+QfT+Y/XyV9VYrpUhdxCVhFz9XSFR8Jv3ddBGZlMVnseLbI6oTuvkCgBcGvn8VwDZmfh+AYwA2Z8c3AziWHd+Wnad4RKJbLXXysYU0xWfa302rarQapx2+DQMjRU9EKwBsBPBfs+8EYArAA9kp9wLYlH2+OfuO7Ocfzc5XPFEkLEXvj/WB68kntLcgTfGZ9ndZPqCsT7WUth2+DQPTGP3XAPwxgHdn3y8DcJyZT2XfXwXQf8ITAF4BAGY+RURvZOf/fPCCRLQFwBYAWLlyZcPmx0mol09T9rdDDEaXFoyElaTSymzr9HdePsB0S2dV7M3wvbiwUtET0ScBHGHmOSK63tYfZubtALYDvfJKW9eVTtkAAuwoiq0bVuPOHfsx3KmcXd/l4CyaxFzWhktZSSpJ8bXt76I+vUN3sLSCb8PAxKJfD+BTRHQTgHcB+BcAvg5gnIiWZFb9CgB9v24ewBUAXiWiJQAuBvAL6y2PlKIB9OW/fh5vLZyxYpVuWjeBO3bsz/2Zy+Rg2STm0oJx4S3EXrXUtr/L+k7a9tOx4tMwqIzRM/MXmXkFM68C8FsAdjPz5wDsAXBrdtrtAB7MPj+UfUf2890sYVWWEIoG0LETC1Zj2BMBkoNVlrWrmK7teGcKieO2/V3Vd6GT+0o92tTR3wXgfiL6UwD7ANyTHb8HwH8jooMAXkdvclAyilzqIppapSE2GKuyrF1ZMLbvVUooKI86nkab/s7r02Gk1MzH7n35oJaiZ+YnADyRff4xgA/lnPMWgM9YaFuSFCmlC5ach+MnFxadn2d
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"roi_cent_values = np.array([roi_centers[k] for k in first_cell_ids])\n",
"plt.scatter(roi_cent_values[:, 0], roi_cent_values[:, 1])"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(254, 254, 17546, 17546, 254)"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(first_cell_ids), len(roi_cent_values), len(cell_ids), len(cells), len(exp_1.get_cell_specimen_ids())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Split cells into groups**\n",
"\n",
"Probably take regions with high concentrations and work only with them"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"s = 75\n",
"s_x, s_y = masks[cell_ids[0]].shape[0] // s + 1, masks[cell_ids[0]].shape[1] // s + 1\n",
"# grid = np.array([[x, y] for x in np.arange(0, masks[cell_ids[0]].shape[0], s) for y in np.arange(0, masks[cell_ids[0]].shape[1], s)])"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"cells_by_exp_and_region = [[[[] for _ in range(s_y)] for _ in range(s_x)] for cont_id in exp_cont_ids_masks]\n",
"for i, cell in enumerate(cells):\n",
" if cell['cell_specimen_id'] not in masks:\n",
" continue\n",
" x, y = roi_centers[cell['cell_specimen_id']]\n",
" exp_id_cell = cell['experiment_container_id']\n",
" exp_id_cell = exp_cont_ids_masks.index(exp_id_cell)\n",
" cells_by_exp_and_region[exp_id_cell][x // s][y // s].append(cell)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(16, 16)"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"max_cells_exp_i = np.argmax([np.max([len(cells_by_exp_and_region[i][x][y]) for x in range(s_x) for y in range(s_y)]) for i in range(len(exp_cont_ids_masks))])\n",
"max_exp_id = exp_cont_ids_masks[max_cells_exp_i]\n",
"chosen_i, chosen_j = np.unravel_index(np.argmax([[len(cells_by_exp_and_region[max_cells_exp_i][x][y]) for x in range(s_x) for y in range(s_y)]]), [s_x, s_y])\n",
"cells_chosen = cells_by_exp_and_region[max_cells_exp_i][chosen_i][chosen_j]\n",
"np.max([len(cells_by_exp_and_region[max_cells_exp_i][x][y]) for x in range(s_x) for y in range(s_y)]), len(cells_chosen)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(array([100, 100]), 21)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"num_cells_first = [sum(x <= roi_centers[k][0] < x + s and y <= roi_centers[k][1] < y + s for k in first_cell_ids if k in roi_centers) for x, y in grid]\n",
"i_max = np.argmax(num_cells_first)\n",
"grid[i_max], num_cells_first[i_max]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"x, y = grid[i_max]\n",
"cells_1 = [cell_id for cell_id in first_cell_ids if x <= roi_centers[cell_id][0] < x + s and y <= roi_centers[cell_id][1] < y + s]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Static gratings"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"from allensdk.brain_observatory.static_gratings import StaticGratings"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"exp_ch_gratings = exp_gratings[cont_ids_gratings.index(max_exp_id)]\n",
"exp_ch_gratings = boc.get_ophys_experiment_data(exp_ch_gratings['id'])\n",
"exp_ch_gratings_ = StaticGratings(exp_ch_gratings)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"12"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ch_cells_inds = exp_ch_gratings.get_cell_specimen_indices([c['cell_specimen_id'] for c in cells_chosen if c['cell_specimen_id'] in exp_ch_gratings.get_cell_specimen_ids()])\n",
"len(ch_cells_inds)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"resp_gr = exp_ch_gratings_.get_response()"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(6, 6, 4, 360, 3)"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"resp_gr.shape"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[310, 8, 246, 269, 272, 118, 337, 356, 120, 273, 3, 45]"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ch_cells_inds"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9d04e18ae1db421c8e3fef87772a9ae7",
"version_major": 2,
"version_minor": 0
},
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA2AAAAOoCAYAAAC3KZd9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACGBklEQVR4nOzde9yldV3v/9fbGY6DMCAHcQYFFFH0p4aj4u4gYTvRNNj7588NWpJRs1MyLbemdqDssNPame7UoqTBcqOGGlRaEqJsS7ABFUEkRjwwiEwGIgflMHx+f6xrcHE7M8zc67qva61rvZ6Px/241/W9rrXuz5e57zfrs65Tqgppa5IUcERVbRgb+w3gUVX1Ezv5WscCf1VVq7ezTYDfA36mGfpz4LXlL6k0d3rInx8Gfh04Gri5qg7d+aolzboesufVwCnAI4BvAG+vqt/f+co1Sx7UdwHSmLXAicATgScAzwP+e58FSZobtwNnAq/uuxBJcyXAi4F9geOBn09yUr8laanZgGnRkhybZGOSVyXZlOSGJC8ZW78uyW8nWQF8GHhYktuar4dt5SVPAf5XVW2squuB/wX8VCeTkTRT2s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U6mt7Nl9t304/IPfabm67j35mpf2XUIrHvK5O/ouoRW7fOXf+y6hJZ/ou4DvMRV7wJL8FPBc4EVVVc3w9cAhY5utbsa+R1WdUVVrqmrNshXDeMMvqRtt5s+uK/dY0lolDUeb2bPLLr73kWZJ7w1YkuOB1wA/XlXjHxmcB5yUZLckhwFHAJ/qo0ZJw2T+SOqD2SPNt04PQUxyNnAssH+SjcDpjK78sxtwfhKAi6vq56rqyiTvY3TU1D3AaVW1uct6JQ2H+SOpD2aPpIU
"text/html": [
"\n",
" <div style=\"display: inline-block;\">\n",
" <div class=\"jupyter-widgets widget-label\" style=\"text-align: center;\">\n",
" Figure\n",
" </div>\n",
" <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA2AAAAOoCAYAAAC3KZd9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAACGBklEQVR4nOzde9yldV3v/9fbGY6DMCAHcQYFFFH0p4aj4u4gYTvRNNj7588NWpJRs1MyLbemdqDssNPame7UoqTBcqOGGlRaEqJsS7ABFUEkRjwwiEwGIgflMHx+f6xrcHE7M8zc67qva61rvZ6Px/241/W9rrXuz5e57zfrs65Tqgppa5IUcERVbRgb+w3gUVX1Ezv5WscCf1VVq7ezTYDfA36mGfpz4LXlL6k0d3rInx8Gfh04Gri5qg7d+aolzboesufVwCnAI4BvAG+vqt/f+co1Sx7UdwHSmLXAicATgScAzwP+e58FSZobtwNnAq/uuxBJcyXAi4F9geOBn09yUr8laanZgGnRkhybZGOSVyXZlOSGJC8ZW78uyW8nWQF8GHhYktuar4dt5SVPAf5XVW2squuB/wX8VCeTkTRT2s6fqvpUVf0lcG2H05A0Y5Yge95UVZdV1T1VdTVwLvD93c1IfbAB06QeCuwDrAJOBd6WZN/xDarqduDZwNeqaq/m62tbea3HAZ8dW/5sMyZJW9Nm/kjS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tt5s+uK/dY0lolDUeb2bPLLr73kWZJ7w1YkuOB1wA/XlXjHxmcB5yUZLckhwFHAJ/qo0ZJw2T+SOqD2SPNt04PQUxyNnAssH+SjcDpjK78sxtwfhKAi6vq56r
" </div>\n",
" "
],
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, axs = plt.subplots(4, 3, figsize=(12, 13))\n",
"fig.tight_layout(w_pad=2)\n",
"for i, ax in enumerate(axs.flatten()):\n",
" ax.imshow(resp_gr[:, :, :, i, 0].mean(axis=0), extent=(0, 360, 0, 180), aspect=2)\n",
" ax.set(xlabel=\"phase\", ylabel=\"orientation\", title=f\"Unit {i}\")\n",
"# plt.imshow(resp_gr[:, :, :, 0, 0].mean(axis=2))"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((4, 6, 6, 12), (144, 12))"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"resp_gr_ = np.array([resp_gr[:, :, :, i, 0] for i in ch_cells_inds]).swapaxes(0, 3)\n",
"resp_gr_flat = resp_gr_.reshape((-1, resp_gr_.shape[-1]))\n",
"resp_gr_.shape, resp_gr_flat.shape"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"orientation 150.00\n",
"spatial_frequency 0.32\n",
"phase 0.75\n",
"start 113616.00\n",
"end 113623.00\n",
"dtype: float64"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"exp_ch_gratings_.stim_table.max()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"stim_table = np.array([[[(ori, freq, ph) for ph in np.linspace(0, 0.75, 6)] for freq in np.linspace(0, 0.32, 6)] for ori in np.linspace(0, 150, 4)]).reshape((-1, 3))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(121, 12)"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nan_filt = ~np.isnan(resp_gr_flat).any(axis=1)\n",
"stim_ori, stim_ph, stim_freq = stim_table[nan_filt, 0], stim_table[nan_filt, 2], stim_table[nan_filt, 1]\n",
"resp_gr_flat = resp_gr_flat[nan_filt, :]\n",
"resp_gr_flat.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Get activity for natural images"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"exp_ch_scenes = exp_scenes[cont_ids_scenes.index(max_exp_id)]\n",
"exp_ch_scenes = boc.get_ophys_experiment_data(exp_ch_scenes['id'])"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"from allensdk.brain_observatory.natural_scenes import NaturalScenes"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"exp_ch_scenes_ = NaturalScenes(exp_ch_scenes)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"resp_nat = exp_ch_scenes_.get_response()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(119, 360, 3)"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"resp_nat.shape"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(exp_ch_scenes.get_cell_specimen_ids() == exp_ch_gratings.get_cell_specimen_ids()).all()"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(11, 21)"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ids_exp_1 = exp_1.get_cell_specimen_ids()\n",
"cells_1_inds = [i for i in range(len(ids_exp_1)) if ids_exp_1[i] in cells_1]\n",
"len(cells_1_inds), len(cells_1)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(119, 12)"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"activity_1 = np.array([resp_nat[:, i, 0] for i in ch_cells_inds]).swapaxes(0, 1)\n",
"activity_1.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### UMAP and stuff"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/lib/python3.10/site-packages/numba/core/cpu.py:97: UserWarning: Numba extension module 'awkward._connect._numba' failed to load due to 'AttributeError(module 'setuptools' has no attribute 'extern')'.\n",
" numba.core.entrypoints.init_all()\n"
]
}
],
"source": [
"from umap import UMAP"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"ncomp_umap = 4\n",
"embed = UMAP(n_components=ncomp_umap, n_neighbors=60, metric='euclidean').fit_transform(np.concatenate((activity_1, resp_gr_flat)))\n",
"embed_nat, embed_gr = embed[:len(activity_1), :], embed[len(activity_1):, :]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"embed_nat, embed_gr = embed[:len(activity_1), :], embed[len(activity_1):, :]"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "df41ebbc089842b1be9cc9a778290f17",
"version_major": 2,
"version_minor": 0
},
"image/png": "iVBORw0KGgoAAAANSUhEUgAABaAAAALQCAYAAABmJdeHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXR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UEADQAAAAAAAAAoCgJoAAAAAAAAAEBREEADAAAAAAAAAIqCABoAAAAAAAAAUBQE0AAAAAAAAACAoiCABgAAAAAAAAAUBQE0AAAAAAAAAKAoCKABAAAAAAAAAEVBAA0AAAAAAAAAKAoCaAAAAAAAAABAURBAAwAAAAAAAACKggAaAAAAAAAAAFAUBNAAAAAAAAAAgKIggAYAAAAAAAAAFAUBNAAAAAAAAACgKAigAQAAAAAAAABFQQANAAAAAAAAACgKAmgAAAAAAAAAQFEQQAMAAAAAAAAAioIAGgAAAAAAAABQFATQAAAAAAAAAICi8Eo9AADA1LLWKpPJyHEcua4rx3FkjCn1sAAAAKa1MAyVyWTked6hORgAADMBATQAzCC+78v3faXT6UOPGWMUiUQOuxkikAYAACgMa+1hc7CReZbjOEfNwQAAmI4IoAFgBhh942OMkeu6stbKGCNrrbLZrDKZjKTXb4YikYhc15UxhkAaAADgJIzMs8IwlKRDcytr7aFdaUfOwQikAQDTDQE0AExzYRgql8spDMMxw+SRQHrE6EDaGCPHceR5HoE0AADABIy8+T/ypv9oR86nxgqkXdc9NP/yPI/5FwCgYhFAA8A0Za1VEATK5XKSNO5VNKMDaWutJCmbzSqbzR46z+hAmtU5AAAArzty59nIXGlkXjWWsQLpMAwPK5s2Eki
"text/html": [
"\n",
" <div style=\"display: inline-block;\">\n",
" <div class=\"jupyter-widgets widget-label\" style=\"text-align: center;\">\n",
" Figure\n",
" </div>\n",
" <img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABaAAAALQCAYAAABmJdeHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOzdd3gc133v/8+ZmS3ovbD3qi5RvVpdtmVZknuPE9tx4ti5+SXXcZJ77dwbXye+yU117DiJu+PeJFuS1a1eqE5KlNh7QQd2F1tm5vz+WIICSZAEiF3s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AAAFAUBNAAAAAAAAAAgKIggAYAAAAAAAAAFAUBNAAAAAAAAACgKAigAQAAAAAAAABFQQANAAAAAAAAACgKAmgAAAAAAAAAQFEQQAMAAAAAAAAAioIAGgAAAAAAAABQFATQAAAAAAAAAICi8Eo9AADA1LLWKpPJyHEcua4rx3FkjCn1sAAAAKa1MAyVyWTked6hORgAADMBATQAzCC+78v3faXT6UOPGWMUiUQOuxkikAYAACgMa+1hc7CReZbjOEfNwQAAmI4IoAFgBhh942OMkeu6stbKGCNrrbLZrDKZjKTXb4YikYhc15UxhkAaAADgJIzMs8IwlKRDcytr7aFdaUfOwQikAQDTDQE0AExzYRgql8spDMMxw+SRQHrE6EDaGCPHceR5HoE0AADABIy8+T/ypv9oR86nxgqkXdc9NP/yPI/5FwCgYhFAA8A0Za1VEATK5XKSNO5VNKMDaWutJCmbzSqbzR46z+hAmtU
" </div>\n",
" "
],
"text/plain": [
"Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from mpl_toolkits import mplot3d\n",
"from mpl_toolkits.mplot3d import Axes3D\n",
"\n",
"%matplotlib inline\n",
"%matplotlib widget\n",
"\n",
"# x, y, z, u = embed[:,0], embed[:,1], embed[:,2], embed[:,3] \n",
"\n",
"fig, ax = plt.subplots(1, 1, figsize=(20, 10))\n",
"# ax.scatter3D(x, y, z, c=np.array([param_corr[:, 0] / 180, [0] * param_corr.shape[0], param_corr[:, 1] / 360]).swapaxes(0, 1))\n",
"ax = fig.add_subplot(1, 2, 1, projection='3d')\n",
"ax.scatter3D(embed_gr[:,0], embed_gr[:,1], embed_gr[:,2], c=stim_freq)\n",
"ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U2\", xticks=[], yticks=[], zticks=[])\n",
"ax = fig.add_subplot(1, 2, 2, projection='3d')\n",
"ax.scatter3D(embed[:,0], embed[:,1], embed[:,2], c=[1] * len(activity_1) + list(0 * stim_ph))\n",
"ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U2\", xticks=[], yticks=[], zticks=[])\n",
"# ax = fig.add_subplot(2, 2, 3, projection='3d')\n",
"# ax.scatter3D(x, y, u, c=param_corr[:, 0], cmap=\"hsv\")\n",
"# ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U3\", xticks=[], yticks=[], zticks=[])\n",
"# ax = fig.add_subplot(2, 2, 4, projection='3d')\n",
"# ax.scatter3D(x, y, u, c=param_corr[:, 1], cmap=\"hsv\")\n",
"# ax.set(xlabel=\"U0\", ylabel=\"U1\", zlabel=\"U3\", xticks=[], yticks=[], zticks=[])\n",
"fig.suptitle('UMAP 3D')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Persistence"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from persistence import persistence"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA/4AAAM+CAYAAACjdNp5AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdd3hT1RvA8W+60gFtGW1ZhbL3RhAB2VaWFFSmTAERUBRR2QjaoiLIT0FQUFARARFQGWXvKVOQ1QJlFMpuCy1N1/39cW3aNEln2nS8n+fJAzk5996TtD25773nvEejKIqCEEIIIYQQQgghCiQbazdACCGEEEIIIYQQOUcCfyGEEEIIIYQQogCTwF8IIYQQQgghhCjAJPAXQgghhBBCCCEKMAn8hRBCCCGEEEKIAkwCfyGEEEIIIYQQogCTwF8IIYQQQgghhCjAJPAXQgghhBBCCCEKMAn8hRBCCCGEEEKIAqxABv4ajYaPPvrI2s2wutmzZ1OpUiVsbW1p0KCBt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ZMAZTWrVvry3bt2qUASqVKlZTo6GiD/cTExCgJCQkGZVevXlW0Wq0yc+ZMfdnff/+tAMrSpUtNvu+UP8erV68qgFKiRAnl4cOH+vI//vhDAZS//vpLX1a3bl2lXLlyyuPHj/Vlu3fvVgCDfY4dO1ZxdXVV4uPj0/1s0pP0t5MVGf19S/05K4qiHDp0SAGUn376SV/222+/KYCya9cuk8dK+TeVpEK
"text/plain": [
"<Figure size 1000x1000 with 6 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(2, 3, figsize=(10, 10))\n",
"fig.tight_layout(w_pad=3)\n",
"ax = ax.flatten()\n",
"ax[0].set_title('Persistence for gratings + natural scenes')\n",
"persistence(embed, ax=ax[0])\n",
"ax[1].set_title('Persistence for gratings')\n",
"persistence(embed_gr, ax=ax[1])\n",
"ax[2].set_title('Persistence for natural scenes')\n",
"persistence(embed_nat, ax=ax[2])\n",
"ax[3].set_title('Persistence for natural scenes, coeff=3')\n",
"persistence(embed_nat, coeff=3, ax=ax[3])\n",
"ax[4].set_title('Persistence for natural scenes, homdim=2')\n",
"persistence(embed_nat, homdim=2, ax=ax[4])\n",
"ax[5].set_title('Persistence for gratings, homdim=2')\n",
"persistence(embed_gr, homdim=2, ax=ax[5])"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAbgAAAHHCAYAAADNvk2nAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABkdklEQVR4nO3deVhUZf8G8HsYmGEHQVlFEdw3SNytgMLc0rRMs15FS63USmnTFtdcKlNbNFPLpSwXXrVU0tTkNdMyxfXnLuKMKKAiu2wz5/fHxMgwA7LMzBlm7s91cb0vD88553vQ5vac85znkQiCIICIiMjK2IldABERk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evSrI5XJh9uzZ2rZ//vlHACCsXr3a4HmX/3O8evWqAEDw9vYWMjMzte0///yzAEDYvn27tq1Dhw5C48aNhdzcXG1bYmKiAEBnn2+88Ybg7u4ulJaWPvB3Q+bFW5RkMjExMWjUqBGCgoLw3HPPwdXVFVu3bkVgYCC2bNkCtVqNYcOG4fbt29ovPz8/tGjRAvv379fZl1wux5gxY3Tayq7wduzYgZKSkmrX5enpib///hs3btyo8Tlt3rwZbdq0QevWrXXqLrv9WrHumJgYhIaGar/v2LEj3N3dkZycDEBzRbht2zYMHDhQ+7yyPIlEoj3uI488ggYNGugcNyYmBiqVCgcOHKjxuSQkJAAA4uLidNrffPNNAJormPKaNWuGPn36PHC/R48exZ07dzBu3DidwT0vvPACGjRoYHCb2NhYved5crlc+xxOpVLhzp07cHV1RatWrbS3k2tr+PDhOrWUXfmV/bncuHEDp0+fxqhRo7RX7wAQGRmJDh066OzL09MT+fn52LNnT51qIuPjLUoymaVLl6Jly5awt7eHr68vWrVqpf3AunTpEgRBQIsWLQxuW3FwQGBgoN4AicjISDzzzDOYNWsWFi9ejKioKAwePBjPP/885HJ5pXV98skniI2NRVBQECIiItC/f3+MGjUKISEhDzynS5cu4dy5c2jUqJHBn2dkZOh836RJE70+DRo0wN27dwEAt27dQk5ODtq3b//A4546darax62Oa9euwc7ODs2bN9dp9/Pzg6enJ65du6bT3qxZs2rvF4Defu3t7St9J83QvtVqNT7//HMsW7YMV69ehUql0v6s7PZubVX8cykLu7I/l8rOoaytfMBOmDABmzZtQr9+/RAYGIgnnngCw4YNQ9++fetUI9UdA45MpmvXrgavSgDNh5dEIsGvv/4KqVSq9/Py/2oGYHC0nkQiQXx8PP766y9s374du3fvxosvvojPPvsMf/31l94+ygwbNgyPPPIItm7dit9++w2ffvopPv74Y2zZsgX9+vWr8pzUajU6dOiARYsWGfx5UFCQzveGzg3QjEKsCbVajd69e+Odd94x+POWLVvWaH/llV0lPogpRkxWte958+bhww8/xIsvvog5c+bAy8sLdnZ2mDx5cp2H/hvrzwUAfHx8cOLECezevRu//vorfv31V6xevRqjRo3C2rVr61Qn1Q0DjkQRGhoKQRDQrFmzOn04A0D37t3RvXt3zJ07Fz/++CNeeOEFbNiwAWPHjq10G39/f0yYMAETJkxARkYGOnXqhLlz52oDrrIP/dDQUJw8eRKPP/54tYOhKo0aNYK7uzvOnDlTZb/Q0FDk5eUhJiamzscs07RpU6jValy6dAlt2rTRtqenpyMrKwtNmzat9X4B4PLly4iOjta2l5aWIiUlBR07dqzWfuLj4xEdHY1vv/1Wpz0rKwsNGzbUfm+MP4eKyp9DRYbaZDIZBg4ciIEDB0KtVmPChAn45ptv8OGHHxq8CiTz4DM4EsXTTz8
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.title('Persistence for gratings')\n",
"persistence(embed_gr)"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAcMAAAHHCAYAAADDFzPIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABmbUlEQVR4nO3deVhUZf8G8HsYmGEHQVnFBdw3UMxdgcLc0jR9Ne2naKkt+r6VLWrlVpnpa2qlZmq5VKZGaqXkmrymWaa45i7ijISgILtsM+f3x8TowAwwIzNnhrk/1zVXzcNzzvkewLk55zznPBJBEAQQERHZMQexCyAiIhIbw5CIiOwew5CIiOwew5CIiOwew5CIiOwew5CIiOwew5CIiOwew5CIiOwew5CIiOwew5BEIZFIMHfuXLHLEN1///tfhIaGQiqVIiIiQuxybBZ/n+hhMQztxPr16yGRSLQvZ2dntGjRAlOnTkV6errY5dXIpk2bsGzZMrHLqDV79+7Fm2++iZ49e2LdunX44IMPxC7JKIWFhZg7dy4SExPFLoXooTmKXQBZ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kUikWLFigvcZcHYlEovf7qVKp9PbXtx+1UceDWrdujUuXLmHnzp3YvXs3vv/+e6xcuRKzZ8/W3iJSE8b+3Kv7npcPunn99dcNHuWX/3HUp08fXLt2DT/88AP27t2LtWvXYunSpVi1ahUmTpxY432gyhiGpBUWFgZBENC0adOH+iAHgG7duqFbt26YP38
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.title('Persistence for natural scenes')\n",
"persistence(embed_nat)"
]
},
{
"cell_type": "code",
"execution_count": 75,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAcMAAAHHCAYAAADDFzPIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAA9hAAAPYQGoP6dpAABrRElEQVR4nO3deVhUZf8G8HsYmGETEJRVXMB9A8V9AwpzS9MsTfspWmqZvi2+LVq5UKnVa+pbaqamZmWapFZK7vKaZrngVm4o4IyEoCC7bDPn98fE6MAMMOOszP25rrlqHp5zzvcAzs055znnEQmCIICIiMiOOVi6ACIiIktjGBIRkd1jGBIRkd1jGBIRkd1jGBIRkd1jGBIRkd1jGBIRkd1jGBIRkd1jGBIRkd1jGNZjIpEICxYssHQZFvef//wHISEhEIvFCA8Pt3Q5Nou/T7bl5MmT6NOnD9zc3CASiXD27FkAwJ49exAeHg5nZ2eIRCLk5uZatE5rwTA0oo0bN0IkEqlfzs7OaN26NWbOnInMzExLl1cnmzdvxvLlyy1dhtHs27cPb775Jvr27YsNGzZg0aJFli5JL8XFxViwYAESExMtXQrZkPLycjz99NPIycnBsmXL8PXXX6NZs2bIzs7GmDFj4OLigpUrV+Lrr7+Gm5ubwdtZu3YtIiMj4efnB6lUihYtWmDy5MlIS0sz3s6YiaOlC6iP3nvvPbRo0QIlJSU4evQoPv/8cyQkJODPP/+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D5sdt5b4eOHAAZWVlePXVVzX6TJ06FR4
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.title('Persistence for natural scenes, coeff=3')\n",
"persistence(embed_nat, coeff=3)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.5"
},
"vscode": {
"interpreter": {
"hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}