Fix strict conform voxel center to agree with FreeSurfer and earlier FastSurfer versions#815
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts FastSurfer conforming behavior so strict conforming uses the FreeSurfer-style shape / 2 center convention, while soft/native paths retain voxel-center semantics for round-trip geometry preservation.
Changes:
- Adds a
voxel_centerswitch to reorientation center-fixing logic. - Updates strict vs soft/native reorientation paths to use different center conventions.
- Adds regression coverage and updates documentation around conform/native geometry behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
FastSurferCNN/data_loader/conform.py |
Implements center-convention selection in reorientation helpers. |
test/image/test_orientation_transform.py |
Updates existing center tests and adds strict FreeSurfer-center regression coverage. |
README.md |
Clarifies orig.mgz geometry expectations for CC/native processing. |
FastSurferCNN/README.md |
Documents strict conform vs native/soft geometry semantics. |
doc/scripts/RUN_FASTSURFER.md |
Updates CLI documentation for conform and keepgeom behavior. |
Comments suppressed due to low confidence (1)
FastSurferCNN/data_loader/conform.py:499
- This default changes the behavior of direct
from_vox2voxcalls with 3x3 transforms from the historical/nibabel voxel-center convention to FreeSurfer'sshape / 2convention. Since the strict conform path can opt intovoxel_center=Falseexplicitly, keeping this public helper's default asTruewould avoid introducing half-voxel shifts for existing generic reorientation callers.
*,
voxel_center: bool = False,
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The new voxel center convention (shape-1)/2 is problematic when performing strict conform. It leads to different image interpolation (not only shifts) compared to earlier FastSurfer versions and to FreeSurfer. As our ground truth for validation lies in the FreeSurfer space, DICE scores cannot be computed directly any longer.
We therefore switch back to FreeSurfer conventions for the center as shape/2 in the strict conform path.
Keepgeom/native_image still uses the (shape-1)/2 voxel center, to be compatible with nibabel and to allow round trip conversions without any shifts/cropping.
The third potential situation (soft-LIA but actual re-slicing due to e.g. voxel size changes) has not been tested, and could still be buggy. It is also not used in the FreeSurfer processing pipeline.