Hi..
I am new to python programming. I am trying to generate a raster plot here.
my code:
MY INPUT IS A FILE. FILE CONTENT
0001
2000
2004
3000
3004
0002
2001
2010
3010
3011
0003
2020
3020
3031
I am new to python programming. I am trying to generate a raster plot here.
my code:
from brian2 import * import matplotlib start_scope() cnt=1 ct=0 f= open("list.txt") dict={} i=[] t=[] lines = f.readlines() for l in lines : if l[0]==0 : ct=ct+1 b = ct elif (l[0]!= 0): ind =l if ind not in dict: dict[ind]=cnt t.append(b) i.append(dict[ind]) cnt=cnt+1 plot(t,i,'.k') xlabel('Time (ms)') ylabel('Neuron index')When I execute it i dont get any errors. But i dont get the desired output also. The IF statement inside the FOR loop was not executed. When i tried to debug the program using pdb, I get this.
(Pdb) from brian2 import * (Pdb) import matplotlib (Pdb) (Pdb) (Pdb) start_scope() (Pdb) cnt=1 (Pdb) ct=0 (Pdb) f= open("list.txt") (Pdb) dict={} (Pdb) i=[] (Pdb) t=[] (Pdb) lines = f.readlines() (Pdb) for l in lines : *** SyntaxError: unexpected EOF while parsing (Pdb) if l[0]==0 : *** SyntaxError: unexpected EOF while parsing (Pdb) ct=ct+1 (Pdb) b = ct *** The specified object '= ct' is not a function or was not found along sys.path. (Pdb) *** The specified object '= ct' is not a function or was not found along sys.path. (Pdb) elif (l[0]!= 0): *** SyntaxError: invalid syntax (Pdb) ind =l *** NameError: name 'l' is not defined (Pdb) *** NameError: name 'l' is not defined (Pdb) if ind not in dict: *** SyntaxError: unexpected EOF while parsing (Pdb) dict[ind]=cnt *** NameError: name 'ind' is not defined (Pdb) t.append(b) *** NameError: name 'b' is not defined (Pdb) i.append(dict[ind]) *** NameError: name 'ind' is not defined (Pdb) cnt=cnt+1 (Pdb) (Pdb) plot(t,i,'.k') [<matplotlib.lines.Line2D object at 0x7fd91dfab0b8>] (Pdb) xlabel('Time (ms)') Text(0.5,0,'Time (ms)') (Pdb) ylabel('Neuron index') Text(0,0.5,'Neuron index')PLEASE HELP TO DEBUG THIS
MY INPUT IS A FILE. FILE CONTENT
0001
2000
2004
3000
3004
0002
2001
2010
3010
3011
0003
2020
3020
3031