Skip to content

Commit

Permalink
Merge pull request #140 from pyplati/more-fixes-to-cardiac-docs
Browse files Browse the repository at this point in the history
A few minor fixes
  • Loading branch information
pchlap authored Jun 2, 2022
2 parents eeea435 + 23bc766 commit 6ecc6c0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
24 changes: 9 additions & 15 deletions examples/cardiac_segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"source": [
"# Cardiac Sub-Structure Segmentation Example\n",
"\n",
"> Important: When running on Google Colab, ensure you change your runtime to use a GPU before\n",
"proceeding (Runtime->Change runtime type, select GPU as Hardware accelerator and press Save)\n",
"\n",
"## Import Modules"
]
},
Expand All @@ -19,14 +22,13 @@
" import platipy\n",
"except:\n",
" !pip install git+https://github.com/pyplati/platipy.git\n",
" !pip install nnunet\n",
" import platipy\n",
"\n",
"from matplotlib import pyplot as plt\n",
"\n",
"import SimpleITK as sitk\n",
"\n",
"%matplotlib inline\n",
"\n",
"from platipy.imaging.tests.data import get_lung_nifti\n",
"from platipy.imaging.projects.cardiac.run import run_hybrid_segmentation\n",
"from platipy.imaging import ImageVisualiser\n",
Expand Down Expand Up @@ -113,8 +115,7 @@
"for struct_name in list(auto_structures.keys()):\n",
" sitk.WriteImage(auto_structures[struct_name], str(output_directory.joinpath(f\"{struct_name}.nii.gz\")))\n",
"\n",
"print(f\"Segmentations saved to: {output_directory}\")\n",
"\n"
"print(f\"Segmentations saved to: {output_directory}\")"
]
},
{
Expand All @@ -134,17 +135,10 @@
"source": [
"vis = ImageVisualiser(test_image, cut=get_com(auto_structures[\"Heart\"]))\n",
"vis.add_contour({struct: auto_structures[struct] for struct in auto_structures.keys()})\n",
"fig = vis.show()\n",
"plt.savefig(output_directory.joinpath(f\"snapshot.png\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig"
"vis.show()\n",
"snapshot_path = output_directory.joinpath(f\"snapshot.png\")\n",
"plt.savefig(snapshot_path)\n",
"print(f\"Snapshot saved to: {snapshot_path}\")"
]
},
{
Expand Down
21 changes: 13 additions & 8 deletions platipy/imaging/projects/cardiac/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Cardiac sub-structure auto-segmentation
# Cardiac Segmentation

This project consists of an algorithm to automatically segment the heart plus 17 cardiac
sub-structures in typical Radiotherapy CT scans. The hybrid algorithm [[1]](#references) first segments the whole
heart using a deep learning model (nnUNet [[2]](#references)) followed by a multi-atlas based mapping of the
cardiac sub-structure [[3]](#references) and geometric modelling of smaller cardiac structures. The following
cardiac sub-structures [[3]](#references) and finally geometric modelling of smaller cardiac structures. The following
cardiac structures are generated by the auto-segmentation algorithm. By default, structure names
are formatted to conform to the [TG-263](https://www.aapm.org/pubs/reports/RPT_263.pdf)
guildelines:
guidelines:

| Structure | Name |
| -------------------------------- | ------------------- |
Expand All @@ -33,13 +33,18 @@ guildelines:

## Quickstart

These steps have been tested on an Ubuntu 20.04 OS with Python 3.8. Other Linux Operating Systems
and Python versions 3.7-3.9 are expected to work. This tool is untest and likely won't run on a
These steps have been tested on an Ubuntu 20.04 operating system using Python 3.8. Other Linux operating systems
and Python versions 3.7-3.9 are expected to work. This tool is untested and likely won't run on a
Windows operating system at this time (contributions are welcome).

### System Requirements

On a system with the following specification, one case takes approximately 5 minutes process.
On a system with the following specifications, one case takes approximately 5 minutes process:
- 24 core Intel i9 processor
- 64GB RAM
- NVIDIA 3090 GPU

The tool will run on a system with lower specifications, however a GPU is recommended.

> Note: The nnUNet model as well as the cardiac atlas will be downloaded which will increase the
runtime on the first run.
Expand Down Expand Up @@ -100,7 +105,7 @@ plt.savefig(output_directory.joinpath(f"snapshot.png"))

### Run from Command Line Interface (CLI)

This command assumes you have a thorax CT image stored in Nifti format at a location
This command assumes you have a thorax CT image stored in Nifti format at the location
`/path/to/ct.nii.gz`:

```bash
Expand Down Expand Up @@ -136,7 +141,7 @@ library:
!pip install platipy
```

If you continute to experience issues, restart the Colab runtime (Runtime->Restart Runtime) and try
If you continue to experience issues, restart the Colab runtime (Runtime->Restart Runtime) and try
again.

> If you are experiencing other issues, please consider reporting these in the [PlatiPy GitHub
Expand Down
2 changes: 1 addition & 1 deletion platipy/imaging/projects/cardiac/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def run_cardiac_segmentation(img, guide_structure=None, settings=CARDIAC_SETTING
)

# 5 - SINOATRIAL NODE
san_name = "CN_Sinoatrialz"
san_name = "CN_Sinoatrial"
results[san_name] = geometric_sinoatrialnode(
label_svc=results[geom_atlas_names["atlas_superior_vena_cava"]],
label_ra=results[geom_atlas_names["atlas_right_atrium"]],
Expand Down

0 comments on commit 6ecc6c0

Please sign in to comment.