Skip to content

Commit

Permalink
example id update in module_examples/ImageReader.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
marxmit7 committed Feb 7, 2019
1 parent 8902ec4 commit d640267
Showing 1 changed file with 31 additions and 184 deletions.
215 changes: 31 additions & 184 deletions demos/module_examples/ImageReader.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,7 @@
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"INFO:tensorflow:TensorFlow version 1.5.0\n",
"CRITICAL:tensorflow:Optional Python module cv2 not found, please install cv2 and retry if the application fails.\n",
"INFO:tensorflow:Available Image Loaders:\n",
"['nibabel', 'skimage', 'pillow', 'simpleitk', 'dummy'].\n"
]
}
],
"outputs": [],
"source": [
"import sys\n",
"niftynet_path = '/Users/bar/Documents/Niftynet/'\n",
Expand All @@ -70,15 +59,15 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Accessing: https://cmiclab.cs.ucl.ac.uk/CMIC/NiftyNetExampleServer\n",
"anisotropic_nets_brats_challenge_model_zoo_data: OK. \n",
"Accessing: https://github.com/NifTK/NiftyNetModelZoo\n",
"anisotropic_nets_brats_challenge_model_zoo: OK. \n",
"Already downloaded. Use the -r option to download again.\n"
]
},
Expand All @@ -88,7 +77,7 @@
"True"
]
},
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -107,22 +96,9 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1mINFO:niftynet:\u001b[0m \n",
"\n",
"Number of subjects 10, input section names: ['subject_id', 'MR']\n",
"-- using all subjects (without data partitioning).\n",
"\n",
"\u001b[1mINFO:niftynet:\u001b[0m Image reader: loading 10 subjects from sections ('MR',) as input [MR]\n"
]
}
],
"outputs": [],
"source": [
"from niftynet.io.image_reader import ImageReader\n",
"\n",
Expand All @@ -132,30 +108,17 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"({'MR': (134, 167, 135, 1, 1)}, {'MR': tf.float32})"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"reader.shapes, reader.tf_dtypes"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": true
},
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# read data using the initialised reader\n",
Expand All @@ -164,39 +127,18 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((134, 167, 135, 1, 1), dtype('float32'))"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"image_data['MR'].shape, image_data['MR'].dtype"
]
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3 image: (134, 167, 135, 1, 1)\n",
"6 image: (152, 169, 130, 1, 1)\n",
"8 image: (152, 169, 130, 1, 1)\n"
]
}
],
"outputs": [],
"source": [
"# randomly sample the list of images\n",
"for _ in range(3):\n",
Expand All @@ -223,23 +165,9 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1mINFO:niftynet:\u001b[0m \n",
"\n",
"Number of subjects 2, input section names: ['subject_id', 'image', 'label']\n",
"-- using all subjects (without data partitioning).\n",
"\n",
"\u001b[1mINFO:niftynet:\u001b[0m Image reader: loading 2 subjects from sections ('image',) as input [image]\n",
"\u001b[1mINFO:niftynet:\u001b[0m Image reader: loading 2 subjects from sections ('label',) as input [label]\n"
]
}
],
"outputs": [],
"source": [
"from niftynet.io.image_reader import ImageReader\n",
"\n",
Expand All @@ -262,20 +190,9 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((134, 167, 135, 1, 1), (134, 167, 135, 1, 1))"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"idx, image_data, interp_order = reader(idx=0)\n",
"\n",
Expand All @@ -293,23 +210,9 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1mINFO:niftynet:\u001b[0m \n",
"\n",
"Number of subjects 2, input section names: ['subject_id', 'T1', 'T1c', 'T2', 'Flair', 'label']\n",
"-- using all subjects (without data partitioning).\n",
"\n",
"\u001b[1mINFO:niftynet:\u001b[0m Image reader: loading 2 subjects from sections ('T1', 'T1c', 'T2', 'Flair') as input [image]\n",
"\u001b[1mINFO:niftynet:\u001b[0m Image reader: loading 2 subjects from sections ('label',) as input [label]\n"
]
}
],
"outputs": [],
"source": [
"from niftynet.io.image_reader import ImageReader\n",
"\n",
Expand All @@ -329,31 +232,18 @@
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {
"collapsed": true
},
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"_, image_data, _ = reader(idx=0)"
]
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((134, 167, 135, 1, 4), (134, 167, 135, 1, 1))"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"image_data['image'].shape, image_data['label'].shape"
]
Expand Down Expand Up @@ -382,32 +272,9 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1mINFO:niftynet:\u001b[0m \n",
"\n",
"Number of subjects 10, input section names: ['subject_id', 'MR']\n",
"-- using all subjects (without data partitioning).\n",
"\n",
"\u001b[1mINFO:niftynet:\u001b[0m Image reader: loading 10 subjects from sections ('MR',) as input [MR]\n"
]
},
{
"data": {
"text/plain": [
"(134, 167, 135, 1, 1)"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"from niftynet.io.image_reader import ImageReader\n",
"from niftynet.layer.rand_rotation import RandomRotationLayer as Rotate\n",
Expand Down Expand Up @@ -436,29 +303,9 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1mINFO:niftynet:\u001b[0m \n",
"\n",
"Number of subjects 2, input section names: ['subject_id', 'T1', 'T1c', 'T2', 'Flair', 'label']\n",
"-- using all subjects (without data partitioning).\n",
"\n",
"\u001b[1mINFO:niftynet:\u001b[0m Image reader: loading 2 subjects from sections ('T1', 'T1c', 'T2', 'Flair') as input [image]\n",
"\u001b[1mINFO:niftynet:\u001b[0m Image reader: loading 2 subjects from sections ('label',) as input [label]\n",
"dict_keys(['image', 'label'])\n",
"image: (1, 134, 167, 135, 1, 4), label: (1, 134, 167, 135, 1, 1)\n",
"dict_keys(['image', 'label'])\n",
"image: (1, 134, 167, 135, 1, 4), label: (1, 134, 167, 135, 1, 1)\n",
"dict_keys(['image', 'label'])\n",
"image: (1, 152, 169, 130, 1, 4), label: (1, 152, 169, 130, 1, 1)\n"
]
}
],
"outputs": [],
"source": [
"import tensorflow as tf\n",
"from niftynet.io.image_reader import ImageReader\n",
Expand Down Expand Up @@ -511,7 +358,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -525,7 +372,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.4"
}
},
"nbformat": 4,
Expand Down

0 comments on commit d640267

Please sign in to comment.