Skip to content

Conversation

jmumford
Copy link
Contributor

Overview

When users correctly specify fir_delays (FIRDelays in a model spec), they provide delays in TR units. However, in compute_regressor within the Convolve class, the resulting FIR regressors were constructed incorrectly, which showed up as unexpected temporal shifts in the regressors.

This happens because compute_regressor assumes that the provided frame_times are defined at the same temporal resolution as the fir_delays specification (typically TR units). In pybids, frame_times is set to resample_frames, which may have a different resolution than the TR. As a result, the FIR shifts were misspecified, and the regressors did not reflect the intended delays.

Changes

  1. Create fir_delays_resample_adjusted and use it in compute_regressor to correctly align delays with the resampled frame times.
  2. Repair the regressor names returned by compute_regressor (issue caused by Change 1). The names embed the delay value input (fir_delays_resample_adjusted), so the resampled delays are replaced with the original fir_delays to ensure consistency with model/contrast specification.

Things an expert should review closely

  • I am assuming that tr is always available via tr = var.run_info[0].tr. I’m fairly confident this is the case, but it may be worth confirming.
  • I am assuming that resample_frames contains uniformly spaced frame times. This may not hold for inputs that are not SparseRunVariable objects. This matters because the sampling interval is computed as dt = resample_frames[1] - resample_frames[0], and any non-uniform spacing could affect the FIR delay adjustment.

Copy link

codecov bot commented Sep 12, 2025

Codecov Report

❌ Patch coverage is 22.22222% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.25%. Comparing base (8895e28) to head (f244774).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/bids/modeling/transformations/compute.py 22.22% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1164      +/-   ##
==========================================
- Coverage   89.33%   89.25%   -0.09%     
==========================================
  Files          66       66              
  Lines        7259     7268       +9     
  Branches     1149     1152       +3     
==========================================
+ Hits         6485     6487       +2     
- Misses        565      570       +5     
- Partials      209      211       +2     

☔ 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.

@jmumford
Copy link
Contributor Author

Bah! Something is off (other than my missing tests). Michael tested this and found it was including a lag0 by default (even though that wasn't specified), so I'll look into that issue next.

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.

2 participants