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

Faster way to implement optional delay to current Injection. #15

Open
russelljjarvis opened this issue Apr 18, 2020 · 2 comments
Open

Comments

@russelljjarvis
Copy link
Collaborator

russelljjarvis commented Apr 18, 2020

I am using SpikingNeuralNetworks in the context of single neuron model optimization.To take simulated electrical measurements of the cell model I need the membrane potential to be quiescent for some duration before and after stimulation. I introduced an optional delay to the sim argument. I was wondering if there is a neater way to implement the delay without counters? I am wondering if the approach I have adopted will harm performance?

Thanks.
Russell.

function sim!(P, C; dt = 0.25ms, simulation_duration = 1300ms, delay = 300ms,stimulus_duration=1000ms)
    temp = deepcopy(P[1].I)
    size = simulation_duration/dt
    cnt1 = 0
    for t = 0ms:dt:simulation_duration
        cnt1+=1
        if cnt1 < delay/dt 
           P[1].I[1] = 0.0 
        end 
        if cnt1 > (delay/dt + stimulus_duration/dt)
	   P[1].I[1] = 0.0 
        end 
        if (delay/dt) < cnt1 < (stimulus_duration/dt)  
           P[1].I[1] = maximum(temp[1])
        end
        sim!(P, C, dt)
    end
end

https://github.com/russelljjarvis/NeuronUnitOpt.jl/blob/master/src/main.jl#L6-L27

@AStupidBear
Copy link
Owner

@russelljjarvis Your approach is fine. I can't think up a better way.

@jpsamaroo
Copy link
Collaborator

I think we'll eventually be able to do this better. I've written my own personal SNN packages in the past which have implemented this by adding callbacks to each neuron/synapse "layer"; I think once we move to using OrdinaryDiffEq for solving we'll be able to make use of their callbacks for the same purposes. Let's keep this issue open until we have a nice interface for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants