Skip to content

Cc subsegment ordering#836

Merged
m-reuter merged 3 commits into
Deep-MI:devfrom
ClePol:cc_subsegment_ordering
Jun 2, 2026
Merged

Cc subsegment ordering#836
m-reuter merged 3 commits into
Deep-MI:devfrom
ClePol:cc_subsegment_ordering

Conversation

@ClePol

@ClePol ClePol commented Jun 1, 2026

Copy link
Copy Markdown
Member

This PR proposes a fix for an unnoticed regression prior to the FastSurfer 2.5.0 release, where the midline was not always oriented anterior->posteior. This caused inconsistent mapping of CC subsegments, where only two large segments would be written to the aseg. This is commit 9a255f0

The second, larger, commit hardens the sub-segmentation logic by not interrupting the control flow when subsegmentation fails for one slice. This can happen for bad CC segmentations, e.g. images with head motion.
We can however recover from this if at least one slice is intact. In that case the subsegmentation can still be propagated to adjacent slices and painted into the aseg. The code also includes a WARNING for this special case.

Testing was done on 5 previously failing cases with --seg_only

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a regression where the CC midline was not consistently oriented anterior→posterior (causing CC subsegments to be mismapped), and hardens the per-slice subsegmentation pipeline so a single bad slice no longer aborts the whole run.

Changes:

  • In thickness.py, after solving the Laplace level path, flip the equidistant midline if it does not start at the anterior endpoint.
  • In postprocessing.py, switch from executor.map + _zip_failed to as_completed, store per-slice results/contours in fixed-position lists (with None for failures), and propagate num_failed_slices cleanly.
  • In fastsurfer_cc.py, derive result_slice_indices, pick the nearest valid slice when the middle slice fails (with a warning), gate volume/area-change checks on num_failed_slices == 0, and record selected_morphometry_slice* metrics.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
CorpusCallosum/shape/thickness.py Enforce anterior→posterior orientation of the midline level path.
CorpusCallosum/shape/postprocessing.py Reorder slice processing via as_completed and tolerate per-slice failures via positional None placeholders.
CorpusCallosum/fastsurfer_cc.py Fallback to nearest valid middle slice, expose new fallback metrics, guard volume/area checks when slices failed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CorpusCallosum/fastsurfer_cc.py Outdated
Comment thread CorpusCallosum/fastsurfer_cc.py Outdated
Comment thread CorpusCallosum/shape/postprocessing.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@m-reuter m-reuter merged commit 07d89f3 into Deep-MI:dev Jun 2, 2026
3 checks passed
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.

3 participants