Changes for page Code description
Last modified by galluzziandrea on 2022/06/20 12:33
From version 22.1
edited by galluzziandrea
on 2022/01/27 17:20
on 2022/01/27 17:20
Change comment:
There is no comment for this version
To version 6.1
edited by galluzziandrea
on 2021/12/09 14:47
on 2021/12/09 14:47
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Attachments (0 modified, 0 added, 7 removed)
Details
- Page properties
-
- Content
-
... ... @@ -36,7 +36,8 @@ 36 36 37 37 === Define necessary classes to import the Initialization Files: === 38 38 39 -{{code language="python" title=" "}} 39 +{{code language="python" width="90%" title=" 40 +120%"}} 40 40 class ImportIniLIFCA(): 41 41 #initialize the information to look for in perseo.ini 42 42 inf=["NeuronType", #still fixed value ... ... @@ -235,296 +235,9 @@ 235 235 # [.....],[],...] 236 236 {{/code}} 237 237 238 -=== Defining general and nest.kernel parameters === 239 239 240 -{{code language="python"}} 241 -#############################------------------------------------------------------------------------ 242 -#Clean the Network 243 -#############################------------------------------------------------------------------------ 244 -nest.ResetKernel() 245 245 246 -#############################------------------------------------------------------------------------ 247 -#insert the introductory parameters of the simulation 248 -#############################------------------------------------------------------------------------ 249 249 242 +=== Results === 250 250 251 -dt = 0.1 # the resolution in ms 252 -StartMisure=0. # start time of measurements 253 -simtime = int(float(InfoPerseo[3])) # Simulation time in ms (200 s) 254 -if simtime<=StartMisure: # If the simulation time is less than StartMisure, it is increased by StartMisure 255 - simtime=simtime+StartMisure 256 -start=0.0 # start time of poissonian processes 257 -origin=0.0 # temporal origin 258 - 259 -#############################------------------------------------------------------------------------ 260 -# Kernel parameters 261 -#############################------------------------------------------------------------------------ 262 -LNT=multiprocessing.cpu_count(); 263 -nest.SetKernelStatus({"local_num_threads": LNT}) 264 -nest.SetKernelStatus({"resolution": dt, "print_time": True, 265 - "overwrite_files": True}) 266 - 267 -#############################------------------------------------------------------------------------ 268 -#"randomize" the seeds of the random generators 269 -#############################------------------------------------------------------------------------ 270 - 271 -#msd = int(math.fabs(time.process_time()*1000)) 272 -#N_vp = nest.GetKernelStatus(['total_num_virtual_procs'])[0] 273 -#pyrngs = [numpy.random.RandomState(s) for s in range(msd, msd+N_vp)] 274 -#nest.SetKernelStatus({"grng_seed" : msd+N_vp}) 275 -#nest.SetKernelStatus({"rng_seeds" : list(range(msd+N_vp+1, msd+2*N_vp+1))}) 276 -{{/code}} 277 - 278 -=== Building the network: neuronal populations , Poisson processes and spike detectors === 279 - 280 -{{code language="python"}} 281 -#############################------------------------------------------------------------------------ 282 -print("Building network") 283 -#############################------------------------------------------------------------------------ 284 - 285 -startbuild = time.time() #initialize the calculation of the time used to simulate 286 - 287 -NeuronPop=[] 288 -NoisePop=[] 289 -DetectorPop=[] 290 - 291 -#define and initialize the populations of neurons with the parameters extracted from the.ini files 292 -for i in range(1,int(InfoBuild[0])+1): 293 - if int(InfoBuild[i][7])==0: 294 - app=float(InfoBuild[i][5]) 295 - else: 296 - app=0. 297 - app2= nest.Create("aeif_psc_exp", int(InfoBuild[i][0]),params={"C_m": 1.0, 298 - "g_L": 1.0/float(InfoBuild[i][3]), 299 - "t_ref": float(InfoBuild[i][6]), 300 - "E_L": 0.0, 301 - "V_reset": float(InfoBuild[i][5]), 302 - "V_m": app, 303 - "V_th": float(InfoBuild[i][4]), 304 - "Delta_T": 0., 305 - "tau_syn_ex": 1.0, 306 - "tau_syn_in": 1.0, 307 - "a": 0.0, 308 - "b": float(InfoBuild[i][10]), 309 - "tau_w": float(InfoBuild[i][9]), 310 - "V_peak":float(InfoBuild[i][4])+10.0}) 311 - NeuronPop.append(app2) 312 - 313 -#define and initialize the poisson generators and the spike detectors with the parameters extracted from the.ini files 314 - 315 -for i in range(1,int(InfoBuild[0])+1): 316 - app3= nest.Create("poisson_generator",params={"rate": float(InfoBuild[i][1]*InfoBuild[i][2]), 317 - 'origin':0., 318 - 'start':start}) 319 - NoisePop.append(app3) 320 - app4 = nest.Create("spike_recorder",params={ "start":StartMisure}) 321 - DetectorPop.append(app4) 322 - 323 -endbuild = time.time() 324 -{{/code}} 325 - 326 -=== [[image:image-20220127165908-2.png||height="659" width="1149"]] === 327 - 328 -=== Connecting the network nodes: neuronal populations, Poisson processes and spike detectors === 329 - 330 -{{code language="python"}} 331 -#############################------------------------------------------------------------------------ 332 -print("Connecting ") 333 -#############################------------------------------------------------------------------------ 334 - 335 -startconnect = time.time() 336 -Connessioni=[] 337 -Medie=[] 338 - 339 -#create and define the connections between the populations of neurons and the poisson generators 340 -#and between the populations of neurons and the spike detectors with the parameters extracted from the.ini files 341 - 342 -for i in range(0,int(InfoBuild[0])): 343 - nest.Connect(NoisePop[i], NeuronPop[i], syn_spec={'synapse_model': 'static_synapse_hpc', 344 - 'delay': dt, 345 - 'weight': nest.math.redraw(nest.random.normal(mean=float(InfoConnectNoise[i+1][0]), 346 - std=(float(InfoConnectNoise[i+1][1])*float(InfoConnectNoise[i+1][0]))), 347 - min=0., max=float('Inf')) 348 - }) 349 - nest.Connect(NeuronPop[i][:int(InfoBuild[i+1][0])], DetectorPop[i], syn_spec={"weight": 1.0, "delay": dt}) 350 - 351 -#create and define the connections between the populations of neurons with the parameters extracted from the.ini files 352 - 353 -for i in range(0,len(InfoConnectPop[1:])): 354 - 355 - conn=nest.Connect(NeuronPop[int(InfoConnectPop[i+1][1])], NeuronPop[int(InfoConnectPop[i+1][0])], 356 - {'rule': 'pairwise_bernoulli', 357 - 'p':float(InfoConnectPop[i+1][2]) }, 358 - syn_spec={'synapse_model': 'static_synapse_hpc', 359 - 'delay':nest.math.redraw(nest.random.exponential(beta=float(1./(2.99573227355/(float(InfoConnectPop[i+1][4])-float(InfoConnectPop[i+1][3]))))), 360 - min= numpy.max([dt,float(1./float(InfoConnectPop[i+1][4]))]), 361 - max= float(1./(float(InfoConnectPop[i+1][3])-dt/2))), 362 - 363 - 'weight':nest.random.normal(mean=float(InfoConnectPop[i+1][6]), 364 - std=math.fabs(float(InfoConnectPop[i+1][6])*float(InfoConnectPop[i+1][7])))}) 365 - 366 - 367 -endconnect = time.time() 368 -{{/code}} 369 - 370 -=== === 371 - 372 -=== === 373 - 374 -=== [[image:image-20220127170722-1.png]] === 375 - 376 -=== Simulating: neuronal time evolution. === 377 - 378 -=== === 379 - 380 -{{code language="python"}} 381 - #############################------------------------------------------------------------------------ 382 - print("Simulating") 383 - #############################------------------------------------------------------------------------ 384 - ################################################################################################################################################################### 385 - if Salva: 386 - print("I m going to save the data") 387 - #x=str(iterazioni) 388 - f = open(FileName,"w") 389 - if len(InfoProtocol): 390 - print("I m going to split the simulation") 391 - tempo=0 392 - for contatore in range(0,len(InfoProtocol)): 393 - appoggio1=int((tempo+InfoProtocol[contatore][0])/1000.) 394 - appoggio2=int(tempo/1000.) 395 - appoggio3=tempo+InfoProtocol[contatore][0] 396 - if (appoggio1-appoggio2)>=1: 397 - T1=(1+appoggio2)*1000-tempo 398 - nest.Simulate(T1) 399 - #Save the Data!!!! 400 - ########################################################### 401 - Equilibri=[] 402 - for i in range(0,int(InfoBuild[0])): 403 - Equilibri.append([]) 404 - a=nest.GetStatus(DetectorPop[i])[0]["events"]["times"] 405 - if len(a)>0: 406 - Trange=(1000*int(numpy.min(a)/1000.),1000*int(numpy.min(a)/1000.)+1000) 407 - hist,Tbin=numpy.histogram(a,200,(Trange[0],Trange[1])) 408 - Equilibri[i]=hist*1000./(5.*int(InfoBuild[i+1][0])) 409 - else: 410 - Trange=(1000*int(tempo/1000.),1000*int(tempo/1000.)+1000) 411 - hist=numpy.zeros(200) 412 - Tbin=numpy.linspace(Trange[0],Trange[1],num=201) 413 - Equilibri[i]=hist 414 - nest.SetStatus(DetectorPop[i],{'n_events':0}) 415 - for j in range(0,len(hist)): 416 - f.write(str(Tbin[j])+" ") 417 - for i in range(0,int(InfoBuild[0])): 418 - f.write(str(Equilibri[i][j])+" ") 419 - f.write("\n ") 420 - ########################################################### 421 - tempo=tempo+T1 422 - for contatore2 in range(1,(appoggio1-appoggio2)): 423 - nest.Simulate(1000.) 424 - #Save the Data!!!! 425 - ########################################################### 426 - Equilibri=[] 427 - for i in range(0,int(InfoBuild[0])): 428 - Equilibri.append([]) 429 - a=nest.GetStatus(DetectorPop[i])[0]["events"]["times"] 430 - if len(a)>0: 431 - Trange=(1000*int(numpy.min(a)/1000.),1000*int(numpy.min(a)/1000.)+1000) 432 - hist,Tbin=numpy.histogram(a,200,(Trange[0],Trange[1])) 433 - Equilibri[i]=hist*1000./(5.*int(InfoBuild[i+1][0])) 434 - else: 435 - Trange=(1000*int(tempo/1000.),1000*int(tempo/1000.)+1000) 436 - hist=numpy.zeros(200) 437 - Tbin=numpy.linspace(Trange[0],Trange[1],num=201) 438 - Equilibri[i]=hist 439 - nest.SetStatus(DetectorPop[i],{'n_events':0}) 440 - for j in range(0,len(hist)): 441 - f.write(str(Tbin[j])+" ") 442 - for i in range(0,int(InfoBuild[0])): 443 - f.write(str(Equilibri[i][j])+" ") 444 - f.write("\n ") 445 - tempo=tempo+1000. 446 - T2=appoggio3-tempo 447 - nest.Simulate(T2); 448 - tempo=tempo+T2; 449 - else: 450 - nest.Simulate(InfoProtocol[contatore][0]) 451 - temp=InfoProtocol[contatore][0] 452 - tempo=tempo+temp 453 - if InfoProtocol[contatore][2]==4: 454 - nest.SetStatus(NoisePop[InfoProtocol[contatore][1]],params={"rate": float(InfoBuild[1+InfoProtocol[contatore][1]][2]*InfoProtocol[contatore][3])}) 455 - if InfoProtocol[contatore][2]==12: 456 - nest.SetStatus(NeuronPop[InfoProtocol[contatore][1]], params={"b": float(InfoProtocol[contatore][3])}) 457 - else: 458 - nest.Simulate(simtime) 459 - tempo=simtime 460 - if (simtime-tempo)>0.: 461 - nest.Simulate(simtime-tempo) 462 - 463 - 464 - endsimulate = time.time() 465 - f.close() 466 - else: 467 - if len(InfoProtocol): 468 - tempo=0 469 - for contatore in range(0,len(InfoProtocol)): 470 - nest.Simulate(InfoProtocol[contatore][0]) 471 - temp=InfoProtocol[contatore][0] 472 - tempo=tempo+temp 473 - if InfoProtocol[contatore][2]==4: 474 - nest.SetStatus(NoisePop[InfoProtocol[contatore][1]],params={"rate": float(InfoBuild[1+InfoProtocol[contatore][1]][2]*InfoProtocol[contatore][3])}) 475 - #print "Population:", InfoProtocol[contatore][1] ,";Parameter:", InfoProtocol[contatore][2] ,"; Value: ",InfoProtocol[contatore][3] 476 - if InfoProtocol[contatore][2]==12: 477 - nest.SetStatus(NeuronPop[InfoProtocol[contatore][1]], params={"b": float(InfoProtocol[contatore][3])}) 478 - #print "Population:", InfoProtocol[contatore][1] ,";Parameter:", InfoProtocol[contatore][2] ,"; Value: ",InfoProtocol[contatore][3] 479 - 480 - else: 481 - nest.Simulate(simtime) 482 - tempo=simtime 483 - if (simtime-tempo)>0.: 484 - nest.Simulate(simtime-tempo) 485 - endsimulate = time.time() 486 - 487 - 488 - ################################################################################################################################################################### 489 - 490 - #############################------------------------------------------------------------------------ 491 - #print some information from the simulation 492 - #############################------------------------------------------------------------------------ 493 - 494 - num_synapses = nest.GetDefaults('static_synapse_hpc')["num_connections"] 495 - build_time = endbuild - startbuild 496 - connect_time = endconnect - startconnect 497 - sim_time = endsimulate - endconnect 498 - 499 - N_neurons=0 500 - for i in range(0,int(InfoBuild[0])): 501 - N_neurons=N_neurons+int(InfoBuild[i+1][0]) 502 - 503 - print(" Network simulation (Python) neuron type:",InfoPerseo[0]) 504 - print("Number of neurons : {0}".format(N_neurons)) 505 - print("Number of synapses: {0}".format(num_synapses)) 506 - print("Building time : %.2f s" % build_time) 507 - print("Connecting time : %.2f s" % connect_time) 508 - print("Simulation time : %.2f s" % sim_time) 509 - 510 -Fine=time.time() 511 -print ("Total Simulation time : %.2f s" % (Fine-Inizio)) 512 -{{/code}} 513 - 514 -=== === 515 - 516 -=== === 517 - 518 -=== [[image:image-20220127171242-1.png]] === 519 - 520 -=== Results: === 521 - 522 -the output of this simulationo is... 523 - 524 -[[attach:CorticalField_t=80_DeepSpontPlanar.mp4||target="_blank"]] 525 - 526 - 527 - 528 - 529 - 530 530 ==== ====
- CorticalField_t=80_DeepSpontPlanar.mp4
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.galluzziandrea - Size
-
... ... @@ -1,1 +1,0 @@ 1 -3.4 MB - Content
- 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
- image-20220127170155-2.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.galluzziandrea - Size
-
... ... @@ -1,1 +1,0 @@ 1 -280.0 KB - Content
- image-20220127170722-1.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.galluzziandrea - Size
-
... ... @@ -1,1 +1,0 @@ 1 -220.5 KB - Content
- image-20220127171242-1.png
-
- Author
-
... ... @@ -1,1 +1,0 @@ 1 -XWiki.galluzziandrea - Size
-
... ... @@ -1,1 +1,0 @@ 1 -301.3 KB - Content
- Introduction (path and modules):
- Check where I am and place myself in the right folder:
- Import the modules necessary for the simulation:
- Define necessary classes to import the Initialization Files:
- Import the initialization files:
- Defining general and nest.kernel parameters
- Building the network: neuronal populations , Poisson processes and spike detectors
- Connecting the network nodes: neuronal populations, Poisson processes and spike detectors
- Simulating: neuronal time evolution.
- Results: