Lesion inpainting (LIT) integration#803
Conversation
There was a problem hiding this comment.
Pull request overview
Integrates the optional neuroLIT Lesion Inpainting Tool (LIT) into the FastSurfer pipeline so that lesion-aware processing can be triggered via --lesion_mask, including Docker preloading of LIT checkpoints and updated documentation.
Changes:
- Add
--lesion_masksupport inrun_fastsurfer.shto runlit-inpaintingbefore segmentation andlit-postprocessingafter segmentation/surfaces, with special handling for--no_biasfield. - Add
neurolitas a Python dependency and preload LIT models in the Docker image with deterministicXDG_DATA_HOME. - Add documentation pages/updates describing LIT usage, examples, outputs, and module overview entries.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/Docker/Dockerfile | Pins XDG_DATA_HOME and pre-downloads LIT models during image build. |
| run_fastsurfer.sh | Adds --lesion_mask flag and runs LIT inpainting/postprocessing around the existing pipeline. |
| pyproject.toml | Adds neurolit dependency for LIT CLIs. |
| doc/scripts/lit.rst | New script documentation page explaining LIT integration and outputs. |
| doc/scripts/index.rst | Adds lit.rst to scripts documentation index. |
| doc/scripts/RUN_FASTSURFER.md | Documents the new --lesion_mask CLI option. |
| doc/overview/modules/index.rst | Adds LIT to module overview index. |
| doc/overview/modules/LIT.md | New module overview page describing LIT and its outputs. |
| doc/overview/intro.rst | Mentions LIT as a FastSurfer capability in the intro overview. |
| doc/overview/OUTPUT_FILES.md | Documents LIT-related outputs and file locations. |
| doc/overview/EXAMPLES.md | Adds a new end-to-end example for running FastSurfer with --lesion_mask. |
| README.md | Mentions neurolit/LIT in modules list and adds the LIT citation. |
| FastSurferCNN/data_loader/conform.py | Hardens dtype-name handling in is_conform() logging/check labeling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Checks fail because neurolit 0.6.1 is not released |
|
@dkuegler Because of FastSurfer issues in dev my testing had failed. I pushed some preliminary fixes to be able to continue - it suceeds now. I think it would make sense if you took a look and resolved the conflicts that may emerge from this. I'll have a look at your comments |
Allow run_fastsurfer.sh to forward --vox_size any when --keepgeom or --native_image is used instead of translating the request to the legacy none value. The segmentation pipeline maps this value to None in RunModelOnData so FastSurferVINN preserves the input geometry rather than rejecting the option. Update the CLI help and validation text to document that native-geometry anisotropic inputs are experimental and segmentation-only. This fixes the release-testing keepgeom blocker where an anisotropic 1x1x1.2 image failed before prediction because --vox_size none was not accepted.
2d8526b to
fd3126e
Compare
Treat LIT as an experimental FastSurfer extension rather than a segmentation module in the README and overview docs. Make the example and module documentation more FastSurfer-centric, document lesion mask requirements in the LIT module page, keep detailed LIT outputs only in OUTPUT_FILES after the surface module, remove the redundant script documentation page, and align LIT execution-log labels with the extension terminology.
Set XDG_DATA_HOME to /var/.local/share in the FastSurfer Docker image instead of a /tmp path. Create the directory with runtime-writable permissions so neurolit platformdirs data and predownloaded LIT checkpoints remain available for non-root container users without relying on temporary directories.
|
Addressed comments, I'm rerunning the LIT test-suite |
39b297f to
72bea58
Compare
Move neurolit out of the base FastSurfer dependency set and expose it through a dedicated lit extra. Add a container extra that installs both qc and lit dependencies, and use that extra when building the Docker virtual environment so container images continue to include neurolit by default.
Set LIT activation directly when --lesion_mask is parsed and remove the separate reuse/postprocessing state variables. Detect existing LIT outputs from the subject directory, fail on inconsistent LIT activation for segmentation or edits runs, and trigger postprocessing from the output files themselves. Limit --skip-segstats to the explicit --seg_only plus --no_biasfield case and use the shared LIT output filename variables throughout. Keep FastSurfer LIT call compatible with neurolit 0.6.1 Do not pass explicit output-path arguments to lit-inpainting because neurolit 0.6.1 has already been released without those CLI options. Keep the released --fastsurfer_dir interface and document the neurolit-created FastSurfer-mode files that run_fastsurfer.sh checks downstream. changed lit tool calling to python -m
c99fd6e to
d6e8df3
Compare
Summary
This PR adds optional neuroLIT integration to FastSurfer for lesion-aware runs via
--lesion_mask.What changes
lit-inpaintingbefore VINN segmentation when--lesion_maskis providedlit-postprocessingafter segmentation / recon-surf to restore lesion-aware outputs and reports--keepgeomto neuroLIT in native-image mode--no_biasfieldbehavior by skipping only the segstats that are unsupported by the available inputs instead of crashingXDG_DATA_HOMEforneurolitTesting
neurolitwheel install and standalone CUDA inpainting passed--no_biasfieldpassed1.0x1.0x1.2--keepgeom --seg_onlyintegration passed and preserved image size / voxel size through the inpainted and downstream FastSurfer outputs--surf_only --lesion_maskcase fails early with a clear error if prior inpainting outputs are missing