{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Examples of different co-plotting with flywire" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### This section contains several examples of different ways of manipulating flywire instances and co-plotting neurons, synapses as annotations" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Import neccesary library modules now" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import navis\n", "import fafbseg\n", "import pymaid" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import os\n", "from copy import deepcopy\n", "import glob" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from pyroglancer.flywire import flywireurl2dict, add_flywirelayer" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example 1: Add segments to empty config in flywire.." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "layer_kws = {'type': 'segments',\n", " 'segmentid': 720575940620589336,\n", " 'color': 'cyan','alpha': 0.8\n", " }" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "flywire url at: https://ngl.flywire.ai/?json_url=https://globalv1.flywire-daf.com/nglstate/4557723320451072\n" ] } ], "source": [ "flywireurl = add_flywirelayer(layer_kws=layer_kws)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "#add some more now..\n", "layer_kws = {'type': 'segments',\n", " 'segmentid': [720575940638461392,720575940607092337],\n", " 'color': ['yellow', 'red']}" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "flywire url at: https://ngl.flywire.ai/?json_url=https://globalv1.flywire-daf.com/nglstate/5112535262953472\n" ] } ], "source": [ "flywireurl = add_flywirelayer(flywireurl2dict(flywireurl), layer_kws)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example 2: Display neurons as annotations in flywire, that can be directly shared in short urls" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'/Users/sri/Documents/Python/pyroglancer'" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(\"__file__\")))))\n", "BASE_DIR" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "swc_path = os.path.join(BASE_DIR, 'pyroglancer/data/swc')\n", "swc_files = glob.glob(os.path.join(swc_path, '57*.swc'))" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO - 2021-05-19 23:34:11,112 - utils - NumExpr defaulting to 8 threads.\n" ] } ], "source": [ "neuronlist = []\n", "neuronlist += [navis.read_swc(f, units='8 nm', connector_labels={'presynapse': 7, 'postsynapse': 8},\n", " id=int(os.path.splitext(os.path.basename(f))[0])) for f in swc_files]\n", "neuronlist = navis.core.NeuronList(neuronlist)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<class 'navis.core.neuronlist.NeuronList'> containing 2 neurons (314.0KiB)
| \n", " | type | \n", "name | \n", "id | \n", "n_nodes | \n", "n_connectors | \n", "n_branches | \n", "n_leafs | \n", "cable_length | \n", "soma | \n", "units | \n", "
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "navis.TreeNeuron | \n", "57323 | \n", "57323 | \n", "6223 | \n", "414 | \n", "256 | \n", "268 | \n", "1483462.250 | \n", "[2579] | \n", "8 nanometer | \n", "
| 1 | \n", "navis.TreeNeuron | \n", "57311 | \n", "57311 | \n", "5543 | \n", "398 | \n", "211 | \n", "219 | \n", "1364103.125 | \n", "[3187] | \n", "8 nanometer | \n", "