void StimulusGroup::evolve() { if ( !active ) return; // detect and push spikes boost::exponential_distribution<> dist(BASERATE); boost::variate_generator<boost::mt19937&, boost::exponential_distribution<> > die(poisson_gen, dist); for ( NeuronID i = 0 ; i < get_rank_size() ; ++i ) { if ( ttl[i] < sys->get_clock() && activity[i]>0.0 ) { push_spike ( i ); ttl[i] = sys->get_clock() + (AurynTime)((AurynFloat)die()/((activity[i]+base_rate)*dt)); } } // update stimulus properties if ( sys->get_clock() >= next_action_time ) { write_sequence_file(dt*(sys->get_clock())); if ( stimulus_active ) { if ( off_pattern >= 0 ) { set_active_pattern( off_pattern ); // turn on "off-stimulus" cur_stim_index = off_pattern; } else set_all( 0.0 ); // turn off currently active stimulus stimulus_active = false ; if ( randomintervals ) { boost::exponential_distribution<> dist(1./mean_off_period); boost::variate_generator<boost::mt19937&, boost::exponential_distribution<> > die(order_gen, dist); next_action_time = sys->get_clock() + (AurynTime)(max(0.0,die())/dt); } else { next_action_time = sys->get_clock() + (AurynTime)(mean_off_period/dt); } } else { if ( active ) { // choose stimulus switch ( stimulus_order ) { case MANUAL: break; case SEQUENTIAL: cur_stim_index = (cur_stim_index+1)%stimuli.size(); break; case SEQUENTIAL_REV: --cur_stim_index; if ( cur_stim_index <= 0 ) cur_stim_index = stimuli.size() - 1 ; break; case RANDOM: default: double draw = order_die(); double cummulative = 0; // TODO make this less greedy and do not compute this every draw cur_stim_index = 0; // cout.precision(5); // cout << " draw " << draw << endl; for ( unsigned int i = 0 ; i < probabilities.size() ; ++i ) { cummulative += probabilities[i]; // cout << cummulative << endl; if ( draw <= cummulative ) { cur_stim_index = i; break; } } break; } set_active_pattern( cur_stim_index ); stimulus_active = true; if ( randomintervals ) { boost::normal_distribution<> dist(mean_on_period,mean_on_period/3); boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > die(order_gen, dist); next_action_time = sys->get_clock() + (AurynTime)(max(0.0,die())/dt); } else { next_action_time = sys->get_clock() + (AurynTime)(mean_on_period/dt); } } } write_sequence_file(dt*(sys->get_clock()+1)); } }
main() { portstr = getenv("FASTPORT"); if(portstr!=NULL) { if(strlen(portstr)<3) { fprintf(stderr, "FASTPORT environment variable must be"); fprintf(stderr, " form: c;p. c and p are numerals for card"); fprintf(stderr, " and port respectively\n"); return -1; } else { card = portstr[0] - '0'; port = portstr[2] - '0'; } } if(card<0 || card>=NCARDS) { fprintf(stderr, "card number out of range\n"); return -1; } if(port<0 || port>2) { fprintf(stderr, "port number out of range\n"); return -1; } if(!Init(card, port)) { fprintf(stderr, "Unable to access device\n"); Finish(); exit(-1); } getflag = 0; oldxoffset = 0; oldyoffset = 0; strcpy(imagename,"image.cel"); xmax = 40; ymax = 25; while(1) { printmenu(); gets(tempstr); c = tempstr[0]; printf("\n"); if(c == 'i') { system("down -S < /u1/gg/bin/face64.out"); newcel(); } if(c == 'd') { system("ls -C *.cel | more"); } if(c == '!') { printf("Unix command >"); fflush(stdin) ; gets(tempstr); printf("\n"); system(tempstr); printf("\nhit return to continue"); fflush(stdin); gets(tempstr); } if(c == 'h') { if(fopen("/u1/gg/bin/face.doc","r") == NULL) { printf("\nHelp file not in /u1/gg/bin\n"); } else { system("more /u1/gg/bin/face.doc"); } } if(c == 'l') { getimagename(); loadcel(); } if(c == 's') { getimagename(); savecel(); } if(c == 'n') { newcel(); } if(c == 'r') { getsequencename(); read_sequence_file(); getflag = 0; } if(c == 'w') { getsequencename(); write_sequence_file(); getflag = 0; } if(c == 'g') { get_a_sequence(); getflag = 1; } if(c == 'p') { put_a_sequence(); } if(c == 'P') { buf[0] = 1; down(buf,(word)1,(word)0x15); Cont(); system("sleep 1"); ffile = fopen(".ptemp","w"); putc(40,ffile); putc(14,ffile); putc(0,ffile); /* black edges */ putc(0,ffile); putc(0,ffile); putc(0,ffile); up(buf,(word)4480,(word)0xa000); /* get bitmap */ for(i=0;i<4480;i++) putc(buf[i],ffile); for(i=0;i<560;i++) putc(0xde,ffile); /* pink/blue */ for(i=0;i<560;i++) putc(0x01,ffile); /* gray bkgrnd */ fclose(ffile); system("pixit < .ptemp | lpr &"); buf[0] = 0; down(buf,(word)1,(word)0x15); Cont(); } if(c == 'q') { if (getflag) { printf("sequences not written. Quit? (y/n)"); gets(tempstr); c = tempstr[0]; printf("\n"); if (c == 'y') { exit(0); } } else { exit(0); } } } }