void prepare_tetanus(struct network * network, char * filename) { long num_neuron, num_compartment; double start, length, current, periodicity, i; int direct; char line[MAX_LINE_LEN]; FILE * fp = open_file_to_section(filename,"@TETANUS"); fgets(line, MAX_LINE_LEN, fp); remove_newline(line); while(strcmp(line,"") != 0 && strcmp(line,"0") != 0) { sscanf(line, "%ld %ld %d %lf %lf %lf %lf", &num_neuron, &num_compartment, &direct, &start, &length, &periodicity, ¤t); if(network->neurons[num_neuron]->compartments[num_compartment]->stimuli == NULL) network->neurons[num_neuron]->compartments[num_compartment]->stimuli = init_stimuli_struct(); if(network->stimuli == NULL) network->stimuli = init_stimuli_struct(); for(i = start; i < network->runtime[1]; i += periodicity) { stimulate(network, num_neuron, num_compartment, i, i + length, direct, current); } fgets(line, MAX_LINE_LEN, fp); remove_newline(line); } fclose(fp); }
void Neuron::stimulate_step(){ if( stimulation >= threshold ){ stimulation = 0; for( auto it = outputs.begin(); it != outputs.end(); it++ ){ stimulate(*it); } output = output_strength; }else{ output = 0; } stimulation *= (1 - stim_decay); }
void init_stimuli(struct network * network, char * filename) { long num_neuron, num_compartment; double start, end, current; int direct; char line[MAX_LINE_LEN]; FILE * fp = open_file_to_section(filename,"@STIMULI"); fgets(line, MAX_LINE_LEN, fp); remove_newline(line); while(strcmp(line,"") != 0 && strcmp(line,"0") != 0) { sscanf(line, "%ld %ld %d %lf %lf %lf", &num_neuron, &num_compartment, &direct, &start, &end, ¤t); if(num_neuron < 0 || num_neuron > network->size - 1) { printf("init_stimuli(): config file says to stimulate neuron that doesn't exist (#%ld, network size is %ld\n",num_neuron,network->size); exit(-1); } if(num_compartment < 0 || num_compartment > network->compartments - 1) { printf("init_stimuli(): config file says to stimulate compartment that doesn't exist (#%ld, neuron has %ld compartments\n",num_compartment,network->compartments); exit(-1); } if(network->neurons[num_neuron]->compartments[num_compartment]->stimuli == NULL) network->neurons[num_neuron]->compartments[num_compartment]->stimuli = init_stimuli_struct(); if(network->stimuli == NULL) network->stimuli = init_stimuli_struct(); stimulate(network, num_neuron, num_compartment, start, end, direct, current); fgets(line, MAX_LINE_LEN, fp); remove_newline(line); } fclose(fp); }