Skip to content

Lesion inpainting (LIT) integration#803

Merged
dkuegler merged 14 commits into
Deep-MI:devfrom
ClePol:pr/lit-integration-release
Apr 29, 2026
Merged

Lesion inpainting (LIT) integration#803
dkuegler merged 14 commits into
Deep-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 Outdated
Comment thread run_fastsurfer.sh Outdated
Comment thread doc/overview/OUTPUT_FILES.md Outdated
Comment thread README.md Outdated
@ClePol
Copy link
Copy Markdown
Member Author

ClePol commented Apr 28, 2026

Checks fail because neurolit 0.6.1 is not released

Copy link
Copy Markdown
Member

@dkuegler dkuegler left a comment

Choose a reason for hiding this comment

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

There are a couple of changes and inconsistencies with other FastSurfer things.. Also fix merge conflicts and checks. And please rebase instead of merging!

Comment thread doc/overview/modules/LIT.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md
Comment thread doc/overview/EXAMPLES.md Outdated
Comment thread run_fastsurfer.sh Outdated
Comment thread run_fastsurfer.sh Outdated
Comment thread run_fastsurfer.sh Outdated
Comment thread run_fastsurfer.sh
Comment thread run_fastsurfer.sh Outdated
@ClePol
Copy link
Copy Markdown
Member Author

ClePol commented Apr 29, 2026

@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

ClePol added 9 commits April 29, 2026 11:55
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.
@dkuegler dkuegler force-pushed the pr/lit-integration-release branch from 2d8526b to fd3126e Compare April 29, 2026 10:12
ClePol added 2 commits April 29, 2026 12:55
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.
@ClePol ClePol requested a review from dkuegler April 29, 2026 14:07
@ClePol
Copy link
Copy Markdown
Member Author

ClePol commented Apr 29, 2026

Addressed comments, I'm rerunning the LIT test-suite

Copy link
Copy Markdown
Member

@dkuegler dkuegler left a comment

Choose a reason for hiding this comment

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

Nice changes!

Comment thread doc/overview/modules/LIT.md Outdated
Comment thread doc/overview/EXAMPLES.md Outdated
Comment thread doc/overview/modules/LIT.md
Comment thread doc/overview/OUTPUT_FILES.md Outdated
Comment thread run_fastsurfer.sh Outdated
Comment thread run_fastsurfer.sh
Comment thread run_fastsurfer.sh Outdated
Comment thread run_fastsurfer.sh Outdated
Comment thread run_fastsurfer.sh Outdated
Comment thread run_fastsurfer.sh Outdated
@dkuegler dkuegler force-pushed the pr/lit-integration-release branch 2 times, most recently from 39b297f to 72bea58 Compare April 29, 2026 15:19
ClePol and others added 3 commits April 29, 2026 23:16
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
@dkuegler dkuegler force-pushed the pr/lit-integration-release branch from c99fd6e to d6e8df3 Compare April 29, 2026 21:18
@dkuegler dkuegler merged commit 7c3d437 into Deep-MI:dev Apr 29, 2026
3 checks passed
@m-reuter m-reuter added this to the FastSurfer v2.5 Release milestone May 12, 2026
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.

4 participants