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 lag application for negative lags #36

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phys2denoise/metrics/cardiac.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _crf(t):

dt = tr / oversampling
time_stamps = np.linspace(
0, time_length, np.rint(float(time_length) / dt).astype(np.int)
0, time_length, np.rint(float(time_length) / dt).astype(int)
)
time_stamps -= onset
crf_arr = _crf(time_stamps)
Expand Down
4 changes: 2 additions & 2 deletions phys2denoise/metrics/chest_belt.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def env(resp, samplerate, window=10):


@due.dcite(references.CHANG_GLOVER_2009)
def rv(resp, samplerate, window=6, lags=(0,)):
def rv(resp, samplerate, window=6):
"""Calculate respiratory variance.

Parameters
Expand Down Expand Up @@ -260,7 +260,7 @@ def _rrf(t):

dt = tr / oversampling
time_stamps = np.linspace(
0, time_length, np.rint(float(time_length) / dt).astype(np.int)
0, time_length, np.rint(float(time_length) / dt).astype(int)
)
time_stamps -= onset
rrf_arr = _rrf(time_stamps)
Expand Down
4 changes: 2 additions & 2 deletions phys2denoise/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ def apply_lags(arr1d, lags):
arr_with_lags = np.zeros((arr1d.shape[0], len(lags)))
for i_lag, lag in enumerate(lags):
if lag < 0:
arr_delayed = np.hstack((arr1d[lag:], np.zeros(lag)))
arr_delayed = np.hstack((arr1d[abs(lag):], np.zeros(abs(lag))))
elif lag > 0:
arr_delayed = np.hstack((np.zeros(lag), arr1d[lag:]))
arr_delayed = np.hstack((np.zeros(lag), arr1d[:-lag]))
else:
arr_delayed = arr1d.copy()
arr_with_lags[:, i_lag] = arr_delayed
Expand Down