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

Release Info on PhysIO RVT/HRV Bugfix #65

Closed
mrikasper opened this issue Aug 20, 2019 · 1 comment
Closed

Release Info on PhysIO RVT/HRV Bugfix #65

mrikasper opened this issue Aug 20, 2019 · 1 comment
Assignees
Labels
bug physio Issues related to PhysIO Toolbox

Comments

@mrikasper
Copy link
Member

No description provided.

@mrikasper mrikasper added bug physio Issues related to PhysIO Toolbox labels Aug 20, 2019
@mrikasper mrikasper self-assigned this Aug 20, 2019
@mrikasper mrikasper changed the title Test for next release v3.2.0 Release Info on PhysIO RVT/HRV Bugfix Aug 29, 2019
@mrikasper
Copy link
Member Author

Release Info on PhysIO RVT/HRV Bugfix

Summary

In July 2019, Samuel Harrison, TNU, spotted a bug in the heart rate variability (HRV) and respiratory volume per time (RVT) models of the PhysIO Toolbox.

In practice, this led to the final HRV/RVT regressors being shifted forward by about 15 (HRV) or 30 (RVT) seconds compared to the actual time course of the experiment.

Importantly, the bug does not affect any of the RETROICOR model regressors typically employed by PhysIO users.

The bug has been fixed in August 2019 with PhysIO R2019b (v7.2.0), shipped with TAPAS v3.2.0.

Who is affected?

  • Most users who included the HRV/RVT models in PhysIO
  • Exception: You have also included delayed versions of the regressors at delays of about -15s or -30s for HRV and RVT, respectively.

Do I have to worry?

There are two different scenarios:

  1. HRV/RVT modeling is exclusively performed to reduce physiological noise
    This is typically the case for resting-state analyses and those task-based analysis, where the research question and experimental design is unrelated to physiological modulations. In this case, you might not have optimally accounted for all physiological noise by the old HRV/RVT models, which reduces sensitivity somewhat (see results below), but overall, your results for effects of interest will probably not change much.

  2. HRV/RVT modeling is performed to understand effects of heart-rate variability/breathing changes on the BOLD signal
    This is the case if your research question has a focus on experimentally-induced heart rate or breathing changes on the BOLD response - either by the task design, or by, e.g., a pharmacological intervention. In this case, if you investigated parameters related to the HRV/RVT parameter estimates of the models, your results could significantly change, for example in terms of effect sizes and signs, or estimated delay changes.

The nature of the bug

  • The standard implementation of z = conv(x,y) in Matlab produces a result with length(z) = length(x) + length(y) - 1
  • In order to have output with the same length as the input traces, we used z = conv(x,y,'same'), making z and x the same length.
  • However, the cropping of z was performed symmetrically on both ends of the convolved time course, effectively cropping its beginning by half the length of the convolution kernel y.
  • Below, you see how the convolution of a breathing impulse (stick function at t = 50s) with the respiratory response function (RRF), is shifted by 30 seconds (half the width of the RRF) using the 'same' instead of the 'full' option.
figure('DefaultLineLineWidth', 2); 

rrf = tapas_physio_rrf(0:60);
impulse = [zeros(1,50), 1.0, zeros(1,60)];

plot(impulse); hold all;
plot(conv(impulse, rrf, 'same')); 
plot(conv(impulse, rrf, 'full'));

legend('impulse at t=50 s', 'conv(...''same'')', 'conv(...''full'')')
xlabel('t (seconds)');

conv_same_vs_full

Bugfix

  • We now use our own wrapper tapas_physio_conv that also supports the cropping of the convolved time series at the end of the result only. This is the default.
  • We implemented a few unit tests to ensure compatibility with Matlab's conv and expected behavior for the HRV/RVT models.

Group level results from a TNU study

Here, we illustrate the difference in group level GLM results for the RVT regressors before and after the bugfix for a group of 70 healthy subjects. In summary, the original models before the bugfix had the following properties (illustrated for RVT, but similar for HRV):

  1. The overall effect had the wrong sign (Fig. 1 vs 2 below).
    • This would not impact on noise reduction performance, but only change interpretation, if HRV/RVT were regressors of interest.
  2. The effect sizes in regions of high RVT-related fluctuations were underestimated (Fig. 2 vs 3).
  3. The mean of the main effect t-distribution throughout the brain was scarcely affected (Fig. 4).

Figure 1: Main effect of RVT, before bugfix (raw t-stats):

before

Figure 2: Main effect of RVT, before bugfix (sign-flipped raw t-stats):

before_signflipped

Figure 3: Main effect of RVT, after bugfix (raw t-stats):

after

Figure 4: Histograms of t-stats (pre-bugfix is sign-flipped & red; post-bugfix is blue):

hist_before_after

tnutapas added a commit that referenced this issue Aug 30, 2019
## [3.2.0] 2019-09-29

### Added
- HUGE: introduced object-oriented interface in addition to old interface
- HUGE: build-in unit tests
- HUGE: user manual
- PhysIO (details in tapas/PhysIO/CHANGELOG.md)
    - more unit testing and integration testing for examples
    - bandpass-filtering for cardiac data in preprocessing, user-defined max
    heart rate for peak detection

### Fixed
- PhysIO: Bugfix RVT/HRV convolution had erroneous half-width shift
    - For details on the bug, its impact and fix, see our specific [Release
    Info on RVT/HRV Bugfix](#65)

### Changed
- HUGE: demo script reflect interface changes
likeajumprope pushed a commit to likeajumprope/tapas that referenced this issue Jan 17, 2024
## [3.2.0] 2019-09-29

### Added
- HUGE: introduced object-oriented interface in addition to old interface
- HUGE: build-in unit tests
- HUGE: user manual
- PhysIO (details in tapas/PhysIO/CHANGELOG.md)
    - more unit testing and integration testing for examples
    - bandpass-filtering for cardiac data in preprocessing, user-defined max
    heart rate for peak detection

### Fixed
- PhysIO: Bugfix RVT/HRV convolution had erroneous half-width shift
    - For details on the bug, its impact and fix, see our specific [Release
    Info on RVT/HRV Bugfix](translationalneuromodeling#65)

### Changed
- HUGE: demo script reflect interface changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug physio Issues related to PhysIO Toolbox
Projects
None yet
Development

No branches or pull requests

1 participant