Skip to content

Commit

Permalink
Remove shape features
Browse files Browse the repository at this point in the history
Hopefully it'll be added again in the future.
  • Loading branch information
alexdaniel654 committed Sep 7, 2023
1 parent fb0c24d commit 88befc9
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 444 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ scipy~=1.9.1
scikit-learn~=1.2.1
tabulate~=0.9.0
tqdm~=4.64.1
trimesh~=3.22.0
88 changes: 0 additions & 88 deletions tutorials/segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -230,94 +230,6 @@
"start_time": "2023-06-29T15:26:33.555928800Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"## Shape Features\n",
"To further characterise the kidney, a number of shape features can be calculated. These can be calculated from a labeled\n",
"image i.e. each region/tissue is represented by a different integer such as the kidney variable above or from a binary mask\n",
"of 0s and 1s such as the mask variable above. If a binary mask is used, the labeled image is generated internally by\n",
"assuming each unconnected component is a different region/tissue. If the labeled image (be it supplied or internally\n",
"generated) has background plus two labels, it is assumed the first label is the left kidney and the second label is the\n",
"right kidney."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 5,
"outputs": [
{
"data": {
"text/plain": " volume surface_area volume_bbox volume_convex volume_filled n_vox \\\nL 118.193529 148.056898 360.854707 170.527361 118.193529 9551.0 \nR 121.807026 154.516434 263.735786 150.368503 121.807026 9843.0 \n\n long_axis short_axis compactness euler_number solidity \nL 11.79375 4.347013 0.078666 2.0 0.693106 \nR 12.317681 3.643008 0.076906 2.0 0.810057 ",
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>volume</th>\n <th>surface_area</th>\n <th>volume_bbox</th>\n <th>volume_convex</th>\n <th>volume_filled</th>\n <th>n_vox</th>\n <th>long_axis</th>\n <th>short_axis</th>\n <th>compactness</th>\n <th>euler_number</th>\n <th>solidity</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>L</th>\n <td>118.193529</td>\n <td>148.056898</td>\n <td>360.854707</td>\n <td>170.527361</td>\n <td>118.193529</td>\n <td>9551.0</td>\n <td>11.79375</td>\n <td>4.347013</td>\n <td>0.078666</td>\n <td>2.0</td>\n <td>0.693106</td>\n </tr>\n <tr>\n <th>R</th>\n <td>121.807026</td>\n <td>154.516434</td>\n <td>263.735786</td>\n <td>150.368503</td>\n <td>121.807026</td>\n <td>9843.0</td>\n <td>12.317681</td>\n <td>3.643008</td>\n <td>0.076906</td>\n <td>2.0</td>\n <td>0.810057</td>\n </tr>\n </tbody>\n</table>\n</div>"
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from ukat.segmentation.shape_features import ShapeFeatures\n",
"\n",
"shape_features = ShapeFeatures(kidneys, affine)\n",
"\n",
"# Save the shape features as a csv.\n",
"shape_features.save_features_csv(os.path.join(OUTPUT_DIR, 'shape_features.csv'))\n",
"\n",
"# Print shape features.\n",
"shape_features.get_features()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-06-29T15:26:34.994777600Z",
"start_time": "2023-06-29T15:26:33.647876800Z"
}
}
},
{
"cell_type": "markdown",
"source": [
"By default, if there are two labels in the image, they are assumed to be the left and right kidney. This can be overridden\n",
"using the `region_labels` argument. This can also be used to update the row index if there are more than two labels e.g. the\n",
" kidneys, liver and spleen are all segmented."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 6,
"outputs": [
{
"data": {
"text/plain": " volume surface_area volume_bbox volume_convex volume_filled \\\nLeft 118.193529 148.056898 360.854707 170.527361 118.193529 \nRight 121.807026 154.516434 263.735786 150.368503 121.807026 \n\n n_vox long_axis short_axis compactness euler_number solidity \nLeft 9551.0 11.79375 4.347013 0.078666 2.0 0.693106 \nRight 9843.0 12.317681 3.643008 0.076906 2.0 0.810057 ",
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>volume</th>\n <th>surface_area</th>\n <th>volume_bbox</th>\n <th>volume_convex</th>\n <th>volume_filled</th>\n <th>n_vox</th>\n <th>long_axis</th>\n <th>short_axis</th>\n <th>compactness</th>\n <th>euler_number</th>\n <th>solidity</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>Left</th>\n <td>118.193529</td>\n <td>148.056898</td>\n <td>360.854707</td>\n <td>170.527361</td>\n <td>118.193529</td>\n <td>9551.0</td>\n <td>11.79375</td>\n <td>4.347013</td>\n <td>0.078666</td>\n <td>2.0</td>\n <td>0.693106</td>\n </tr>\n <tr>\n <th>Right</th>\n <td>121.807026</td>\n <td>154.516434</td>\n <td>263.735786</td>\n <td>150.368503</td>\n <td>121.807026</td>\n <td>9843.0</td>\n <td>12.317681</td>\n <td>3.643008</td>\n <td>0.076906</td>\n <td>2.0</td>\n <td>0.810057</td>\n </tr>\n </tbody>\n</table>\n</div>"
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Add custom index labels, here we'll just expand L and R to Left and Right as that's what's in the data we're using, but\n",
"# these could be cortex and medulla.\n",
"shape_features = ShapeFeatures(kidneys, affine, region_labels=['Left', 'Right'])\n",
"\n",
"shape_features.get_features()"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-06-29T15:26:37.158651300Z",
"start_time": "2023-06-29T15:26:34.999775400Z"
}
}
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion ukat/segmentation/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import shape_features, whole_kidney
from . import whole_kidney
161 changes: 0 additions & 161 deletions ukat/segmentation/shape_features.py

This file was deleted.

2 changes: 1 addition & 1 deletion ukat/segmentation/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import test_shape_features, test_whole_kidney
from . import test_whole_kidney
Loading

0 comments on commit 88befc9

Please sign in to comment.