Changes for page Code description

Last modified by galluzziandrea on 2022/06/20 12:33

From version 14.1
edited by galluzziandrea
on 2022/01/27 17:01
Change comment: Uploaded new attachment "image-20220127170104-1.png", version {1}
To version 8.1
edited by galluzziandrea
on 2021/12/09 14:58
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -323,202 +323,6 @@
323 323  endbuild = time.time()
324 324  {{/code}}
325 325  
326 -(% class="wikigeneratedid" %)
327 -=== [[image:image-20220127165908-2.png||height="659" width="1149"]] ===
326 +=== Results ===
328 328  
329 -=== Connecting the network nodes: neuronal populations, Poisson processes and spike detectors ===
330 -
331 -{{code language="python"}}
332 -#############################------------------------------------------------------------------------
333 -print("Connecting ")
334 -#############################------------------------------------------------------------------------
335 -
336 -startconnect = time.time()
337 -Connessioni=[]
338 -Medie=[]
339 -
340 -#create and define the connections between the populations of neurons and the poisson generators
341 -#and between the populations of neurons and the spike detectors with the parameters extracted from the.ini files
342 -
343 -for i in range(0,int(InfoBuild[0])):
344 - nest.Connect(NoisePop[i], NeuronPop[i], syn_spec={'synapse_model': 'static_synapse_hpc',
345 - 'delay': dt,
346 - 'weight': nest.math.redraw(nest.random.normal(mean=float(InfoConnectNoise[i+1][0]),
347 - std=(float(InfoConnectNoise[i+1][1])*float(InfoConnectNoise[i+1][0]))),
348 - min=0., max=float('Inf'))
349 - })
350 - nest.Connect(NeuronPop[i][:int(InfoBuild[i+1][0])], DetectorPop[i], syn_spec={"weight": 1.0, "delay": dt})
351 -
352 -#create and define the connections between the populations of neurons with the parameters extracted from the.ini files
353 -
354 -for i in range(0,len(InfoConnectPop[1:])):
355 -
356 - conn=nest.Connect(NeuronPop[int(InfoConnectPop[i+1][1])], NeuronPop[int(InfoConnectPop[i+1][0])],
357 - {'rule': 'pairwise_bernoulli',
358 - 'p':float(InfoConnectPop[i+1][2]) },
359 - syn_spec={'synapse_model': 'static_synapse_hpc',
360 - 'delay':nest.math.redraw(nest.random.exponential(beta=float(1./(2.99573227355/(float(InfoConnectPop[i+1][4])-float(InfoConnectPop[i+1][3]))))),
361 - min= numpy.max([dt,float(1./float(InfoConnectPop[i+1][4]))]),
362 - max= float(1./(float(InfoConnectPop[i+1][3])-dt/2))),
363 -
364 - 'weight':nest.random.normal(mean=float(InfoConnectPop[i+1][6]),
365 - std=math.fabs(float(InfoConnectPop[i+1][6])*float(InfoConnectPop[i+1][7])))})
366 -
367 -
368 -endconnect = time.time()
369 -{{/code}}
370 -
371 -=== ===
372 -
373 -=== ===
374 -
375 -=== Simulating: neuronal time evolution. ===
376 -
377 -=== ===
378 -
379 -{{code language="python"}}
380 - #############################------------------------------------------------------------------------
381 - print("Simulating")
382 - #############################------------------------------------------------------------------------
383 - ###################################################################################################################################################################
384 - if Salva:
385 - print("I m going to save the data")
386 - #x=str(iterazioni)
387 - f = open(FileName,"w")
388 - if len(InfoProtocol):
389 - print("I m going to split the simulation")
390 - tempo=0
391 - for contatore in range(0,len(InfoProtocol)):
392 - appoggio1=int((tempo+InfoProtocol[contatore][0])/1000.)
393 - appoggio2=int(tempo/1000.)
394 - appoggio3=tempo+InfoProtocol[contatore][0]
395 - if (appoggio1-appoggio2)>=1:
396 - T1=(1+appoggio2)*1000-tempo
397 - nest.Simulate(T1)
398 - #Save the Data!!!!
399 - ###########################################################
400 - Equilibri=[]
401 - for i in range(0,int(InfoBuild[0])):
402 - Equilibri.append([])
403 - a=nest.GetStatus(DetectorPop[i])[0]["events"]["times"]
404 - if len(a)>0:
405 - Trange=(1000*int(numpy.min(a)/1000.),1000*int(numpy.min(a)/1000.)+1000)
406 - hist,Tbin=numpy.histogram(a,200,(Trange[0],Trange[1]))
407 - Equilibri[i]=hist*1000./(5.*int(InfoBuild[i+1][0]))
408 - else:
409 - Trange=(1000*int(tempo/1000.),1000*int(tempo/1000.)+1000)
410 - hist=numpy.zeros(200)
411 - Tbin=numpy.linspace(Trange[0],Trange[1],num=201)
412 - Equilibri[i]=hist
413 - nest.SetStatus(DetectorPop[i],{'n_events':0})
414 - for j in range(0,len(hist)):
415 - f.write(str(Tbin[j])+" ")
416 - for i in range(0,int(InfoBuild[0])):
417 - f.write(str(Equilibri[i][j])+" ")
418 - f.write("\n ")
419 - ###########################################################
420 - tempo=tempo+T1
421 - for contatore2 in range(1,(appoggio1-appoggio2)):
422 - nest.Simulate(1000.)
423 - #Save the Data!!!!
424 - ###########################################################
425 - Equilibri=[]
426 - for i in range(0,int(InfoBuild[0])):
427 - Equilibri.append([])
428 - a=nest.GetStatus(DetectorPop[i])[0]["events"]["times"]
429 - if len(a)>0:
430 - Trange=(1000*int(numpy.min(a)/1000.),1000*int(numpy.min(a)/1000.)+1000)
431 - hist,Tbin=numpy.histogram(a,200,(Trange[0],Trange[1]))
432 - Equilibri[i]=hist*1000./(5.*int(InfoBuild[i+1][0]))
433 - else:
434 - Trange=(1000*int(tempo/1000.),1000*int(tempo/1000.)+1000)
435 - hist=numpy.zeros(200)
436 - Tbin=numpy.linspace(Trange[0],Trange[1],num=201)
437 - Equilibri[i]=hist
438 - nest.SetStatus(DetectorPop[i],{'n_events':0})
439 - for j in range(0,len(hist)):
440 - f.write(str(Tbin[j])+" ")
441 - for i in range(0,int(InfoBuild[0])):
442 - f.write(str(Equilibri[i][j])+" ")
443 - f.write("\n ")
444 - tempo=tempo+1000.
445 - T2=appoggio3-tempo
446 - nest.Simulate(T2);
447 - tempo=tempo+T2;
448 - else:
449 - nest.Simulate(InfoProtocol[contatore][0])
450 - temp=InfoProtocol[contatore][0]
451 - tempo=tempo+temp
452 - if InfoProtocol[contatore][2]==4:
453 - nest.SetStatus(NoisePop[InfoProtocol[contatore][1]],params={"rate": float(InfoBuild[1+InfoProtocol[contatore][1]][2]*InfoProtocol[contatore][3])})
454 - if InfoProtocol[contatore][2]==12:
455 - nest.SetStatus(NeuronPop[InfoProtocol[contatore][1]], params={"b": float(InfoProtocol[contatore][3])})
456 - else:
457 - nest.Simulate(simtime)
458 - tempo=simtime
459 - if (simtime-tempo)>0.:
460 - nest.Simulate(simtime-tempo)
461 -
462 -
463 - endsimulate = time.time()
464 - f.close()
465 - else:
466 - if len(InfoProtocol):
467 - tempo=0
468 - for contatore in range(0,len(InfoProtocol)):
469 - nest.Simulate(InfoProtocol[contatore][0])
470 - temp=InfoProtocol[contatore][0]
471 - tempo=tempo+temp
472 - if InfoProtocol[contatore][2]==4:
473 - nest.SetStatus(NoisePop[InfoProtocol[contatore][1]],params={"rate": float(InfoBuild[1+InfoProtocol[contatore][1]][2]*InfoProtocol[contatore][3])})
474 - #print "Population:", InfoProtocol[contatore][1] ,";Parameter:", InfoProtocol[contatore][2] ,"; Value: ",InfoProtocol[contatore][3]
475 - if InfoProtocol[contatore][2]==12:
476 - nest.SetStatus(NeuronPop[InfoProtocol[contatore][1]], params={"b": float(InfoProtocol[contatore][3])})
477 - #print "Population:", InfoProtocol[contatore][1] ,";Parameter:", InfoProtocol[contatore][2] ,"; Value: ",InfoProtocol[contatore][3]
478 -
479 - else:
480 - nest.Simulate(simtime)
481 - tempo=simtime
482 - if (simtime-tempo)>0.:
483 - nest.Simulate(simtime-tempo)
484 - endsimulate = time.time()
485 -
486 -
487 - ###################################################################################################################################################################
488 -
489 - #############################------------------------------------------------------------------------
490 - #print some information from the simulation
491 - #############################------------------------------------------------------------------------
492 -
493 - num_synapses = nest.GetDefaults('static_synapse_hpc')["num_connections"]
494 - build_time = endbuild - startbuild
495 - connect_time = endconnect - startconnect
496 - sim_time = endsimulate - endconnect
497 -
498 - N_neurons=0
499 - for i in range(0,int(InfoBuild[0])):
500 - N_neurons=N_neurons+int(InfoBuild[i+1][0])
501 -
502 - print(" Network simulation (Python) neuron type:",InfoPerseo[0])
503 - print("Number of neurons : {0}".format(N_neurons))
504 - print("Number of synapses: {0}".format(num_synapses))
505 - print("Building time : %.2f s" % build_time)
506 - print("Connecting time : %.2f s" % connect_time)
507 - print("Simulation time : %.2f s" % sim_time)
508 -
509 -Fine=time.time()
510 -print ("Total Simulation time : %.2f s" % (Fine-Inizio))
511 -{{/code}}
512 -
513 -=== ===
514 -
515 -=== Results: ===
516 -
517 -the output of this simulationo is...
518 -
519 -
520 -
521 -
522 -
523 -
524 524  ==== ====
image-20220127165822-1.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.galluzziandrea
Size
... ... @@ -1,1 +1,0 @@
1 -237.6 KB
Content
image-20220127165908-2.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.galluzziandrea
Size
... ... @@ -1,1 +1,0 @@
1 -106.6 KB
Content
image-20220127170104-1.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.galluzziandrea
Size
... ... @@ -1,1 +1,0 @@
1 -149.6 KB
Content