Changes for page Code description
Last modified by galluzziandrea on 2022/06/20 12:33
From version 7.1
edited by galluzziandrea
on 2021/12/09 14:49
on 2021/12/09 14:49
Change comment:
There is no comment for this version
To version 2.1
edited by galluzziandrea
on 2021/12/09 12:34
on 2021/12/09 12:34
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,243 +1,30 @@ 1 -== Introduction(path and modules):==1 +== Code Description == 2 2 3 -First of all we check the path and import the necessary modules . 4 4 5 - ===CheckwhereIam andplace myselfinthe right folder:===4 +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 6 6 7 -{{code language="python"}} 8 -# Import the os module 9 -import os 6 +>This is a quote. You can add a quote by selecting some text and clicking the quote button in the editor. 10 10 11 -#Print the current working directory 12 -print("Current working directory: {0}".format(os.getcwd())) 8 +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 13 13 14 -# Change the current working directory 15 -os.chdir('/mnt/user/shared/Slow waves in fading anesthesia/Nest3Python3') 10 +=== Results === 16 16 17 -# Print the current working directory 18 -print("Current working directory: {0}".format(os.getcwd())) 19 -{{/code}} 12 +==== You can also add images ==== 20 20 21 - === Importhemodules necessary forthesimulation: ===14 +[[image:Collaboratory.Apps.Article.Code.ArticleSheet@placeholder.jpg]] 22 22 23 -{{code language="python"}} 24 -import nest 25 -import time 26 -from numpy import exp 27 -import numpy 28 -import math 29 -import random 30 -import multiprocessing 31 -Inizio=time.time() 32 -print('tempo di Inizio:',Inizio) 33 -{{/code}} 16 +Photo by David Clode 34 34 35 -=== === 18 +==== Or code ==== 36 36 37 - === DefinenecessaryclassestoimporttheInitialization Files:===20 +Code blocks can be added by using the code macro: 38 38 39 -{{code language="python" title=" "}} 40 -class ImportIniLIFCA(): 41 - #initialize the information to look for in perseo.ini 42 - inf=["NeuronType", #still fixed value 43 - "DelayDistribType", #still fixed value 44 - "SynapticExtractionType", #still fixed value 45 - "Life"] 46 - 47 - def __init__(self,files): 48 - self.files=files 49 - 50 - def FilesControllo(self): 51 - import sys 52 - for i in range(0,len(self.files)): 53 - if self.FileControllo(self.files[i]): 54 - sys.exit(0) 55 - 56 - def FileControllo(self,file1): 57 - try: 58 - f1=open(file1,"r") 59 - f1.close() 60 - return 0 61 - except ValueError: 62 - print("ValueError") 63 - return 1 64 - except IOError as err: 65 - print("OS error: {0}".format(err)) 66 - return 1 67 - except: 68 - print("Unexpected error:", sys.exc_info()[0]) 69 - return 1 70 - 71 - def Estrai_inf(self,stampa=0): 72 - 73 - InfoPerseo=self.EstraiInfoPerseo() #extract info from perseo.ini 74 - AppoggioTempM=self.EstraiInfoModuli() #extract info from modules.ini 75 - AppoggioTempC=self.EstraiInfoConnectivity() #extract info from connectivity.ini 76 - AppoggioTempP=self.EstraiProtocol() #extract info from protocol.ini 77 - 78 - def getKey(item): 79 - return item[0] 80 - InfoProtocol=AppoggioTempP 81 - # I convert the extracted information into a suitable format from tuple to list 82 - 83 - InfoBuildT=[AppoggioTempM[0]] 84 - for i in range(0,AppoggioTempM[0]): 85 - app1=[int(AppoggioTempM[2][i][0])] 86 - app=(app1+list(AppoggioTempM[2][i][3:9])+list(AppoggioTempM[2][i][12])+list(AppoggioTempM[2][i][9:12])) 87 - InfoBuildT.append(app) 88 - del app 89 - 90 - InfoBuild=[float(InfoBuildT[0])] 91 - for i in range(0,int(InfoBuildT[0])): 92 - app=[] 93 - for j in range(0,11): 94 - app.append(float(InfoBuildT[i+1][j])) 95 - InfoBuild=InfoBuild+[app] 96 - del app 97 - 98 - InfoConnectPop=[AppoggioTempM[0]] 99 - for i in range(0,len(AppoggioTempC[1][:])): 100 - app=list(AppoggioTempC[1][i]) 101 - InfoConnectPop.append(app) 102 - del app 103 - 104 - InfoConnectNoise=[AppoggioTempM[0]] 105 - for i in range(0,AppoggioTempM[0]): 106 - app=list(AppoggioTempM[2][i][1:3]) 107 - InfoConnectNoise.append(app) 108 - 109 - 110 - if stampa==1: #Print on screen of saved data 111 - for i,j in enumerate(InfoPerseo): 112 - print(self.inf[i],"=",j) 113 - print("\n") 114 - print("the network consists of ", AppoggioTempM[0], " neuronal population" ) 115 - print(AppoggioTempM[1]) 116 - for i in range(0,AppoggioTempM[0]): 117 - print(AppoggioTempM[2][i]) 118 - print("\n") 119 - print(AppoggioTempC[0]) 120 - for i in range(0,AppoggioTempM[0]**2): 121 - print(AppoggioTempC[1][i]) 122 - print("\n") 123 - for i in InfoProtocol: 124 - print("SET_PARAM"+str(i)) 125 - 126 - 127 - return InfoPerseo,InfoBuild,InfoConnectPop,InfoConnectNoise,InfoProtocol 128 - 129 - def EstraiProtocol(self): 130 - import string 131 - f1=open(self.files[3],"r") 132 - ProtocolList= [] 133 - for x in f1.readlines(): 134 - y=x.split() 135 - if len(y): 136 - if x[0]!="#" and y[0]=="SET_PARAM": 137 - try: 138 - ProtocolList.append([float(y[1]),int(y[2]),float(y[3]),float(y[4])]) 139 - except ValueError: 140 - pass 141 - f1.close() 142 - return ProtocolList 143 - 144 - def EstraiInfoPerseo(self): 145 - import string 146 - f1=open(self.files[0],"r") 147 - InfList= [] 148 - for x in f1.readlines(): 149 - y=x.split() 150 - if len(y): 151 - if x[0]!="#": 152 - for findinf in self.inf: 153 - try: 154 - temp=y.index(findinf) 155 - InfList.append(y[temp+2]) 156 - except ValueError: 157 - pass 158 - f1.close() 159 - return InfList 160 - 161 - def EstraiInfoModuli(self): 162 - import string 163 - f1=open(self.files[2],"r") 164 - NumPop=0 165 - for i,x in enumerate(f1.readlines()): 166 - y=x.split() 167 - if len(y): 168 - if x[0]!="#": 169 - NumPop=NumPop+1 170 - if i==2: 171 - ParamList=[] 172 - for j in range(1,14): 173 - ParamList.append(y[j]) 174 - f1.close() 175 - PopsParamList=[] 176 - f1=open(self.files[2],"r") 177 - x=f1.readlines() 178 - for j in range(0,NumPop): 179 - appo=x[4+j]; 180 - PopsParamList.append(appo.split()) 181 - f1.close() 182 - return NumPop,ParamList,PopsParamList 183 - 184 - def EstraiInfoConnectivity(self): 185 - import string 186 - f1=open(self.files[1],"r") 187 - PopConParamList=[] 188 - for i,x in enumerate(f1.readlines()): 189 - y=x.split() 190 - if len(y): 191 - if x[0]!="#": 192 - PopConParamList.append(y) 193 - if i==1: 194 - ParamList=[] 195 - for j in range(1,9): 196 - ParamList.append(y[j]) 197 - f1.close() 198 - return ParamList,PopConParamList 199 -{{/code}} 200 - 201 -=== Import the initialization files: === 202 - 203 -in this section we... 204 - 205 205 {{code language="python"}} 206 -Salva=1 207 -file1="perseo35.ini" 208 -file2="c_cortsurf_Pot1.43PotStr148v3.ini" 209 -file3="m_cortsurf_Pot1.43.ini" 210 -file4="ProtocolExploration36.ini" 211 -files=[file1,file2,file3,file4] 212 -#define the name of the Output file 213 -FileName="dati/Rates_Nest_Run_Milano_Test36_13x13_"+str(nest.Rank())+"_Pot1.43PotStr148v3Long3.dat" 214 -#check the existence of the files being read 215 -ImpFil=ImportIniLIFCA(files); 216 -ImpFil.FilesControllo() 217 - 218 -#extract the information of interest from the files.ini and transfer them to the files: 219 -#InfoPerseo,InfoBuild,InfoConnectPop,InfoConnectNoise 220 - 221 -stampa=0; #stampa=1 print output simulation data on screen stampa=0 dont 222 -InfoPerseo,InfoBuild,InfoConnectPop,InfoConnectNoise,InfoProtocol=ImpFil.Estrai_inf(stampa) 223 - 224 -# InfoPerseo=["NeuronType","DelayDistribType","SynapticExtractionType","Life" ] 225 -# InfoBuild=[numero di popolazioni, 226 -# [N,C_ext,\nu_ext,\tau,\tetha,H,\tau_arp,NeuronInitType,\alpha_c,\tau_c,g_c], 227 -# [.....],[],...] 228 -# InfoConnectPop=[numero di popolazioni, 229 -# [post,pre,c,Dmin,Dmax,syn typ,J,DJ], 230 -# [.....],[],...] 231 -# InfoConnectNoise=[numero di popolazioni, 232 -# [J_ext,DJ_ext], 233 -# [.....],[],...] 234 -# InfoProtocol=[[time,population,param_num,value], 235 -# [.....],[],...] 23 +x = 1 24 +if x == 1: 25 + # indented four spaces 26 + print("x is 1.") 236 236 {{/code}} 237 237 238 - 239 - 240 - 241 -=== Results === 242 - 243 -==== ==== 29 +(% class="wikigeneratedid" id="HH4Won27tAppearinToC" %) 30 +
- 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: