Skip to content

Commit debdcb0

Browse files
authored
Tests (#43)
* ENH: Updated reporting of nightly results. * ENH: Fix link to download slicerheart data * ENH: Fix coverage reporting * ENH: Detect more download failures * ENH: Remove Vista3D due to challenges on blackwell * TST: Add full type annotations to all test files; include tests/ in mypy Add return type and parameter annotations to every function in tests/, satisfying mypy disallow_untyped_defs=true. Extend mypy coverage from src/ only to src/ tests/ and add a pyproject.toml override so test modules ignore missing stubs from itk/pyvista. * FIX: PyVista extract_surface algorithm, ITK snake-case API, TestTools export Pass algorithm="dataset_surface" to every extract_surface() call to match the updated PyVista API. Switch segment_anatomy_base.py to the ITK snake_case functional API (resample_image_filter, etc.). Replace MultiplyImageFilter with explicit array multiply in transform_tools to avoid type-dispatch issues. Export TestTools from __init__ and add __test__=False to suppress spurious pytest collection. * ENH: Add data/test dir .gitignore * FIX: Guard against empty ids in segment_connected_component np.argmax on an empty array raises ValueError; this can occur when the input contains no labeled voxels in the threshold range (e.g. a non-contrast study). * BUG: Address comments raised by copilot and coderabbit * BUG: Update baselines for tests * FIX: Add urllib.error import and fix stale ensemble/simpleware references urllib.error was used in conftest.py but not imported, causing AttributeError on download failures. Also corrects the segmentation method identifier in troubleshooting docs ('simpleware' -> 'simpleware_heart') and removes stale ensemble references from README and developer docs.
1 parent 782a7a4 commit debdcb0

88 files changed

Lines changed: 1363 additions & 3348 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
settings.local.json

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ jobs:
107107
uses: codecov/codecov-action@v4
108108
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
109109
with:
110+
token: ${{ secrets.CODECOV_TOKEN }}
110111
file: ./coverage.xml
111112
flags: unittests
112113
name: codecov-unit-${{ matrix.os }}-py${{ matrix.python-version }}
@@ -233,6 +234,7 @@ jobs:
233234
- name: Upload coverage to Codecov
234235
uses: codecov/codecov-action@v4
235236
with:
237+
token: ${{ secrets.CODECOV_TOKEN }}
236238
file: ./coverage.xml
237239
flags: integration-tests
238240
name: codecov-integration
@@ -317,6 +319,7 @@ jobs:
317319
- name: Upload coverage to Codecov
318320
uses: codecov/codecov-action@v4
319321
with:
322+
token: ${{ secrets.CODECOV_TOKEN }}
320323
file: ./coverage.xml
321324
flags: gpu-tests
322325
name: codecov-gpu
@@ -380,7 +383,6 @@ jobs:
380383
# - tests/test_register_images_icon.py (requires CUDA for ICON)
381384
# - tests/test_transform_tools.py (depends on slow registration tests)
382385
# - tests/test_segment_chest_total_segmentator.py (requires CUDA for TotalSegmentator)
383-
# - tests/test_segment_chest_vista_3d.py (requires CUDA for VISTA-3D, 20GB+ RAM)
384386
#
385387
# Experiment tests (EXTREMELY SLOW - hours to complete):
386388
# - tests/test_experiments.py (runs all notebooks in experiments/ subdirectories)

.github/workflows/test-slow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ jobs:
8080
- name: Upload coverage to Codecov
8181
uses: codecov/codecov-action@v4
8282
with:
83+
token: ${{ secrets.CODECOV_TOKEN }}
8384
file: ./coverage.xml
8485
flags: slow-tests-gpu
8586
name: codecov-slow-gpu

CLAUDE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ uv pip install -e .
1414
ruff check . --fix && ruff format .
1515

1616
# Type checking
17-
mypy src/
17+
mypy src/ tests/
1818

1919
# All pre-commit hooks
2020
pre-commit run --all-files
@@ -28,7 +28,6 @@ py -m pytest tests/test_contour_tools.py::test_extract_surface -v
2828

2929
# Skip GPU-dependent tests
3030
py -m pytest tests/ --ignore=tests/test_segment_chest_total_segmentator.py \
31-
--ignore=tests/test_segment_chest_vista_3d.py \
3231
--ignore=tests/test_register_images_icon.py
3332

3433
# With coverage

README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PhysioMotion4D is a comprehensive medical imaging package that converts 4D CT sc
77
## 🚀 Key Features
88

99
- **Complete 4D Medical Imaging Pipeline**: End-to-end processing from 4D CT data to animated USD models
10-
- **Multiple AI Segmentation Methods**: TotalSegmentator, VISTA-3D, and ensemble approaches
10+
- **Multiple AI Segmentation Methods**: TotalSegmentator and Simpleware cardiac segmentation
1111
- **Deep Learning Registration**: GPU-accelerated image registration using Icon algorithm
1212
- **NVIDIA Omniverse Integration**: Direct USD file export for medical visualization
1313
- **Physiological Motion Analysis**: Capture and visualize cardiac and respiratory motion
@@ -106,9 +106,6 @@ print(f"PhysioMotion4D version: {physiomotion4d.__version__}")
106106
- `WorkflowFitStatisticalModelToPatient`: Model-to-patient registration workflow
107107
- **Segmentation Classes**: Multiple AI-based chest segmentation implementations
108108
- `SegmentChestTotalSegmentator`: TotalSegmentator-based segmentation
109-
- `SegmentChestVista3D`: VISTA-3D model-based segmentation
110-
- `SegmentChestVista3DNIM`: NVIDIA NIM version of VISTA-3D
111-
- `SegmentChestEnsemble`: Ensemble segmentation combining multiple methods
112109
- `SegmentAnatomyBase`: Base class for custom segmentation methods
113110
- **Registration Classes**: Multiple registration methods for different use cases
114111
- Image-to-Image Registration:
@@ -142,7 +139,7 @@ print(f"PhysioMotion4D version: {physiomotion4d.__version__}")
142139
- **AI/ML**: PyTorch, CuPy (CUDA 13 default; CUDA 12 via `[cuda12]` extra), transformers, MONAI
143140
- **Registration**: icon-registration, unigradicon
144141
- **Visualization**: USD-core, PyVista
145-
- **Segmentation**: TotalSegmentator, VISTA-3D models
142+
- **Segmentation**: TotalSegmentator
146143

147144
## 🎯 Quick Start
148145

@@ -262,11 +259,11 @@ registered_mesh = workflow.run_workflow()
262259
### Custom Segmentation
263260

264261
```python
265-
from physiomotion4d import SegmentChestVista3D
262+
from physiomotion4d import SegmentChestTotalSegmentator
266263
import itk
267264

268-
# Initialize VISTA-3D segmentation
269-
segmenter = SegmentChestVista3D()
265+
# Initialize TotalSegmentator segmentation
266+
segmenter = SegmentChestTotalSegmentator()
270267

271268
# Load and segment image
272269
image = itk.imread("chest_ct.nrrd")
@@ -578,14 +575,12 @@ pytest tests/test_register_images_greedy.py -v # Greedy registration
578575
pytest tests/test_register_images_icon.py -v # Icon registration
579576
pytest tests/test_register_time_series_images.py -v # Time series registration
580577
pytest tests/test_segment_chest_total_segmentator.py -v # TotalSegmentator
581-
pytest tests/test_segment_chest_vista_3d.py -v # VISTA-3D segmentation
582578
pytest tests/test_contour_tools.py -v # Mesh and contour tools
583579
pytest tests/test_image_tools.py -v # Image processing utilities
584580
pytest tests/test_transform_tools.py -v # Transform operations
585581

586582
# Skip GPU-dependent tests (segmentation and registration)
587583
pytest tests/ --ignore=tests/test_segment_chest_total_segmentator.py \
588-
--ignore=tests/test_segment_chest_vista_3d.py \
589584
--ignore=tests/test_register_images_icon.py
590585

591586
# Run with coverage report
@@ -594,7 +589,7 @@ pytest tests/ --cov=src/physiomotion4d --cov-report=html
594589

595590
**Test Categories:**
596591
- **Data Pipeline**: Download, conversion, and preprocessing
597-
- **Segmentation**: TotalSegmentator and VISTA-3D (GPU required)
592+
- **Segmentation**: TotalSegmentator (GPU required)
598593
- **Registration**: ANTs, Icon, and time series methods (slow, ~5-10 min)
599594
- **Geometry & Visualization**: Contour tools, transform tools, VTK to USD
600595
- **USD Utilities**: Merging, time preservation, material handling
@@ -637,7 +632,7 @@ Use `/plan` to get an inspection of the affected classes, a numbered implementat
637632
plan, and a list of open questions — without touching any files.
638633

639634
```text
640-
/plan add a confidence-weighted voting mode to SegmentChestEnsemble
635+
/plan add a new segmentation method to SegmentChestTotalSegmentator
641636
```
642637

643638
Claude will read the relevant source, summarize current behavior, list files that
@@ -767,7 +762,7 @@ This project is licensed under the Apache 2.0 License - see the LICENSE file for
767762
- **NVIDIA Omniverse** team for USD format and visualization platform
768763
- **MONAI** community for medical imaging AI tools
769764
- **DirLab** for providing the 4D-CT benchmark datasets
770-
- **TotalSegmentator** and **VISTA-3D** teams for segmentation models
765+
- **TotalSegmentator** team for segmentation models
771766
- **Icon Registration** team for deep learning registration methods
772767

773768
## 📞 Support

data/test/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.hdf
2+
*.mha
3+
*.nrrd

0 commit comments

Comments
 (0)