From 2942034d766f51576a539f4208d1076986518494 Mon Sep 17 00:00:00 2001 From: mwegrzyn Date: Mon, 24 Feb 2020 12:16:11 +0100 Subject: [PATCH 1/2] changed behavior of _sample_condition when multiple events have the same offset --- nistats/hemodynamic_models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nistats/hemodynamic_models.py b/nistats/hemodynamic_models.py index 85f75c63..1cd60014 100644 --- a/nistats/hemodynamic_models.py +++ b/nistats/hemodynamic_models.py @@ -290,7 +290,9 @@ def _sample_condition(exp_condition, frame_times, oversampling=50, if t < (tmax - 1) and t == t_onset[i]: t_offset[i] += 1 - regressor[t_offset] -= values + for t in t_offset: + regressor[t_offset] -= values + regressor = np.cumsum(regressor) return regressor, hr_frame_times From 7f600e766333f4e2dbbe4d456fc2fe8cc1bc0b8c Mon Sep 17 00:00:00 2001 From: mwegrzyn Date: Mon, 24 Feb 2020 16:02:11 +0100 Subject: [PATCH 2/2] sample_conditon allows for overlapping onsets/offsets --- nistats/hemodynamic_models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nistats/hemodynamic_models.py b/nistats/hemodynamic_models.py index 1cd60014..e71a7042 100644 --- a/nistats/hemodynamic_models.py +++ b/nistats/hemodynamic_models.py @@ -281,7 +281,9 @@ def _sample_condition(exp_condition, frame_times, oversampling=50, tmax = len(hr_frame_times) regressor = np.zeros_like(hr_frame_times).astype(np.float) t_onset = np.minimum(np.searchsorted(hr_frame_times, onsets), tmax - 1) - regressor[t_onset] += values + for t, v in zip(t_onset, values): + regressor[t] += v + t_offset = np.minimum(np.searchsorted(hr_frame_times, onsets + durations), tmax - 1) @@ -290,8 +292,8 @@ def _sample_condition(exp_condition, frame_times, oversampling=50, if t < (tmax - 1) and t == t_onset[i]: t_offset[i] += 1 - for t in t_offset: - regressor[t_offset] -= values + for t, v in zip(t_offset, values): + regressor[t] -= v regressor = np.cumsum(regressor)