Skip to content

Commit

Permalink
ENH filter_data: automatically coerce input to float
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbrodbeck committed Jun 3, 2021
1 parent 6297441 commit 78fef6d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion eelbrain/_ndvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,8 @@ def filter_data(
Returns
-------
filtered_ndvar
NDVar with same dimensions as ``ndvar`` and filtered data.
NDVar with same dimensions as ``ndvar`` and filtered data. The output
type is always floating point regardless of the type of ``ndvar``.
"""
axis = ndvar.get_axis('time')
if axis == ndvar.ndim:
Expand All @@ -566,6 +567,9 @@ def filter_data(
data = ndvar.x.swapaxes(axis, -1)
sfreq = 1. / ndvar.time.tstep

if data.dtype.kind != 'f':
data = data.astype(float)

filter_kwargs.setdefault('copy', True)
x = mne.filter.filter_data(data, sfreq, low, high, **filter_kwargs)

Expand Down

0 comments on commit 78fef6d

Please sign in to comment.