Skip to content

Commit 36995da

Browse files
committed
Handle cases where there are no spikes on an electrode
1 parent 6074a76 commit 36995da

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

replay_trajectory_classification/likelihoods/multiunit_likelihood.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Estimates a marked point process likelihood where the marks are
2-
features of the spike waveform. Features are float32."""
2+
features of the spike waveform. Features are float32."""
33

44
from __future__ import annotations
55

@@ -301,6 +301,8 @@ def fit_multiunit_likelihood(
301301
position_std,
302302
block_size=block_size,
303303
)
304+
else:
305+
marginal_density = np.zeros((place_bin_centers.shape[0],), dtype=np.float32)
304306

305307
summed_ground_process_intensity += estimate_intensity(
306308
marginal_density, occupancy, mean_rates[-1]

replay_trajectory_classification/likelihoods/multiunit_likelihood_gpu.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Estimates a marked point process likelihood where the marks are
2-
features of the spike waveform using GPUs. Features are float32."""
2+
features of the spike waveform using GPUs. Features are float32."""
33

44
from __future__ import annotations
55

@@ -118,7 +118,9 @@ def estimate_intensity(
118118
intensity : cp.ndarray, shape (n_bins,)
119119
120120
"""
121-
return cp.exp(estimate_log_intensity(density, occupancy, mean_rate))
121+
return cp.clip(
122+
cp.exp(estimate_log_intensity(density, occupancy, mean_rate)), a_min=1e-8
123+
)
122124

123125
def estimate_log_joint_mark_intensity(
124126
decoding_marks: cp.ndarray,
@@ -320,6 +322,10 @@ def fit_multiunit_likelihood_gpu(
320322
position_std,
321323
block_size=block_size,
322324
)
325+
else:
326+
marginal_density = cp.zeros(
327+
(place_bin_centers.shape[0],), dtype=cp.float32
328+
)
323329

324330
summed_ground_process_intensity += estimate_intensity(
325331
marginal_density, occupancy, mean_rates[-1]

0 commit comments

Comments
 (0)