Skip to content

Commit

Permalink
BUG: Fix loading parameter file in notebooks.
Browse files Browse the repository at this point in the history
Some recent changes broke source code in some notebooks (wrong/missing imports, missing new lines).
  • Loading branch information
JoostJM committed Aug 16, 2017
1 parent 968a962 commit 1e84396
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion notebooks/FeatureVisualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"source": [
"# Import some libraries\n",
"import SimpleITK as sitk\n",
"import radiomics"
"from radiomics import featureextractor"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/FeatureVisualizationWithClustering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"source": [
"# Import some libraries\n",
"import SimpleITK as sitk\n",
"import radiomics"
"from radiomics import featureextractor"
]
},
{
Expand Down
17 changes: 8 additions & 9 deletions notebooks/FilteringEffects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"outputs": [],
"source": [
"# Radiomics package\n",
"import radiomics\n",
"from radiomics import featureextractor\n",
"\n",
"import six, numpy as np"
]
Expand Down Expand Up @@ -61,7 +61,7 @@
"import SimpleITK as sitk\n",
"\n",
"image = sitk.ReadImage(\"example_data/brain1_image.nrrd\")\n",
"label = sitk.ReadImage(\"example_data/brain1_label.nrrd\")\n"
"label = sitk.ReadImage(\"example_data/brain1_label.nrrd\")"
]
},
{
Expand Down Expand Up @@ -138,8 +138,7 @@
"# Instantiate the extractor\n",
"params = os.path.join(os.getcwd(), '..', 'examples', 'exampleSettings', 'Params.yaml')\n",
"\n",
"extractor = featureextractor.RadiomicsFeaturesExtractor(params)",
"\n",
"extractor = featureextractor.RadiomicsFeaturesExtractor(params)\n",
"# Construct a set of SimpleITK filter objects\n",
"filters = {\n",
" \"AdditiveGaussianNoise\" : sitk.AdditiveGaussianNoiseImageFilter(),\n",
Expand Down Expand Up @@ -214,7 +213,7 @@
"for key, value in six.iteritems(filters):\n",
" print ( \"filtering with \" + key )\n",
" filtered_image = value.Execute(image)\n",
" results[key] = extractor.execute(filtered_image, label)\n"
" results[key] = extractor.execute(filtered_image, label)"
]
},
{
Expand All @@ -239,7 +238,7 @@
"source": [
"# Keep an index of filters and features\n",
"filter_index = list(sorted(filters.keys()))\n",
"feature_names = list(sorted(filter ( lambda k: k.startswith(\"original_\"), results[filter_index[0]] )))\n"
"feature_names = list(sorted(filter ( lambda k: k.startswith(\"original_\"), results[filter_index[0]] )))"
]
},
{
Expand Down Expand Up @@ -321,7 +320,7 @@
"print (\"\\n\")\n",
"print (\"Bottom 10 features with _smallest_ coefficient of variation\")\n",
"for i in range(-11,-1):\n",
" print (\"Feature: {:<50} CV: {}\".format ( cv_sorted[i], cv[cv_sorted[i]]))\n"
" print (\"Feature: {:<50} CV: {}\".format ( cv_sorted[i], cv[cv_sorted[i]]))"
]
}
],
Expand All @@ -334,7 +333,7 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 2.0
},
"file_extension": ".py",
"mimetype": "text/x-python",
Expand All @@ -346,4 +345,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}
12 changes: 6 additions & 6 deletions notebooks/RadiomicsExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"outputs": [],
"source": [
"# Radiomics package\n",
"import radiomics\n",
"from radiomics import featureextractor\n",
"\n",
"import six, numpy as np"
]
Expand Down Expand Up @@ -166,10 +166,11 @@
}
],
"source": [
"import os\n",
"# Instantiate the extractor\n",
"params = os.path.join(os.getcwd(), '..', 'examples', 'exampleSettings', 'Params.yaml')\n",
"\n",
"extractor = featureextractor.RadiomicsFeaturesExtractor(params)",
"extractor = featureextractor.RadiomicsFeaturesExtractor(params)\n",
"result_1 = extractor.execute(image_1, label_1)\n",
"result_2 = extractor.execute(image_2, label_2)"
]
Expand Down Expand Up @@ -239,7 +240,6 @@
}
],
"source": [
"\n",
"plt.figure(figsize=(20,20))\n",
"plt.subplot(3,1,1)\n",
"plt.plot(feature_1)\n",
Expand All @@ -255,7 +255,7 @@
"plt.plot(feature_1 - feature_2)\n",
"plt.yscale('log')\n",
"plt.title ( \"Difference\")\n",
"plt.show()\n"
"plt.show()"
]
}
],
Expand All @@ -268,7 +268,7 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 2.0
},
"file_extension": ".py",
"mimetype": "text/x-python",
Expand All @@ -280,4 +280,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
}
}

0 comments on commit 1e84396

Please sign in to comment.