{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2019-02-27T00:53:58.705489Z", "start_time": "2019-02-27T00:53:55.960852Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/mnt/cube/tsainbur/conda_envs/tpy3/lib/python3.6/site-packages/tqdm/autonotebook/__init__.py:14: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n", " \" (e.g. in jupyter console)\", TqdmExperimentalWarning)\n" ] } ], "source": [ "from birdbrain.atlas import atlas\n", "from birdbrain.visualization.plotting_3d import generate_stl\n", "from birdbrain.utils import ensure_dir, um_to_vox\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load data, create atlas object" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2019-02-27T00:54:25.594241Z", "start_time": "2019-02-27T00:53:58.708300Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "qform_code 32 not valid; setting to 0\n", "qform_code 32 not valid; setting to 0\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Data already download\n", "Loading brain labels...\n", "Getting voxel data from .img files...\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "qform_code 32 not valid; setting to 0\n", "qform_code 32 not valid; setting to 0\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=1), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\r" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=22), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\r" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=12), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\r", "Getting location for each nucleus/region from voxel data...\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HBox(children=(IntProgress(value=0, max=45), HTML(value='')))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "\r", "Atlas created\n" ] } ], "source": [ "dset_dir = '../../data/processed/starling/'\n", "\n", "starling_atlas = atlas(\n", " species = 'starling',\n", " dset_dir = dset_dir,\n", " um_mult = 100,\n", " smoothing = ['Brain', 'Nuclei', 'Tracts'],\n", " updated_y_sinus = [0, 1500, 0]\n", ")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2019-02-27T00:54:25.600199Z", "start_time": "2019-02-27T00:54:25.596562Z" } }, "outputs": [], "source": [ "# ensure the directory\n", "ensure_dir('../../data/stl/')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2019-02-27T00:54:28.588897Z", "start_time": "2019-02-27T00:54:25.601912Z" } }, "outputs": [], "source": [ "# Generate stl of the whole brain\n", "zero_point = um_to_vox(np.array([0,0,0]), starling_atlas.voxel_data.loc['Brain' ,'affine'], starling_atlas.um_mult, np.array([0,0,0]))\n", "vox = starling_atlas.voxel_data.loc['Brain' ,'voxels']\n", "generate_stl(\"../../data/stl/whole_brain.stl\", vox, polygon_simplification=.75, zero_point=zero_point)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2019-02-27T00:54:28.868467Z", "start_time": "2019-02-27T00:54:28.593032Z" } }, "outputs": [], "source": [ "vox = starling_atlas.voxel_data.loc['Nuclei' ,'voxels'] == starling_atlas.brain_labels.loc['CMM', 'label']\n", "generate_stl(\"../../data/stl/CMM.stl\", vox, polygon_simplification=.5, zero_point = zero_point)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2019-02-27T00:54:28.874777Z", "start_time": "2019-02-27T00:54:28.870655Z" } }, "outputs": [], "source": [ "# TODO: generate stl by pulling together half the brain as voxels, and on the other hemisphere grab nuclei of interest (HVC, NCM, CMM, Area X, MAN, Field L)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.6.8" } }, "nbformat": 4, "nbformat_minor": 2 }