{ "cells": [ { "cell_type": "markdown", "id": "7256704a-f9d1-4c3e-9ecc-638edbf2f1f9", "metadata": {}, "source": [ "# Statistics\n", "\n", "This notebook shows show the do some basic statistics on Neuropixels `ChannelMap` and its blueprint." ] }, { "cell_type": "markdown", "id": "921caa08-2269-4da0-9cc8-1b6ce2b6e4ed", "metadata": {}, "source": [ "## Number of selected electrodes\n", "\n", "For a channelmap" ] }, { "cell_type": "code", "execution_count": 5, "id": "c083f032-a2d3-4ac9-945b-8ca8da728236", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from neurocarto.probe_npx import ChannelMap\n", "\n", "chmap = ChannelMap(24)\n", "len(chmap) # empty map" ] }, { "cell_type": "code", "execution_count": 10, "id": "d2a6a7df-f4ef-48d6-a5f7-c25633c4d347", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "chmap.add_electrode((0,0,0))\n", "len(chmap)" ] }, { "cell_type": "markdown", "id": "e382835d-6f7c-4137-899a-bff5cb10e853", "metadata": {}, "source": [ "For a blueprint" ] }, { "cell_type": "code", "execution_count": 11, "id": "4862e95a-fe6e-4967-bd39-0a9694fea459", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from neurocarto.probe_npx import NpxProbeDesp\n", "\n", "D = NpxProbeDesp()\n", "\n", "# all electrodes, chmap here used as a probe type reference, we do not use its content inside.\n", "blueprint = D.all_electrodes(chmap)\n", "len([e for e in blueprint if e.state == D.STATE_USED])" ] }, { "cell_type": "code", "execution_count": 13, "id": "a2234e64-5896-48ce-b62f-9c3918adc931", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Get selected electrodes\n", "# This function will read the content of chmap\n", "len(D.all_channels(chmap))" ] }, { "cell_type": "markdown", "id": "c67a834c-4c43-4e08-8667-38687690f981", "metadata": {}, "source": [ "## Number of electrode set with full-density category" ] }, { "cell_type": "code", "execution_count": 16, "id": "c31ff57c-18c3-42e8-9979-6913d87808ab", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "66" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "blueprint = D.load_blueprint('Fig3_example.blueprint.npy', chmap)\n", "\n", "len([e for e in blueprint if e.category == D.CATE_FULL])" ] }, { "cell_type": "markdown", "id": "d8a2b16b-0c0f-4f13-afd3-77876fa086a4", "metadata": {}, "source": [ "## Area Efficiency\n", "\n", "we define the area efficiency $Aeff$ of a given blueprint $Q$ and its outcomes channel map $S$ as\n", "\n", "$Aeff(S|Q) = \\cfrac{selected(S|Q)}{request(Q)}$, $0$ if $request(Q)=0$ \n", "\n", "Where $selected$ and $request$ are defined below:" ] }, { "cell_type": "code", "execution_count": 18, "id": "21f5c7d1-ee78-43c3-ac0e-7a8b9aafbf68", "metadata": {}, "outputs": [], "source": [ "def selected(S, Q):\n", " \"\"\"How many electrodes are selected in density-category.\"\"\"\n", " # we do not use S here, because Q contains the selecting information.\n", " v1 = len([e for e in Q if e.state == D.STATE_USED and e.category == D.CATE_SET])\n", " v2 = len([e for e in Q if e.state == D.STATE_USED and e.category == D.CATE_FULL])\n", " v3 = len([e for e in Q if e.state == D.STATE_USED and e.category == D.CATE_HALF])\n", " v4 = len([e for e in Q if e.state == D.STATE_USED and e.category == D.CATE_QUARTER])\n", " return v1 + v2 + v3 + v4\n", "\n", "def request(Q):\n", " \"\"\"How many electrodes are requested in density-category.\"\"\"\n", " v1 = len([e for e in Q if e.category == D.CATE_SET])\n", " v2 = len([e for e in Q if e.category == D.CATE_FULL])\n", " v3 = len([e for e in Q if e.category == D.CATE_HALF])\n", " v4 = len([e for e in Q if e.category == D.CATE_QUARTER])\n", " return v1 + v2 + v3/2 + v4/4" ] }, { "cell_type": "markdown", "id": "8a0f5c09-323c-486e-8000-613c31855417", "metadata": {}, "source": [ "When $Aeff < 1$ , it means area are not well used on average. When $Aeff > 1$ , it means area are over-used on average." ] }, { "cell_type": "markdown", "id": "37ac4df0-2045-4a25-827e-7a67cb9ef06f", "metadata": {}, "source": [ "## Channel Efficiency\n", "\n", "We define the channel efficiency $Ceff$ of a given blueprint $Q$ and its outcomes channel map $S$ as\n", "\n", "$Ceff(S|Q) = min \\{ Aeff(S|Q), \\cfrac{1}{Aeff(S|Q)} \\}$, $0$ if $Aeff(S|Q) = 0$" ] }, { "cell_type": "markdown", "id": "6730b582-5da9-445b-8ced-113385cdf5c5", "metadata": {}, "source": [ "We define the channel efficiency $Ceff$ of a blueprint $Q$ as\n", "\n", "$Ceff(Q) = max \\{ Ceff(S|Q) | S \\in \\mathcal{S} \\}$\n", "\n", "where $\\mathcal{S}$ is all possible outcomes from the given blueprint $Q$." ] } ], "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.13" } }, "nbformat": 4, "nbformat_minor": 5 }