A graphical user interface (GUI) for viewing 3D CT scans and overlaying ground truth and predicted segmentation masks.
Install the required libraries using pip:
pip install numpy nibabel PyQt5 matplotlib
Here is the updated README to clarify both methods of naming the folders and files:
Ensure the following directories exist in the project root:
CT
Ground_truth
Predicted
If they do not exist, the script will create them automatically.
You can name your files using one of the following two methods:
-
Numeric Only IDs:
-
CT scans: Place files in the
CT
directory. Name them as<subject_id>.nii.gz
.Example:
CT/ ├── 001.nii.gz ├── 002.nii.gz └── 003.nii.gz
-
Ground truth segmentations: Place files in the
Ground_truth
directory. Name them as<subject_id>.nii.gz
.Example:
Ground_truth/ ├── 001.nii.gz ├── 002.nii.gz └── 003.nii.gz
-
Predicted segmentations: Place files in the
Predicted
directory. Name them as<subject_id>.nii.gz
.Example:
Predicted/ ├── 001.nii.gz ├── 002.nii.gz └── 003.nii.gz
-
-
Alphanumeric IDs:
-
CT scans: Place files in the
CT
directory. Name them as<subject_id>.nii.gz
.Example:
CT/ ├── SUB_001.nii.gz ├── SUB_002.nii.gz └── SUB_003.nii.gz
-
Ground truth segmentations: Place files in the
Ground_truth
directory. Name them as<subject_id>.nii.gz
.Example:
Ground_truth/ ├── SUB_001.nii.gz ├── SUB_002.nii.gz └── SUB_003.nii.gz
-
Predicted segmentations: Place files in the
Predicted
directory. Name them as<subject_id>.nii.gz
.Example:
Predicted/ ├── SUB_001.nii.gz ├── SUB_002.nii.gz └── SUB_003.nii.gz
-
Execute the script to start the GUI:
python viewer.py
- Use the left
<
and right>
arrow buttons to navigate through different subjects. You can use either numeric or alphanumeric IDs for the subjects (e.g., 001, SUB_001). - Enter the subject ID directly in the input field to load a specific subject.
- View Controls: Switch between axial, coronal, and sagittal views.
- Toggle contour display and adjust contour line width.
- Adjust colors for labels and opacity of overlays.
- Adjust the slider to navigate through slices.
- Change the minimum and maximum intensity values to adjust the CT scan contrast.
- Use the
▶
button to animate through the slices automatically. - Toggle the overlay of ground truth and predicted segmentation masks using the
Toggle Overlay
button. - Plot intensity histogram
If you find it helpful, consider supporting us in the following ways:
-
⭐ Star this repository on GitHub.
-
🐦 Follow us on X (Twitter): @AITwinMinds
This project is licensed under the MIT License. See the LICENSE file for details.
For any inquiries, please contact AITwinMinds@gmail.com.