Esempio n. 1
0
// .277 ms
bool neuron_state_update( REAL exc_input, REAL inh_input, neuron_pointer_t neuron ) {

	bool spike = false;
	REAL V_last = neuron->V_membrane;
	
	neuron->refract_timer -= refractory_time_update;  // countdown refractory timer
	
	if( neuron->refract_timer < 1 ) {  // test for outside refractory time
		
		input_this_timestep = exc_input - inh_input + neuron->I_offset; // now adding offset current - all need to be in nA

		lif_neuron_closed_form( neuron, V_last, -neuron->refract_timer );
//		ode_solve_fix_ss_expl( RK_METHOD, NO_OF_EXPL_FIX_STEPS, EXPL_FIX_STEP_SIZE, neuron );
//	   ode_solve_fix_ss_expl_rk2_v1( NO_OF_EXPL_FIX_STEPS, EXPL_FIX_STEP_SIZE, neuron );
	   
		spike = REAL_COMPARE( neuron->V_membrane, >=, neuron->V_thresh );  // has it spiked?
		
#ifdef CORRECT_FOR_THRESHOLD_GRANULARITY		
	
		if( spike ) {

			REAL A, B, thresh;

// calculate the two simple linear indicators of where the threshold was cut
			thresh = neuron->V_thresh;
			
			A = neuron->V_membrane - thresh;
			B = thresh - V_last;
			
			if			( A >= 2*B ) 	neuron->prev_spike_code = 2; 	// it spiked in first third
			else if  ( B >= 2*A ) 	neuron->prev_spike_code = 0;	// it spiked in last third
			else						 	neuron->prev_spike_code = 1; 	// it spiked near middle

//			io_printf( IO_STD, " A %9.4k   B %9.4k  code %u \n", A, B, neuron->prev_spike_code );
			
			neuron_discrete_changes( neuron );
			}	
				
#else  // works for both no correction and simple correction case
		if( spike ) neuron_discrete_changes( neuron );
#endif		
		}
bool neuron_state_update( REAL exc_input, REAL inh_input, REAL external_bias, neuron_pointer_t neuron ) {

	input_this_timestep = exc_input - inh_input + external_bias + neuron->I_offset; 	// all need to be in nA

	rk2_kernel_midpoint( neuron->this_h, neuron );  						// the best AR update so far

	
   // create noisy membrane voltage by adding Gaussian noise with SD = membrane_noise_sd
   REAL noisy_membrane = neuron->V + norminv_urb( mars_kiss32() ) * neuron->membrane_noise_sd;

   // compare noisy membrane voltage with threshold
   bool spike = REAL_COMPARE( noisy_membrane, >=, V_threshold );


	if( spike ) {
		neuron_discrete_changes( neuron );
		neuron->this_h = machine_timestep * SIMPLE_TQ_OFFSET; //REAL_CONST( 1.85 );  // simple threshold correction - next timestep (only) gets a bump
		}
	else
		neuron->this_h = machine_timestep;

	return spike;
}