Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spike inference fails on traces with NaNs #161

Open
jzaremba opened this issue Apr 24, 2015 · 0 comments
Open

Spike inference fails on traces with NaNs #161

jzaremba opened this issue Apr 24, 2015 · 0 comments
Labels

Comments

@jzaremba
Copy link
Member

As the title says.

Short-term solution would be to skip traces that have NaN's in them.

Long-term we'll want to be able to handle NaN's in the trace.

Additionally, need to ensure that sigma and gamma are estimated correctly with NaN values.

Example code that fails (modified from test_spikes.py):

import sima
import sima.spikes
import numpy as np
from scipy import signal
from scipy.stats import uniform, norm
import picos

RATE = 1  # mean firing rate of poisson spike train (Hz)
STEPS = 100  # number of time steps in data
TAU = 0.6  # time constant of calcium indicator (seconds)
DELTAT = 1/30  # time step duration (seconds)
sigma = 0.1    # standard deviation of gaussian noise
SEED = 2222    # random number generator seed

# Make a poisson spike trains
spikes = sima.spikes.get_poisson_spikes(
    deltat=DELTAT, rate=RATE, steps=STEPS, seed=SEED)

# Convolve with kernel to make calcium signal
np.random.seed(SEED)
gamma = 1 - (DELTAT / TAU)
CALCIUM = signal.lfilter([1], [1, -gamma], spikes)

# Make fluorescence traces with random gaussian noise and baseline
fluors = CALCIUM + norm.rvs(
    scale=sigma, size=STEPS) + uniform.rvs()
fluors[5:7] = np.nan

inference, fits, params = sima.spikes.spike_inference(fluors)
@jzaremba jzaremba added the bug label Apr 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant