CTScanViewer is a Jupyter Notebook widget for visualizing 3D CT scans along with their organ segmentations. The widget allows users to navigate through different slices, adjust the transparency of the segmentation overlay, and switch between different viewing planes (axial, sagittal, coronal). It also provides a progress bar to indicate loading status and displays metadata for each scan.
- Slice Navigation: Navigate through CT scan slices using a slider.
- Transparency Adjustment: Adjust the transparency of the segmentation overlay with a slider.
- Plane Selection: Choose the viewing plane (axial, sagittal, coronal) using a dropdown menu.
- Progress Bar: Visual indication of the loading process.
- Metadata Display: View additional information about the CT scan and segmentation.
- Next Button: Easily switch to the next scan in the dataframe.
- Python 3.x
- Jupyter Notebook or JupyterLab
- nibabel
- numpy
- matplotlib
- ipywidgets
- pandas
- Clone this repository:
git clone https://github.com/yourusername/CTScanViewer.git
cd CTScanViewer
- Install the required Python packages:
pip install nibabel numpy matplotlib ipywidgets pandas
- Prepare a dataframe containing paths to the CT scans and segmentations, along with any additional metadata:
import pandas as pd
df = pd.DataFrame({
'ct_scan_path': ['path_to_ct_scan1.nii', 'path_to_ct_scan2.nii'],
'segmentation_path': ['path_to_segmentation1.nii', 'path_to_segmentation2.nii'],
'patient_id': [1, 2],
'age': [65, 70],
'sex': ['M', 'F']
})
- Create an instance of the
CTScanViewer
with your dataframe:
viewer = CTScanViewer(df)
- Run the code in a Jupyter Notebook cell to display the interactive widget.
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.