Skip to content

Commit

Permalink
replace special branch
Browse files Browse the repository at this point in the history
  • Loading branch information
satra committed Oct 26, 2022
1 parent 0472051 commit 908c879
Show file tree
Hide file tree
Showing 2 changed files with 199 additions and 47 deletions.
116 changes: 93 additions & 23 deletions guide/api_train_binary_segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
{
"cell_type": "markdown",
"metadata": {
"id": "ijHnNTIjDkt0"
"id": "ijHnNTIjDkt0",
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Train a neural network for binary volumetric segmentation\n",
Expand Down Expand Up @@ -38,14 +41,17 @@
},
"outputs": [],
"source": [
"!pip install --no-cache-dir nilearn https://github.com/neuronets/nobrainer/archive/refs/heads/enh/api.zip"
"!pip install --no-cache-dir nilearn nobrainer"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Ht_CGSk1Dkt3"
"id": "Ht_CGSk1Dkt3",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand All @@ -58,7 +64,10 @@
{
"cell_type": "markdown",
"metadata": {
"id": "hVCchp9uDkt3"
"id": "hVCchp9uDkt3",
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Get sample features and labels\n",
Expand All @@ -70,7 +79,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "YpqTxNu4Dkt4"
"id": "YpqTxNu4Dkt4",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand All @@ -81,7 +93,10 @@
{
"cell_type": "markdown",
"metadata": {
"id": "m3P3BUQKiCjg"
"id": "m3P3BUQKiCjg",
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Here is an example of one training pair, with the brainmask overlaid on the anatomical image."
Expand All @@ -90,7 +105,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"filepaths[0]"
Expand All @@ -100,7 +119,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "9tAhbM4ChgIj"
"id": "9tAhbM4ChgIj",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand All @@ -113,7 +135,10 @@
{
"cell_type": "markdown",
"metadata": {
"id": "ScgF78rmDkt4"
"id": "ScgF78rmDkt4",
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Convert medical images to TFRecords\n",
Expand All @@ -125,7 +150,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "n7lCL-55Ta4R"
"id": "n7lCL-55Ta4R",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand All @@ -136,7 +164,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Q3zPyRlbTa4R"
"id": "Q3zPyRlbTa4R",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -171,7 +202,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "X8u_owicTa4T"
"id": "X8u_owicTa4T",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand All @@ -183,7 +217,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "RhJ7upa5Ta4T"
"id": "RhJ7upa5Ta4T",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand All @@ -194,7 +231,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "oKQm8qrOTa4U"
"id": "oKQm8qrOTa4U",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand All @@ -212,7 +252,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "OWqLu2xFTa4U"
"id": "OWqLu2xFTa4U",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand All @@ -227,7 +270,10 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4xJxR7Ddbd-0"
"id": "4xJxR7Ddbd-0",
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
Expand All @@ -237,7 +283,11 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"1. Save model\n",
"2. Load model back as a class instance\n",
Expand All @@ -248,7 +298,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"bem.save(\"data/testsave\")"
Expand All @@ -257,7 +311,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"from nobrainer.processing.segmentation import Segmentation\n",
Expand All @@ -267,7 +325,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"image_path = filepaths[0][0]\n",
Expand All @@ -278,7 +340,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"bem.fit(dataset_train=dataset_train,\n",
Expand All @@ -291,7 +357,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": []
}
Expand Down Expand Up @@ -322,4 +392,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
Loading

0 comments on commit 908c879

Please sign in to comment.