Skip to content

Commit 85ac7a4

Browse files
committed
autofixes
Signed-off-by: Wenqi Li <[email protected]>
1 parent 7ead3da commit 85ac7a4

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

model_zoo/TCIA_PROSTATEx_Prostate_MRI_Anatomy_Model.ipynb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
{
1717
"cell_type": "markdown",
1818
"metadata": {
19-
"id": "N92pMd7ig0ZS",
20-
"jp-MarkdownHeadingCollapsed": true,
19+
"incorrectly_encoded_metadata": "id=\"N92pMd7ig0ZS\" jp-MarkdownHeadingCollapsed=true",
2120
"tags": []
2221
},
2322
"source": [
@@ -76,7 +75,6 @@
7675
"outputs": [],
7776
"source": [
7877
"import os\n",
79-
"import sys\n",
8078
"\n",
8179
"# Upgrade pip, just in case.\n",
8280
"!{sys.executable} -m pip install --upgrade -q pip"
@@ -210,10 +208,10 @@
210208
"# Download a \"Shared Cart\" containing 6 scans from PROSTATEx\n",
211209
"# that has been previously created via the TCIA website \n",
212210
"# (https://nbia.cancerimagingarchive.net).\n",
213-
"cartName = \"nbia-17571668146714049\"\n",
211+
"cart_name = \"nbia-17571668146714049\"\n",
214212
"\n",
215213
"# retrieve cart metadata\n",
216-
"cart_data = nbia.getSharedCart(cartName)\n",
214+
"cart_data = nbia.getSharedCart(cart_name)\n",
217215
"\n",
218216
"# download the series_uids list and return dataframe of metadata\n",
219217
"df = nbia.downloadSeries(cart_data)\n",
@@ -318,11 +316,12 @@
318316
"# Ideally this would have been accomplished using MONAI's transforms\n",
319317
"# for data pre-processing / augmentation instead of using a separate\n",
320318
"# function.\n",
321-
"def prostate_crop( img ):\n",
322-
" boundary = [int(crop_size*0.2) for crop_size in img.GetLargestPossibleRegion().GetSize()]\n",
319+
"def prostate_crop(img):\n",
320+
" boundary = [int(crop_size * 0.2) for crop_size in img.GetLargestPossibleRegion().GetSize()]\n",
323321
" new_image = itk.CropImageFilter(Input=img, BoundaryCropSize=boundary)\n",
324322
" return new_image\n",
325323
"\n",
324+
"\n",
326325
"mr_image_prep = prostate_crop(mr_image)\n",
327326
"seg_image_prep = prostate_crop(seg_image)\n",
328327
"\n",
@@ -456,7 +455,8 @@
456455
"outputs": [],
457456
"source": [
458457
"# Read the result image that was written into the output_dir.\n",
459-
"result_image = itk.imread(os.path.join( output_dir, os.path.split(mr_dir)[1], os.path.split(mr_dir)[1] + \"_trans.nii.gz\"))"
458+
"result_image = itk.imread(os.path.join(output_dir, os.path.split(mr_dir)[\n",
459+
" 1], os.path.split(mr_dir)[1] + \"_trans.nii.gz\"))"
460460
]
461461
},
462462
{
@@ -473,9 +473,9 @@
473473
"# image to match the physical properties of the original input data.\n",
474474
"interpolator = itk.NearestNeighborInterpolateImageFunction.New(seg_image)\n",
475475
"result_image_resampled = itk.resample_image_filter(Input=result_image,\n",
476-
" Interpolator=interpolator,\n",
477-
" reference_image=seg_image_prep, \n",
478-
" use_reference_image=True)"
476+
" Interpolator=interpolator,\n",
477+
" reference_image=seg_image_prep, \n",
478+
" use_reference_image=True)"
479479
]
480480
},
481481
{
@@ -488,7 +488,7 @@
488488
"outputs": [],
489489
"source": [
490490
"# View the image with results overlaid in an interactive 2D slice viewer.\n",
491-
"viewerB = view(image=mr_image_prep, label_image=result_image_resampled)"
491+
"viewer_b = view(image=mr_image_prep, label_image=result_image_resampled)"
492492
]
493493
},
494494
{
@@ -501,11 +501,11 @@
501501
},
502502
"outputs": [],
503503
"source": [
504-
"viewerB.set_image_color_map(\"Grayscale\")\n",
505-
"viewerB.set_label_image_blend(0.5)\n",
506-
"viewerB.set_image_color_range([100,500])\n",
507-
"viewerB.set_view_mode('ZPlane')\n",
508-
"viewerB.set_ui_collapsed(False)"
504+
"viewer_b.set_image_color_map(\"Grayscale\")\n",
505+
"viewer_b.set_label_image_blend(0.5)\n",
506+
"viewer_b.set_image_color_range([100, 500])\n",
507+
"viewer_b.set_view_mode('ZPlane')\n",
508+
"viewer_b.set_ui_collapsed(False)"
509509
]
510510
},
511511
{
@@ -528,11 +528,11 @@
528528
"# 1 = ideal prostate, but model called non-prostate (red)\n",
529529
"# 2 = model called prostate, but ideal called non-prostate (purple)\n",
530530
"# 3 = modeal and ideal agreed (green)\n",
531-
"compare_model_expert = np.where(result_array!=1,0,2) + np.where(expert_array!=2,0,1)\n",
531+
"compare_model_expert = np.where(result_array != 1, 0, 2) + np.where(expert_array != 2, 0, 1)\n",
532532
"compare_image = itk.GetImageFromArray(compare_model_expert.astype(np.float32))\n",
533533
"compare_image.CopyInformation(seg_image_prep)\n",
534534
"\n",
535-
"viewerC = view(image=mr_image_prep, label_image=compare_image)"
535+
"viewer_c = view(image=mr_image_prep, label_image=compare_image)"
536536
]
537537
},
538538
{
@@ -544,11 +544,11 @@
544544
"outputs": [],
545545
"source": [
546546
"# Switch to an interactive slice view so that labels are more easily seen.\n",
547-
"viewerC.set_label_image_blend(0.6)\n",
548-
"viewerC.set_image_color_map(\"Grayscale\")\n",
549-
"viewerC.set_view_mode(\"ZPlane\")\n",
550-
"viewerC.set_image_color_range([100,500])\n",
551-
"viewerC.set_ui_collapsed(False)"
547+
"viewer_c.set_label_image_blend(0.6)\n",
548+
"viewer_c.set_image_color_map(\"Grayscale\")\n",
549+
"viewer_c.set_view_mode(\"ZPlane\")\n",
550+
"viewer_c.set_image_color_range([100, 500])\n",
551+
"viewer_c.set_ui_collapsed(False)"
552552
]
553553
},
554554
{
@@ -590,9 +590,9 @@
590590
"provenance": []
591591
},
592592
"kernelspec": {
593-
"display_name": "medical-image-ai:Python",
593+
"display_name": "Python 3 (ipykernel)",
594594
"language": "python",
595-
"name": "conda-env-medical-image-ai-py"
595+
"name": "python3"
596596
},
597597
"language_info": {
598598
"codemirror_mode": {
@@ -604,7 +604,7 @@
604604
"name": "python",
605605
"nbconvert_exporter": "python",
606606
"pygments_lexer": "ipython3",
607-
"version": "3.9.15"
607+
"version": "3.8.13"
608608
}
609609
},
610610
"nbformat": 4,

0 commit comments

Comments
 (0)