{ "metadata": { "language_info": { "mimetype": "text/x-python", "file_extension": ".py", "name": "python", "version": "3.6.4", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "codemirror_mode": { "version": 3, "name": "ipython" } }, "kernelspec": { "language": "python", "display_name": "Python 3", "name": "python3" }, "celltoolbar": "Raw Cell Format" }, "cells": [ { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ ".. _neuronlist_math:\n", "\n", "NeuronList math\n", "***************\n", ":class:`~pymaid.CatmaidNeuronList` implement some of the basic arithmetic and comparison operators that you might know from standard ``lists`` or ``numpy.arrays``. Most this should be fairly intuitive (I hope) but there are a few things you should be aware of. The following examples will illustrate that:" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "As per usual, we need to get some neurons first (I'm assuming you've already imported and setup pymaid):" ] }, { "outputs": [ { "data": { "text/plain": [ " neuron_name skeleton_id n_nodes n_connectors \\\n", "0 PN glomerulus DA1 57316 ML 2863105 2863104 5222 439 \n", "1 PN glomerulus DA1 57382 ML 57381 7730 360 \n", "2 PN glomerulus DA1 61222 AJ 61221 7875 534 \n", "3 PN glomerulus DA1 57354 GA 57353 4898 327 \n", "4 PN glomerulus DA1 57324 LK JSL 57323 4585 438 \n", "\n", " n_branch_nodes n_end_nodes open_ends cable_length review_status soma \n", "0 149 157 63 1109.886700 NA True \n", "1 153 162 71 1215.920600 NA True \n", "2 135 140 26 1182.642823 NA True \n", "3 90 95 52 1113.156682 NA True \n", "4 120 127 59 1035.099284 NA True " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
neuron_nameskeleton_idn_nodesn_connectorsn_branch_nodesn_end_nodesopen_endscable_lengthreview_statussoma
0PN glomerulus DA1 57316 ML 286310528631045222439149157631109.886700NATrue
1PN glomerulus DA1 57382 ML573817730360153162711215.920600NATrue
2PN glomerulus DA1 61222 AJ612217875534135140261182.642823NATrue
3PN glomerulus DA1 57354 GA5735348983279095521113.156682NATrue
4PN glomerulus DA1 57324 LK JSL573234585438120127591035.099284NATrue
\n", "
" ] }, "execution_count": 1, "output_type": "execute_result", "metadata": {} } ], "execution_count": 1, "metadata": { "scrolled": true }, "cell_type": "code", "source": [ "nl = pymaid.get_neurons('annotation:glomerulus DA1 right')\n", "nl.head()" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "Comparisons\n", "-----------\n", "The ``==`` operator compares two elements:" ] }, { "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 2, "output_type": "execute_result", "metadata": {} } ], "execution_count": 2, "metadata": {}, "cell_type": "code", "source": [ "1 == 1" ] }, { "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 3, "output_type": "execute_result", "metadata": {} } ], "execution_count": 3, "metadata": {}, "cell_type": "code", "source": [ "2 == 1" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "For :class:`~pymaid.CatmaidNeuron` this is done by comparing the neurons' morphologies (somas, root nodes, cable length, ...) and meta data (skeleton ID, name, ...)." ] }, { "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 4, "output_type": "execute_result", "metadata": {} } ], "execution_count": 4, "metadata": {}, "cell_type": "code", "source": [ "n1 = nl[0]\n", "n2 = nl[0]\n", "n1 == n2" ] }, { "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 5, "output_type": "execute_result", "metadata": {} } ], "execution_count": 5, "metadata": {}, "cell_type": "code", "source": [ "n1 = nl[0]\n", "n2 = nl[1]\n", "n1 == n2" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "For :class:`~pymaid.CatmaidNeuronList`, we do the same comparison pairwise between neurons in both neuronlists - so order matters!." ] }, { "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 6, "output_type": "execute_result", "metadata": {} } ], "execution_count": 6, "metadata": {}, "cell_type": "code", "source": [ "nl == nl" ] }, { "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 7, "output_type": "execute_result", "metadata": {} } ], "execution_count": 7, "metadata": {}, "cell_type": "code", "source": [ "nl == nl[:-1]" ] }, { "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 8, "output_type": "execute_result", "metadata": {} } ], "execution_count": 8, "metadata": {}, "cell_type": "code", "source": [ "nl[[0, 1, 2]] == nl[[2, 1, 0]]" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "This is safe against copying but making any changes to the neurons will cause inequality:" ] }, { "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 9, "output_type": "execute_result", "metadata": {} } ], "execution_count": 9, "metadata": {}, "cell_type": "code", "source": [ "n1 = nl[0]\n", "n2 = n1.copy()\n", "n1 == n2" ] }, { "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 10, "output_type": "execute_result", "metadata": {} } ], "execution_count": 10, "metadata": {}, "cell_type": "code", "source": [ "n1 = nl[0]\n", "n2 = n1.reroot(nl[0].tags['ends'][0], inplace=False)\n", "n1 == n2" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "You can also ask if a neuron is in a given ``CatmaidNeuronList``:" ] }, { "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 11, "output_type": "execute_result", "metadata": {} } ], "execution_count": 11, "metadata": {}, "cell_type": "code", "source": [ "n1 = nl[0]\n", "n1 in nl" ] }, { "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 12, "output_type": "execute_result", "metadata": {} } ], "execution_count": 12, "metadata": {}, "cell_type": "code", "source": [ "n1 in nl[1:]" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "This also works with skeleton IDs" ] }, { "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 13, "output_type": "execute_result", "metadata": {} } ], "execution_count": 13, "metadata": {}, "cell_type": "code", "source": [ "n1.skeleton_id in nl" ] }, { "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 14, "output_type": "execute_result", "metadata": {} } ], "execution_count": 14, "metadata": {}, "cell_type": "code", "source": [ "n1.skeleton_id in nl[1:]" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "Addition\n", "--------\n", "To merge two lists in Python, you can simply add them:" ] }, { "outputs": [ { "data": { "text/plain": [ "[1, 3]" ] }, "execution_count": 15, "output_type": "execute_result", "metadata": {} } ], "execution_count": 15, "metadata": {}, "cell_type": "code", "source": [ "a = [1]\n", "b = [3]\n", "a + b" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ ":class:`~pymaid.CatmaidNeuronList` works exactly the same:" ] }, { "outputs": [ { "data": { "text/plain": [ " of 3 neurons \n", " neuron_name skeleton_id n_nodes \\\n", "0 PN glomerulus DA1 57382 ML 57381 7729 \n", "1 AL.L(DA1) -{mALT}-> CAL.L-LH.L 2379518 PN022 D... 2379517 4657 \n", "2 PN glomerulus DA1 57312 LK 57311 4882 \n", "\n", " n_connectors n_branch_nodes n_end_nodes open_ends cable_length \\\n", "0 360 153 162 71 1215.920599 \n", "1 411 86 90 31 836.067253 \n", "2 429 157 164 105 1182.102458 \n", "\n", " review_status soma \n", "0 NA True \n", "1 NA True \n", "2 NA True " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
neuron_nameskeleton_idn_nodesn_connectorsn_branch_nodesn_end_nodesopen_endscable_lengthreview_statussoma
0PN glomerulus DA1 57382 ML573817729360153162711215.920599NATrue
1AL.L(DA1) -{mALT}-> CAL.L-LH.L 2379518 PN022 D...23795174657411869031836.067253NATrue
2PN glomerulus DA1 57312 LK5731148824291571641051182.102458NATrue
\n", "
" ] }, "execution_count": 16, "output_type": "execute_result", "metadata": {} } ], "execution_count": 16, "metadata": {}, "cell_type": "code", "source": [ "a = nl[0]\n", "b = nl[[1, 2]]\n", "a + b" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "This also works on with two single :class:`~pymaid.CatmaidNeuron`! You can use that to combine them into a list:" ] }, { "outputs": [ { "data": { "text/plain": [ " of 2 neurons \n", " neuron_name skeleton_id n_nodes \\\n", "0 PN glomerulus DA1 57316 ML 2863105 2863104 5222 \n", "1 AL.L(DA1) -{mALT}-> CAL.L-LH.L 2319458 PN036 D... 2319457 10209 \n", "\n", " n_connectors n_branch_nodes n_end_nodes open_ends cable_length \\\n", "0 439 149 157 63 1109.88670 \n", "1 964 431 458 90 1747.51171 \n", "\n", " review_status soma \n", "0 NA True \n", "1 NA True " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
neuron_nameskeleton_idn_nodesn_connectorsn_branch_nodesn_end_nodesopen_endscable_lengthreview_statussoma
0PN glomerulus DA1 57316 ML 286310528631045222439149157631109.88670NATrue
1AL.L(DA1) -{mALT}-> CAL.L-LH.L 2319458 PN036 D...231945710209964431458901747.51171NATrue
\n", "
" ] }, "execution_count": 17, "output_type": "execute_result", "metadata": {} } ], "execution_count": 17, "metadata": {}, "cell_type": "code", "source": [ "a = nl[0]\n", "b = nl[1]\n", "a + b" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ ".. note::\n", " If you want to combine two CatmaidNeurons into a single neuron instead of creating a neuronlist, check out :func:`pymaid.stitch_neurons`." ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "Substraction\n", "------------\n", "To remove an item from a Python list, you would call the ``.pop()`` method:" ] }, { "outputs": [ { "data": { "text/plain": [ "[1, 2]" ] }, "execution_count": 18, "output_type": "execute_result", "metadata": {} } ], "execution_count": 18, "metadata": {}, "cell_type": "code", "source": [ "a = [1, 2, 3]\n", "b = 2\n", "a.pop(b)\n", "a" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ ":class:`~pymaid.CatmaidNeuronList` lets you simply use substraction:" ] }, { "outputs": [ { "data": { "text/plain": [ " of 2 neurons \n", " neuron_name skeleton_id n_nodes \\\n", "0 PN glomerulus DA1 57382 ML 57381 7729 \n", "1 AL.L(DA1) -{mALT}-> CAL.L-LH.L 2379518 PN022 D... 2379517 4657 \n", "\n", " n_connectors n_branch_nodes n_end_nodes open_ends cable_length \\\n", "0 360 153 162 71 1215.920599 \n", "1 411 86 90 31 836.067253 \n", "\n", " review_status soma \n", "0 NA True \n", "1 NA True " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
neuron_nameskeleton_idn_nodesn_connectorsn_branch_nodesn_end_nodesopen_endscable_lengthreview_statussoma
0PN glomerulus DA1 57382 ML573817729360153162711215.920599NATrue
1AL.L(DA1) -{mALT}-> CAL.L-LH.L 2379518 PN022 D...23795174657411869031836.067253NATrue
\n", "
" ] }, "execution_count": 19, "output_type": "execute_result", "metadata": {} } ], "execution_count": 19, "metadata": {}, "cell_type": "code", "source": [ "a = nl[[0, 1, 2]]\n", "b = nl[2]\n", "a - b" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "Bitwise AND\n", "-----------\n", "To find the intersection between two lists, you would use ``sets`` and the ``&`` operator:" ] }, { "outputs": [ { "data": { "text/plain": [ "{2}" ] }, "execution_count": 20, "output_type": "execute_result", "metadata": {} } ], "execution_count": 20, "metadata": {}, "cell_type": "code", "source": [ "a = set([0, 1, 2])\n", "b = set([2, 3, 4])\n", "a & b" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ ":class:`~pymaid.CatmaidNeuronList` work similarly:" ] }, { "outputs": [ { "data": { "text/plain": [ " of 1 neurons \n", " neuron_name skeleton_id n_nodes n_connectors \\\n", "0 PN glomerulus DA1 57312 LK 57311 4882 429 \n", "\n", " n_branch_nodes n_end_nodes open_ends cable_length review_status soma \n", "0 157 164 105 1182.102458 NA True " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
neuron_nameskeleton_idn_nodesn_connectorsn_branch_nodesn_end_nodesopen_endscable_lengthreview_statussoma
0PN glomerulus DA1 57312 LK5731148824291571641051182.102458NATrue
\n", "
" ] }, "execution_count": 21, "output_type": "execute_result", "metadata": {} } ], "execution_count": 21, "metadata": {}, "cell_type": "code", "source": [ "a = nl[[0, 1, 2]]\n", "b = nl[[2, 3, 4]]\n", "a & b" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "All of the above also work with skeleton IDs as one of the operators" ] }, { "outputs": [ { "data": { "text/plain": [ " of 1 neurons \n", " neuron_name skeleton_id n_nodes n_connectors \\\n", "0 PN glomerulus DA1 57312 LK 57311 4882 429 \n", "\n", " n_branch_nodes n_end_nodes open_ends cable_length review_status soma \n", "0 157 164 105 1182.102458 NA True " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
neuron_nameskeleton_idn_nodesn_connectorsn_branch_nodesn_end_nodesopen_endscable_lengthreview_statussoma
0PN glomerulus DA1 57312 LK5731148824291571641051182.102458NATrue
\n", "
" ] }, "execution_count": 22, "output_type": "execute_result", "metadata": {} } ], "execution_count": 22, "metadata": {}, "cell_type": "code", "source": [ "a = nl[[0, 1, 2]]\n", "b = nl[[2, 3, 4]]\n", "a & b.skeleton_id" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "Multiplication and Division\n", "---------------------------\n", "So far, all operations have led to changes in the structure of the :class:`~pymaid.CatmaidNeuronList`. Multiplication and division are **different**! If you multiply/divide a :class:`~pymaid.CatmaidNeuron` or :class:`~pymaid.CatmaidNeuronList` by a number, you will change the *coordinates* of nodes and connectors (plus node radii):" ] }, { "outputs": [ { "data": { "text/plain": [ " treenode_id parent_id creator_id x y z radius \\\n", "0 3046710 32963981 53 442883 212802 44240 -1 \n", "1 32963981 3046707 150 442931 212892 44040 -1 \n", "2 652935 652934 22 444126 151826 216240 -1 \n", "3 3245741 3245737 61 414617 243177 52400 3451 \n", "4 3042776 27298300 53 436753 225519 38000 -1 \n", "\n", " confidence type \n", "0 5 slab \n", "1 5 slab \n", "2 5 slab \n", "3 5 end \n", "4 5 slab " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
treenode_idparent_idcreator_idxyzradiusconfidencetype
03046710329639815344288321280244240-15slab
132963981304670715044293121289244040-15slab
265293565293422444126151826216240-15slab
332457413245737614146172431775240034515end
43042776272983005343675322551938000-15slab
\n", "
" ] }, "execution_count": 23, "output_type": "execute_result", "metadata": {} } ], "execution_count": 23, "metadata": {}, "cell_type": "code", "source": [ "n = nl[0]\n", "n.nodes.head()" ] }, { "outputs": [ { "data": { "text/plain": [ " treenode_id parent_id creator_id x y z radius \\\n", "0 3046710 32963981 53 442.883 212.802 44.24 -0.001 \n", "1 32963981 3046707 150 442.931 212.892 44.04 -0.001 \n", "2 652935 652934 22 444.126 151.826 216.24 -0.001 \n", "3 3245741 3245737 61 414.617 243.177 52.40 3.451 \n", "4 3042776 27298300 53 436.753 225.519 38.00 -0.001 \n", "\n", " confidence type \n", "0 5 slab \n", "1 5 slab \n", "2 5 slab \n", "3 5 end \n", "4 5 slab " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
treenode_idparent_idcreator_idxyzradiusconfidencetype
030467103296398153442.883212.80244.24-0.0015slab
1329639813046707150442.931212.89244.04-0.0015slab
265293565293422444.126151.826216.24-0.0015slab
33245741324573761414.617243.17752.403.4515end
430427762729830053436.753225.51938.00-0.0015slab
\n", "
" ] }, "execution_count": 24, "output_type": "execute_result", "metadata": {} } ], "execution_count": 24, "metadata": {}, "cell_type": "code", "source": [ "n2 = n / 1000\n", "n2.nodes.head()" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "The main use of this is to convert units from e.g. nm to um." ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "Dealing with unequal neuron objects\n", "-----------------------------------\n", "\n", "As we demonstrated earlier, making changes to ``CatmaidNeuron/Lists`` will cause comparisons to fail. This also propagates into substractions and bitwise comparisons:" ] }, { "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 25, "output_type": "execute_result", "metadata": {} } ], "execution_count": 25, "metadata": {}, "cell_type": "code", "source": [ "n1 = nl[0]\n", "n1 in nl" ] }, { "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 26, "output_type": "execute_result", "metadata": {} } ], "execution_count": 26, "metadata": {}, "cell_type": "code", "source": [ "n2 = n1.reroot(nl[0].tags['ends'][0], inplace=False)\n", "n2 in nl" ] }, { "outputs": [ { "data": { "text/plain": [ " of 1 neurons \n", " neuron_name skeleton_id n_nodes n_connectors \\\n", "0 PN glomerulus DA1 57316 ML 2863105 2863104 5222 439 \n", "\n", " n_branch_nodes n_end_nodes open_ends cable_length review_status soma \n", "0 149 157 63 1109.8867 NA True " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
neuron_nameskeleton_idn_nodesn_connectorsn_branch_nodesn_end_nodesopen_endscable_lengthreview_statussoma
0PN glomerulus DA1 57316 ML 286310528631045222439149157631109.8867NATrue
\n", "
" ] }, "execution_count": 27, "output_type": "execute_result", "metadata": {} } ], "execution_count": 27, "metadata": {}, "cell_type": "code", "source": [ "nl & n1" ] }, { "outputs": [ { "text": [ "WARNING : Skeleton IDs overlap but neuron not identical! Bitwise cancelled! Try using .skeleton_id instead. (pymaid)\n" ], "output_type": "stream", "name": "stderr" } ], "execution_count": 28, "metadata": {}, "cell_type": "code", "source": [ "nl & n2" ] }, { "metadata": { "raw_mimetype": "text/restructuredtext" }, "cell_type": "raw", "source": [ "See how the comparison fails because we've made changes? The same happens if you tried ``nl - n2``. \n", "\n", "As mentioned in the warning, the workaround is to use the skeleton ID instead:" ] }, { "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 29, "output_type": "execute_result", "metadata": {} } ], "execution_count": 29, "metadata": {}, "cell_type": "code", "source": [ "n2.skeleton_id in nl" ] }, { "outputs": [ { "data": { "text/plain": [ " of 1 neurons \n", " neuron_name skeleton_id n_nodes n_connectors \\\n", "0 PN glomerulus DA1 57316 ML 2863105 2863104 5222 439 \n", "\n", " n_branch_nodes n_end_nodes open_ends cable_length review_status soma \n", "0 149 157 63 1109.8867 NA True " ], "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
neuron_nameskeleton_idn_nodesn_connectorsn_branch_nodesn_end_nodesopen_endscable_lengthreview_statussoma
0PN glomerulus DA1 57316 ML 286310528631045222439149157631109.8867NATrue
\n", "
" ] }, "execution_count": 30, "output_type": "execute_result", "metadata": {} } ], "execution_count": 30, "metadata": {}, "cell_type": "code", "source": [ "nl & n2.skeleton_id" ] } ], "nbformat_minor": 2, "nbformat": 4 }