Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Normalize BIDS-URIs to subject-relative #458

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

effigies
Copy link
Member

Fixes #456.

@effigies effigies force-pushed the fix/bids-uris-nonepi branch from 7c7de16 to 3d5f732 Compare September 24, 2024 14:34
Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.72%. Comparing base (18e5e95) to head (f9ac03c).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #458      +/-   ##
==========================================
+ Coverage   83.66%   83.72%   +0.05%     
==========================================
  Files          32       32              
  Lines        2816     2826      +10     
  Branches      377      380       +3     
==========================================
+ Hits         2356     2366      +10     
  Misses        390      390              
  Partials       70       70              

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

@effigies
Copy link
Member Author

@mgxd @oesteban A review would be appreciated.

fm.FieldmapFile(fmap.path, metadata=fmap.get_metadata())
fm.FieldmapFile(
fmap.path,
metadata=_filter_metadata(fmap.get_metadata(), layout, subject),
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we are reading the metadata too many times right?

has_intended = layout.get(
**{
**base_entities,
**{'suffix': 'epi', 'IntendedFor': Query.REQUIRED, 'session': sessions}
}
)

Then in 445 we use the _resolve_intent() filter, which is similar

target = layout.get_file(_resolve_intent(intent, layout, subject))

Perhaps we should try to avoid the second metadata read and use this one at FieldmapFile instantiation? (meaning, your fix looks good but the old code remains a bit brittle)

Copy link
Member Author

Choose a reason for hiding this comment

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

We're not actually duplicating reads because of:

for epi_fmap in has_intended:
if epi_fmap.path in fm._estimators.sources:
logger.debug("Skipping fieldmap %s (already in use)", epi_fmap.relpath)
continue # skip EPI images already considered above

Fieldmaps affected by this PR never reach the later code.

The issue here is that SDCflows will happily create an estimator for a "whole" fieldmap (doesn't need a bold/dwi/m0scan to compete it) that points to a B0FieldIdentifier, a subject-relative IntendedFor or a BIDS-URI. But when it's time to look up what estimator I should use for my BOLD file (get_identifier()), if I look for a subject-relative path, then I miss the BIDS-URIs.

So anyway, it could be that the better solution is for fMRIPrep to try bids::$DS_RELPATH along with $SUB_RELPATH, but when I started this it felt like SDCflows should expose the estimators the same way regardless.

Copy link
Member Author

Choose a reason for hiding this comment

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

@oesteban Just checking back in on this comment. It says outdated because we removed the unused layout parameter, but the structure didn't change.

@effigies effigies force-pushed the fix/bids-uris-nonepi branch from dfa3cac to e0e3f03 Compare September 24, 2024 21:01
Copy link
Contributor

@mgxd mgxd left a comment

Choose a reason for hiding this comment

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

Minor comment but looks good to me - I believe I tried breaking up the logic in the wrangler module sometime ago but glancing over it again and it was not enough...

sdcflows/utils/wrangler.py Outdated Show resolved Hide resolved
sdcflows/utils/wrangler.py Outdated Show resolved Hide resolved
sdcflows/utils/wrangler.py Outdated Show resolved Hide resolved
sdcflows/utils/wrangler.py Outdated Show resolved Hide resolved
sdcflows/utils/wrangler.py Outdated Show resolved Hide resolved
sdcflows/utils/wrangler.py Outdated Show resolved Hide resolved
@effigies effigies force-pushed the fix/bids-uris-nonepi branch from 98af39d to c4f8301 Compare October 1, 2024 22:11
@effigies effigies force-pushed the fix/bids-uris-nonepi branch from c4f8301 to f9ac03c Compare October 3, 2024 14:49
@effigies
Copy link
Member Author

effigies commented Oct 4, 2024

Going to merge, and we can address any brittleness in a future PR.

@effigies effigies merged commit 656a51d into nipreps:master Oct 4, 2024
13 checks passed
@effigies effigies deleted the fix/bids-uris-nonepi branch October 4, 2024 18:22
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.

BIDS URIs failing for at least some datasets
3 participants