Skip to content

FIX: Improve FreeSurfer ID predictability#3607

Draft
mgxd wants to merge 8 commits intonipreps:masterfrom
mgxd:enh/source-file
Draft

FIX: Improve FreeSurfer ID predictability#3607
mgxd wants to merge 8 commits intonipreps:masterfrom
mgxd:enh/source-file

Conversation

@mgxd
Copy link
Collaborator

@mgxd mgxd commented Feb 11, 2026

The intent after #3495 was encode as much information on how the anatomical template was formed into the FreeSurfer subject ID, but this introduced problems where the resulting FS ID could not be reused across a few cases:

  • A new session was added after a previous run.
  • Func-only processing leveraging precomputed derivatives from another session.

Starting this draft to think on how to cleanly address this in the future series.

Example 1

Assume we have sub-01 with a single session, pre:

--subject-anat-reference FS ID (<25.2.x) FS ID (25.2.x) FS ID (26.0.x)
sessionwise n/a sub-01_ses-pre sub-01_ses-pre
first-lex sub-01 sub-01_ses-pre sub-01
unbiased sub-01 sub-01_ses-pre sub-01

Now if a post session was added, the post's anatomical will be used in first-lex.

--subject-anat-reference FS ID (<25.2.x) FS ID (25.2.x) FS ID (26.0.x)
sessionwise n/a sub-01_ses-pre, sub-01_ses-post sub-01_ses-pre, sub-01_ses-post
first-lex sub-01 sub-01_ses-post+pre ?
unbiased sub-01 sub-01_ses-post+pre ?

IMO, sub-01 is misleading for both first-lex and unbiased, and only becomes hazier as additional sessions are added. Perhaps instead of changing the ID, some metadata (Sources) can be tied directly to the FreeSurfer subjects dir.

Example 2

sub-Z has one anat and many funcX sessions. anat was processed with --anat-only and will be reused via --derivatives

--subject-anat-reference FS ID (<25.2.x) FS ID (25.2.x) FS ID (26.0.x)
sessionwise n/a func session, no anat found n/a
first-lex sub-Z sub-Z_anat+func1+.. sub-Z
unbiased sub-Z sub-Z_anat+func1+.. sub-Z

Suggestions and additional examples are welcome and appreciated.

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.18%. Comparing base (9f426f7) to head (a898448).

Files with missing lines Patch % Lines
fmriprep/interfaces/bids.py 88.88% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3607      +/-   ##
==========================================
- Coverage   73.19%   73.18%   -0.01%     
==========================================
  Files          60       60              
  Lines        4839     4834       -5     
  Branches      628      629       +1     
==========================================
- Hits         3542     3538       -4     
+ Misses       1156     1154       -2     
- Partials      141      142       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant