Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

[FIX] Design matrices are wrong if multiple events in the same regressor have the same onset or offset #442

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions nistats/hemodynamic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -290,7 +292,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, v in zip(t_offset, values):
regressor[t] -= v

regressor = np.cumsum(regressor)

return regressor, hr_frame_times
Expand Down