Skip to content

Lesion inpainting (LIT) integration#803

Open
ClePol wants to merge 4 commits intoDeep-MI:devfrom
ClePol:pr/lit-integration-release
Open

Lesion inpainting (LIT) integration#803
ClePol wants to merge 4 commits intoDeep-MI:devfrom
ClePol:pr/lit-integration-release

Conversation

@ClePol
Copy link
Copy Markdown
Member

@ClePol ClePol commented Apr 23, 2026

Summary

This PR adds optional neuroLIT integration to FastSurfer for lesion-aware runs via --lesion_mask.

What changes

  • call lit-inpainting before VINN segmentation when --lesion_mask is provided
  • call lit-postprocessing after segmentation / recon-surf to restore lesion-aware outputs and reports
  • forward --keepgeom to neuroLIT in native-image mode
  • mirror FastSurfer --no_biasfield behavior by skipping only the segstats that are unsupported by the available inputs instead of crashing
  • add/update documentation for LIT usage, examples, outputs, and module overview
  • preload LIT checkpoints in the FastSurfer Docker image and set a deterministic XDG_DATA_HOME for neurolit

Testing

  • clean neurolit wheel install and standalone CUDA inpainting passed
  • standalone LIT Docker test passed
  • full FastSurfer + LIT integration passed
  • full FastSurfer + LIT integration with --no_biasfield passed
  • anisotropic 1.0x1.0x1.2 --keepgeom --seg_only integration passed and preserved image size / voxel size through the inpainted and downstream FastSurfer outputs
  • negative --surf_only --lesion_mask case fails early with a clear error if prior inpainting outputs are missing

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_mask support in run_fastsurfer.sh to run lit-inpainting before segmentation and lit-postprocessing after segmentation/surfaces, with special handling for --no_biasfield.
  • Add neurolit as a Python dependency and preload LIT models in the Docker image with deterministic XDG_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.

Comment thread tools/Docker/Dockerfile
Comment on lines 298 to +321
@@ -317,8 +318,11 @@ ENV PYTHONPATH=/fastsurfer:/opt/freesurfer/python/packages \
RUN <<EOF
source /venv/bin/activate
cd /fastsurfer
mkdir -p "$XDG_DATA_HOME"
Comment thread run_fastsurfer.sh
Comment on lines +961 to +962
lit_mask_output="${lit_out_dir}/inpainting_mask.nii.gz"
lit_inpainting_result="${lit_out_dir}/inpainting_volumes/inpainting_result.nii.gz"

| directory | filename | module | description |
|:----------|----------|--------|-------------|
| inpainting/inpainting_volumes | inpainting_mask.nii.gz | lit | copy of the input lesion mask in FastSurfer image space (after any optional dilation) |
Comment thread README.md
Examples
--------
The documentation includes [6 detailed Examples](doc/overview/EXAMPLES.md) on how to use FastSurfer.
The documentation includes [6 detailed Examples](doc/overview/EXAMPLES.md) on how to use FastSurfer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants