{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "from glob import glob\n", "import pandas as pd\n", "import os\n", "from skimage.io import imread\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | sample | \n", "frame | \n", "frame_id | \n", "path | \n", "
|---|---|---|---|---|
| 0 | \n", "MI5 | \n", "0 | \n", "MI5_0_00 | \n", "[../data/MI5_0_00_1500.rec.8bit.tif, ../data/M... | \n", "
| 1 | \n", "MI5 | \n", "1 | \n", "MI5_1_00 | \n", "[../data/MI5_1_00_1500.rec.8bit.tif, ../data/M... | \n", "
| 2 | \n", "MI5 | \n", "1 | \n", "MI5_1_01 | \n", "[../data/MI5_1_01_1500.rec.8bit.tif, ../data/M... | \n", "
| 3 | \n", "MI5 | \n", "1 | \n", "MI5_1_02 | \n", "[../data/MI5_1_02_1500.rec.8bit.tif, ../data/M... | \n", "
| 4 | \n", "MI7 | \n", "0 | \n", "MI7_0_00 | \n", "[../data/MI7_0_00_1300.rec.8bit.tif, ../data/M... | \n", "
| 5 | \n", "MI7 | \n", "1 | \n", "MI7_1_00 | \n", "[../data/MI7_1_00_1300.rec.8bit.tif, ../data/M... | \n", "
| 6 | \n", "MI7 | \n", "1 | \n", "MI7_1_01 | \n", "[../data/MI7_1_01_1300.rec.8bit.tif, ../data/M... | \n", "
| 7 | \n", "MI7 | \n", "1 | \n", "MI7_1_02 | \n", "[../data/MI7_1_02_1300.rec.8bit.tif, ../data/M... | \n", "
Failed to display Jupyter Widget of type VBox.
\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "
\n", "\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "
\n" ], "text/plain": [ "VBox(children=(Figure(camera_center=[0.0, 0.0, 0.0], data_max=255.0, height=500, matrix_projection=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], matrix_world=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], style={'axes': {'visible': True, 'label': {'color': 'black'}, 'ticklabel': {'color': 'black'}, 'color': 'black'}, 'box': {'visible': True}, 'background-color': 'white'}, tf=TransferFunction(rgba=array([[0. , 0. , 0. , 0. ],\n", " [0.00392157, 0.00392157, 0.00392157, 0. ],\n", " [0.00784314, 0.00784314, 0.00784314, 0. ],\n", " ...,\n", " [0.99215686, 0.99215686, 0.99215686, 0.49372549],\n", " [0.99607843, 0.99607843, 0.99607843, 0.49686275],\n", " [1. , 1. , 1. , 0.5 ]])), volume_data=array([[[ 76., 84., 88., ..., 81., 83., 85.],\n", " [ 72., 78., 85., ..., 76., 78., 80.],\n", " [ 74., 79., 86., ..., 73., 79., 83.],\n", " ...,\n", " [ 73., 82., 93., ..., 74., 74., 74.],\n", " [ 93., 103., 110., ..., 74., 73., 72.],\n", " [ 97., 104., 104., ..., 82., 76., 72.]],\n", "\n", " [[ 87., 80., 69., ..., 81., 79., 75.],\n", " [ 87., 87., 79., ..., 71., 70., 70.],\n", " [ 91., 93., 90., ..., 65., 69., 76.],\n", " ...,\n", " [ 77., 79., 86., ..., 71., 87., 99.],\n", " [ 77., 81., 86., ..., 61., 79., 95.],\n", " [ 81., 88., 87., ..., 59., 70., 88.]],\n", "\n", " [[ 82., 87., 85., ..., 109., 109., 89.],\n", " [ 73., 81., 84., ..., 118., 101., 71.],\n", " [ 69., 69., 76., ..., 105., 72., 46.],\n", " ...,\n", " [ 95., 87., 77., ..., 83., 87., 92.],\n", " [ 85., 76., 71., ..., 78., 82., 87.],\n", " [ 81., 78., 78., ..., 76., 79., 90.]],\n", "\n", " ...,\n", "\n", " [[ 81., 81., 80., ..., 90., 91., 95.],\n", " [ 72., 75., 72., ..., 93., 96., 99.],\n", " [ 74., 77., 74., ..., 100., 100., 98.],\n", " ...,\n", " [ 75., 81., 88., ..., 84., 81., 74.],\n", " [ 79., 85., 88., ..., 84., 84., 77.],\n", " [ 88., 89., 87., ..., 85., 86., 84.]],\n", "\n", " [[ 84., 88., 89., ..., 93., 94., 96.],\n", " [ 82., 85., 87., ..., 93., 95., 93.],\n", " [ 88., 87., 86., ..., 93., 94., 89.],\n", " ...,\n", " [ 73., 70., 75., ..., 90., 87., 88.],\n", " [ 69., 71., 80., ..., 89., 85., 85.],\n", " [ 67., 75., 85., ..., 90., 87., 87.]],\n", "\n", " [[ 76., 79., 83., ..., 89., 96., 99.],\n", " [ 71., 72., 78., ..., 94., 98., 94.],\n", " [ 73., 64., 63., ..., 101., 94., 84.],\n", " ...,\n", " [ 88., 84., 80., ..., 85., 93., 102.],\n", " [ 90., 86., 80., ..., 81., 85., 97.],\n", " [ 83., 78., 69., ..., 85., 83., 91.]]], dtype=float32), width=400, xlim=[0.0, 1.0], ylim=[0.0, 1.0], zlim=[0.0, 1.0]), HBox(children=(FloatSlider(value=0.5, description='ambient', max=1.0, step=0.001), FloatSlider(value=0.8, description='diffuse', max=1.0, step=0.001))), HBox(children=(FloatSlider(value=0.5, description='specular', max=1.0, step=0.001), FloatSlider(value=5.0, description='specular exp', max=10.0, step=0.001)))))" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/Users/mader/anaconda/envs/qbi2018/lib/python3.6/site-packages/ipyvolume/serialize.py:66: RuntimeWarning: invalid value encountered in true_divide\n", " gradient = gradient / np.sqrt(gradient[0]**2 + gradient[1]**2 + gradient[2]**2)\n" ] } ], "source": [ "_, c_row = next(img_3d_df.query('sample == \"MI5\"').iterrows())\n", "n_vol = paths_to_raw_vol(c_row['path'])\n", "fig = p3.figure()\n", "# create a custom LUT\n", "temp_tf = plt.cm.gray(np.linspace(0, 1, 256))\n", "temp_tf[:,3] = np.linspace(-.3, 0.5, 256).clip(0, 1) # make transparency more aggressive\n", "tf = p3.transferfunction.TransferFunction(rgba = temp_tf)\n", "p3.volshow(n_vol.astype(np.float32), \n", " lighting = True, \n", " max_opacity=0.5, \n", " tf = tf, \n", " controls = True)\n", "\n", "p3.show()\n", "p3.save('mi5_raw.html')" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/mader/anaconda/envs/qbi2018/lib/python3.6/site-packages/ipyvolume/serialize.py:66: RuntimeWarning: invalid value encountered in true_divide\n", " gradient = gradient / np.sqrt(gradient[0]**2 + gradient[1]**2 + gradient[2]**2)\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "08e091159d424cb389442832f1afdbc3", "version_major": 2, "version_minor": 0 }, "text/html": [ "Failed to display Jupyter Widget of type VBox.
\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "
\n", "\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "
\n" ], "text/plain": [ "VBox(children=(VBox(children=(HBox(children=(Label(value='levels:'), FloatSlider(value=0.1, max=1.0, step=0.001), FloatSlider(value=0.5, max=1.0, step=0.001), FloatSlider(value=0.9, max=1.0, step=0.001))), HBox(children=(Label(value='opacities:'), FloatSlider(value=0.01, max=0.2, step=0.001), FloatSlider(value=0.05, max=0.2, step=0.001), FloatSlider(value=0.05, max=0.2, step=0.001))))), Figure(ambient_coefficient=1.0, camera_center=[0.0, 0.0, 0.0], data_max=2.0, diffuse_coefficient=0.0, height=500, matrix_projection=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], matrix_world=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], specular_coefficient=0.0, style={'axes': {'visible': True, 'label': {'color': 'black'}, 'ticklabel': {'color': 'black'}, 'color': 'black'}, 'box': {'visible': True}, 'background-color': 'white'}, tf=TransferFunctionWidgetJs3(level3=0.9), volume_data=array([[[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " ...,\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]]], dtype=uint8), width=400, xlim=[0.0, 1.0], ylim=[0.0, 1.0], zlim=[0.0, 1.0])))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "n_vol = paths_to_vol(c_row['path'])\n", "p3.quickvolshow(n_vol)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# MI7" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/mader/anaconda/envs/qbi2018/lib/python3.6/site-packages/ipyvolume/serialize.py:66: RuntimeWarning: invalid value encountered in true_divide\n", " gradient = gradient / np.sqrt(gradient[0]**2 + gradient[1]**2 + gradient[2]**2)\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "17ad3b41a47d4d15b5b7669c24e9971b", "version_major": 2, "version_minor": 0 }, "text/html": [ "Failed to display Jupyter Widget of type VBox.
\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "
\n", "\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "
\n" ], "text/plain": [ "VBox(children=(VBox(children=(HBox(children=(Label(value='levels:'), FloatSlider(value=0.1, max=1.0, step=0.001), FloatSlider(value=0.5, max=1.0, step=0.001), FloatSlider(value=0.9, max=1.0, step=0.001))), HBox(children=(Label(value='opacities:'), FloatSlider(value=0.01, max=0.2, step=0.001), FloatSlider(value=0.05, max=0.2, step=0.001), FloatSlider(value=0.05, max=0.2, step=0.001))))), Figure(camera_center=[0.0, 0.0, 0.0], data_max=2.0, height=500, matrix_projection=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], matrix_world=[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], style={'axes': {'visible': True, 'label': {'color': 'black'}, 'ticklabel': {'color': 'black'}, 'color': 'black'}, 'box': {'visible': True}, 'background-color': 'white'}, tf=TransferFunctionWidgetJs3(level3=0.9), volume_data=array([[[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " ...,\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]],\n", "\n", " [[0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " ...,\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0],\n", " [0, 0, 0, ..., 0, 0, 0]]], dtype=uint8), width=400, xlim=[0.0, 1.0], ylim=[0.0, 1.0], zlim=[0.0, 1.0]), HBox(children=(FloatSlider(value=0.5, description='ambient', max=1.0, step=0.001), FloatSlider(value=0.8, description='diffuse', max=1.0, step=0.001))), HBox(children=(FloatSlider(value=0.5, description='specular', max=1.0, step=0.001), FloatSlider(value=5.0, description='specular exp', max=10.0, step=0.001)))))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "_, c_row = next(img_3d_df.query('sample == \"MI7\"').iterrows())\n", "n_vol = paths_to_vol(c_row['path'])\n", "p3.quickvolshow(n_vol, lighting=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.4" } }, "nbformat": 4, "nbformat_minor": 2 }