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

Add Hilbert RVT (Harrison et al. 2020) #22

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tsalo
Copy link
Member

@tsalo tsalo commented Dec 30, 2020

Closes #10.

This adds a new function (chest_belt.hilbert_rvt()) to calculate the Hilbert transform-based RVT metric from Harrison et al. (2020). This implementation is based on the manuscript, rather than any available code (couldn't find any).

Proposed Changes

  • Add metrics.chest_belt.hilbert_rvt() to calculate the new metric.
  • Add a number of functions to metrics.chest_belt.utils module in support of the new metric.

Change Type

  • bugfix (+0.0.1)
  • minor (+0.1.0)
  • major (+1.0.0)
  • refactoring (no version update)
  • test (no version update)
  • infrastructure (no version update)
  • documentation (no version update)
  • other

Checklist before review

  • I added everything I wanted to add to this PR.
  • [Code or tests only] I wrote/updated the necessary docstrings.
  • [Code or tests only] I ran and passed tests locally.
  • [Documentation only] I built the docs locally.
  • My contribution is harmonious with the rest of the code: I'm not introducing repetitions.
  • My code respects the adopted style, especially linting conventions.
  • The title of this PR is explanatory on its own, enough to be understood as part of a changelog.
  • I added or indicated the right labels.
  • I added information regarding the timeline of completion for this PR.
  • Please, comment on my PR while it's a draft and give me feedback on the development!

@tsalo tsalo changed the title [ENH] Add Hilbert RVT from Harrison et al. (2020) Add Hilbert RVT from Harrison et al. (2020) Dec 30, 2020
Comment on lines +56 to +57
# not sure why pi is here but it's in the preprint's formula
ibr = np.append(0, np.diff(phas)) / (2 * np.pi)
Copy link
Member Author

Choose a reason for hiding this comment

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

Per @CesarCaballeroGaudes, this seems to normalize radians (see #10 (comment)).

Comment on lines +62 to +64
# low-pass filter both(?) at 0.2Hz
ibr = butter_bandpass_filter(ibr, fs=sampling_freq, highcut=0.75)
rv = butter_bandpass_filter(rv, fs=sampling_freq, highcut=0.75)
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if both signals should be low-pass filtered here, or if just one should be.

Comment on lines +47 to +51
# Reconstruct the oscillatory portion of the signal, cos(𝜙(𝑡)),
# and lowpass filter at 0.75 Hz to remove any resulting artefacts.
oscill = np.cos(phas)
oscill = butter_bandpass_filter(oscill, fs=sampling_freq, highcut=0.75)
phas = np.arccos(oscill)
Copy link
Member Author

@tsalo tsalo Dec 30, 2020

Choose a reason for hiding this comment

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

It seems to me that a number of transformations could be done here, and I'm not sure why one was chosen over the others:

  1. phase to oscillatory portion of signal (as is done)
  2. phase + magnitude to analytic signal, to be split again after low-pass filtering (assuming filtfilt can work with complex-valued data).
  3. phase + magnitude to reconstructed original signal, to be transformed again using the Hilbert after low-pass filtering.
  4. Just filtering the phase signal, right?

from scipy import signal


def get_butter_filter(fs, lowcut=None, highcut=None, order=5):
Copy link
Member Author

Choose a reason for hiding this comment

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

Is a Butterworth filter (+ filtfilt) the way to go?

@tsalo tsalo changed the title Add Hilbert RVT from Harrison et al. (2020) Add Hilbert RVT (Harrison et al. 2020) Jan 8, 2021
@tsalo tsalo added the Minormod This PR generally closes an "Enhancement" issue. It increments the minor version (0.+1.0) label Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Minormod This PR generally closes an "Enhancement" issue. It increments the minor version (0.+1.0)
Projects
Status: Need help!
Development

Successfully merging this pull request may close these issues.

Improved RVT calculation with Hilbert transform
1 participant