Skip to content
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
9 changes: 7 additions & 2 deletions pylabianca/spike_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


# TODO: add n_jobs?
# CONSIDER wintype 'rectangular' vs 'gaussian'
# TODO: refactor (DRY: merge both loops into one?)
# TODO: consider adding `return_type` with `Epochs` option (mne object)
def compute_spike_rate(spk, picks=None, winlen=0.25, step=0.01, tmin=None,
Expand Down Expand Up @@ -229,8 +228,14 @@ def _spike_density(spk, picks=None, winlen=0.3, gauss_sd=None, fwhm=None,
# numerical errors, that do not seem to be present if we do one
# cell-trial at a time, this needs to be investigated a bit more
# but now we just set them to zero
# (this is likely related to numerical precision in computing the
# correlations via FFT)
# using oaconvolve (overlap-add convolution) instead of correlate
# helps, but does not solve the problem completely, so we still remove
# activity below a certain "noise level" threshold
# - [ ] CHECK if this is still an issue and whether the kernel is to
# blame
noise_level = 1e-14

mask = np.abs(cnt) < noise_level
cnt[mask] = 0.

Expand Down
2 changes: 2 additions & 0 deletions pylabianca/utils/xarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ def df_from_xarray_coords(xarr, dim):
'''
import pandas as pd
use_dims = find_nested_dims(xarr, dim)
if dim not in use_dims:
use_dims = [dim] + use_dims

if len(use_dims) > 1:
df = {dim: xarr.coords[dim].values for dim in use_dims}
Expand Down