Skip to content

Commit

Permalink
Merge pull request #336 from neurodata/tathey1-voxelclass
Browse files Browse the repository at this point in the history
Tathey1 voxelclass
  • Loading branch information
tathey1 committed Jan 24, 2022
2 parents f08906d + d1a8d07 commit 670152e
Show file tree
Hide file tree
Showing 3 changed files with 588 additions and 8 deletions.
93 changes: 93 additions & 0 deletions experiments/ViterBrain/notebooks/fig1-fragments.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import napari\n",
"from skimage import io, measure\n",
"import h5py\n",
"from napari_animation import AnimationWidget\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"im = io.imread(\"/Users/thomasathey/Documents/mimlab/mouselight/input/images/first10_quantitative/images/2018-08-01_1_first10_quantitative.tif\")\n",
"\n",
"f = h5py.File(\"/Users/thomasathey/Documents/mimlab/mouselight/input/images/first10_quantitative/2018-08-01_1_first10_quantitative_Probabilities.h5\", 'r')\n",
"pred = f.get('exported_data')\n",
"pred = pred[:,:,:,1]\n",
"probs = pred\n",
"\n",
"thresh = 0.5\n",
"mask = probs > thresh\n",
"labs = measure.label(mask)\n",
"\n",
"res = [0.3,0.3,1]"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/thomasathey/Documents/mimlab/mouselight/docs_env/lib/python3.8/site-packages/napari_animation/_qt/keyframeslist_widget.py:156: FutureWarning: Themes were changed to use evented model with Pydantic's color type rather than the `rgb(x, y, z)`. You can get the old color by calling `color.as_rgb()`. The `as_dict=True` option will be removed in 0.X.X\n",
" self.setStyleSheet(template(qss_template, **get_theme(theme_name)))\n"
]
}
],
"source": [
"viewer = napari.Viewer(ndisplay=3)\n",
"viewer.add_image(im, scale=res)\n",
"viewer.add_labels(mask, scale=res)\n",
"viewer.add_labels(labs, scale=res)\n",
"animation_widget = AnimationWidget(viewer)\n",
"viewer.window.add_dock_widget(animation_widget, area=\"right\")\n",
"viewer.camera.angles = [90, 90, 0]\n",
"viewer.scale_bar.visible = True\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"interpreter": {
"hash": "5dc00d68ff54f8375e99934614da4863299fb9e10af4294c095b7f517546ff26"
},
"kernelspec": {
"display_name": "Python 3.8.10 64-bit ('docs_env': venv)",
"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.8.10"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
480 changes: 480 additions & 0 deletions experiments/ViterBrain/notebooks/fig3-voxels.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -50,7 +50,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -89,24 +89,31 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Viterbrain vs App2: 5.491012510881023e-09\n",
"APP2 vs Advantra: 0.039425832629443\n"
"P values for 2 Proportion Z Tests\n",
"Viterbrain vs App2: 0.041448687457663176\n",
"Viterbrain vs Snake: 0.041397618661288514\n",
"APP2 vs Advantra: 0.039425832629443\n",
"APP2 vs GTree: 0.393153437674003\n",
"APP2 vs Snake: 0.26272224684071965\n"
]
}
],
"source": [
"from statsmodels.stats.proportion import proportions_ztest\n",
"\n",
"print(f\"Viterbrain vs App2: {proportions_ztest(count=[data[0][0], data[1][0]], nobs=[10, 35])[1]}\")\n",
"\n",
"print(f\"APP2 vs Advantra: {proportions_ztest(count=[data[1][0], data[3][0]], nobs=[35, 35])[1]}\")"
"print(\"P values for 2 Proportion Z Tests\")\n",
"print(f\"Viterbrain vs App2: {proportions_ztest(count=[data[0][0], data[1][0]], nobs=[35, 35])[1]}\")\n",
"print(f\"Viterbrain vs Snake: {proportions_ztest(count=[data[0][0], data[4][0]], nobs=[35, 10])[1]}\")\n",
"print(f\"APP2 vs Advantra: {proportions_ztest(count=[data[1][0], data[3][0]], nobs=[35, 35])[1]}\")\n",
"print(f\"APP2 vs GTree: {proportions_ztest(count=[data[1][0], data[2][0]], nobs=[35, 35])[1]}\")\n",
"print(f\"APP2 vs Snake: {proportions_ztest(count=[data[1][0], data[4][0]], nobs=[35, 10])[1]}\")"
]
},
{
Expand Down

0 comments on commit 670152e

Please sign in to comment.