Skip to content

Improve talairach transform and etiv estimation through atlas prealignment#807

Merged
m-reuter merged 21 commits into
Deep-MI:devfrom
kdiers:fix/conform-reorient
May 5, 2026
Merged

Improve talairach transform and etiv estimation through atlas prealignment#807
m-reuter merged 21 commits into
Deep-MI:devfrom
kdiers:fix/conform-reorient

Conversation

@kdiers
Copy link
Copy Markdown
Contributor

@kdiers kdiers commented Apr 29, 2026

This PR intends to improve talairach transform and etiv estimation through atlas prealignment.

  • Previous talairach transforms have been reported to suffer from registration failures, leading to biased etiv estimates.
  • To make talairach registration more robust, we introduce an additional affine prealignment to the mni_icbm152_t1_tal_nlin_asym_09c template, based on neuroreg's centroid segmentation (segreg).
  • The talairach_avi routine will then be based on the prealigned image, which gives a better starting point for the registration.
  • The final talairach transform will be the concatenation of the transforms returned by the segreg and talairach_avi registrations.

@dkuegler
Copy link
Copy Markdown
Member

Should we delete the prealigned image file after talairach-registration was done? We can keep the ltas, but the image file can be deleted, no?

@kdiers
Copy link
Copy Markdown
Contributor Author

kdiers commented Apr 29, 2026

Already marking as "ready for review", but still intending to add update to new neuroreg release.

@kdiers kdiers marked this pull request as ready for review April 29, 2026 11:58
@kdiers
Copy link
Copy Markdown
Contributor Author

kdiers commented Apr 29, 2026

No further commits planned currently and ready for review now @m-reuter , @dkuegler

ClePol added a commit to ClePol/FastSurfer that referenced this pull request Apr 29, 2026
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.

Use the shared get_script_path_python helper for lit-inpainting and lit-postprocessing instead of a local run_fastsurfer.sh helper. The helper is adapted from Deep-MI/FastSurfer PR Deep-MI#807 and runs package entry points through the configured --py interpreter after command -v checks. Limit --skip-segstats to the explicit --seg_only plus --no_biasfield case and use the shared LIT output filename variables throughout.
@m-reuter m-reuter requested a review from Copilot April 29, 2026 14:38
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

This PR strengthens Talairach registration robustness (and downstream eTIV estimation) by introducing an affine prealignment step based on neuroreg centroid-based registration, then concatenating that prealignment with the existing talairach_avi transform.

Changes:

  • Add neuroreg-based centroid prealignment prior to talairach_avi, and concatenate transforms into the final Talairach transform.
  • Plumb through new CLI args (--py, --asegdkt_segfile) to talairach-reg.sh from the main entrypoints.
  • Add neuroreg as a dependency and add a centroid JSON resource for the target template.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
run_fastsurfer.sh Passes Python command + segmentation path into Talairach registration step.
recon_surf/recon-surf.sh Passes Python command + segmentation path into Talairach registration step.
recon_surf/talairach-reg.sh Implements segreg-based prealignment, runs talairach_avi on prealigned image, concatenates transforms.
recon_surf/functions.sh Adds helper to locate Python-provided console scripts (segreg, lta).
recon_surf/segreg_mni_icbm152_t1_tal_nlin_asym_09c_centroids.json Adds centroid definition data intended for the prealignment.
requirements.txt Adds neuroreg to the frozen (container-derived) dependency list.
requirements.cpu.txt Adds neuroreg to the frozen CPU dependency list.
requirements.mac.txt Adds neuroreg to macOS dependency list.
pyproject.toml Declares neuroreg as a project dependency.
Comments suppressed due to low confidence (1)

recon_surf/talairach-reg.sh:85

  • talairach-reg.sh now relies on --py and --asegdkt_segfile, but they are not included in the required-argument validation loop (only --dir/--conformed_name/--norm_name are checked). If a caller omits either flag, the script will fail later with less actionable errors. Add explicit validation for python and asegdkt_segfile (or provide safe defaults) before running segreg.
  --py) python="$1" ; shift ;;
  --asegdkt_segfile) if checkfile "$1" ; then exit 1; fi ; asegdkt_segfile="$1" ; shift ;;
  --edits) edits="true" ;;
  --3t) atlas3T="true" ;;
  *) echo "ERROR: Unrecognized argument $key!" ; usage ; exit 1 ;;
esac
done

for arg_spec in "dir=$mdir" "conformed_name=$conformed_name" "norm_name=$norm_name"
do
  arg=$(echo "$arg_spec" | cut -d"=" -f1)
  value=$(echo "$arg_spec" | cut -d"=" -f2)
  if [[ -z "$value" ]] ; then
    echo "ERROR: --$arg is a required argument, but no value was passed!"
    exit 1
  fi
done

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

Comment thread recon_surf/talairach-reg.sh
Comment thread recon_surf/talairach-reg.sh Outdated
Comment thread requirements.mac.txt Outdated
Comment thread recon_surf/functions.sh Outdated
Comment thread recon_surf/functions.sh Outdated
Comment thread recon_surf/functions.sh Outdated
@dkuegler dkuegler force-pushed the fix/conform-reorient branch 2 times, most recently from 2f6b4c2 to 2f682cc Compare April 29, 2026 21:54
@dkuegler dkuegler requested a review from Copilot April 30, 2026 07:38
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

Improves robustness of Talairach registration (and downstream eTIV estimation) by adding an affine atlas prealignment step using neuroreg centroid-based registration, then concatenating transforms for the final Talairach transform.

Changes:

  • Add neuroreg as a dependency (pip requirements + pyproject.toml).
  • Pass Python interpreter and asegdkt segmentation into the Talairach registration script.
  • Update Talairach registration to: (1) compute a segreg-based prealignment, (2) run talairach_avi from the prealigned image, (3) concatenate transforms.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
run_fastsurfer.sh Passes --py and --asegdkt_segfile into Talairach registration invocation.
recon_surf/recon-surf.sh Passes --py and --asegdkt_segfile into talairach-reg.sh from recon-surf pipeline.
recon_surf/talairach-reg.sh Implements the new neuroreg prealignment + transform concatenation flow.
requirements.txt Adds neuroreg==0.6.0 to the container freeze requirements.
requirements.cpu.txt Adds neuroreg==0.6.0 to the CPU container freeze requirements.
pyproject.toml Adds neuroreg>=0.6.0 to project dependencies.
CerebNet/data_loader/dataset.py Refactors TypedDict typing for ROI metadata and adjusts construction.

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

Comment thread recon_surf/talairach-reg.sh
Comment thread recon_surf/talairach-reg.sh Outdated
Comment thread recon_surf/talairach-reg.sh Outdated
Comment thread recon_surf/talairach-reg.sh Outdated
Comment thread CerebNet/data_loader/dataset.py Outdated
@dkuegler dkuegler force-pushed the fix/conform-reorient branch from 8bd2642 to e3b4053 Compare April 30, 2026 08:29
@dkuegler dkuegler force-pushed the fix/conform-reorient branch from e3b4053 to ebe1024 Compare April 30, 2026 09:41
Comment thread recon_surf/talairach-reg.sh Outdated
@m-reuter m-reuter merged commit 0d9a962 into Deep-MI:dev May 5, 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