I am writing a code to record one variable starting at tmin and stopping at tmax
the basic configuration is this piece of code
variables definition and creation
Code: Select all
objref word,word1,wrd2,cvd, fih0
strdef end,end1
fih0=new List()
word=new string("")
word1=new string("")
wrd2=new string("")
cvd=new CVode()
//Creation of file to save the vectors
//======================================
objref traces_file
traces_file = new File("./volt_time_ww_90msXXX.m")
//======================================
for(Cell_type=0;Cell_type<n_types;Cell_type+=1){
if(Cell_type==0){NL=n_layerP end="P" n_cells=n_P}else{if(Cell_type==1){NL=n_layerFS end="FS" n_cells=n_FS}}
for(c_idx=0;c_idx<NL;c_idx+=1){
sprint(word.str, "objref rec_list_t_%s%g,rec_list_v_%s%g,fihL%s%g",end,c_idx,end,c_idx,end,c_idx)
execute(word.str) //this for cycle creates the objets to be used
}
}
Mean Block
Code: Select all
load_file("./Spk_rec_post_trial1.hoc")
fih0.append(new FInitializeHandler(1,"Start_record()"))
//fih0.append(new FInitializeHandler(1,"cvd.event(tmin,\"Start_record()\")"))
Code: Select all
proc Start_record(){local n_lyr1, n_cels localobj wrd
print "time is ", t
wrd=word
for(Cell_type=0;Cell_type<n_types;Cell_type+=1){
if(Cell_type==0){NL=n_layerP end="P" n_cells=n_P}else{if(Cell_type==1){NL=n_layerFS end="FS" n_cells=n_FS}}
for(n_lyr1=0;n_lyr1<NL;n_lyr1+=1){
sprint(wrd.str,"rec_list_t_%s%g=new List() rec_list_v_%s%g=new List()",end,n_lyr1,end,n_lyr1)execute(wrd.str)
sprint(wrd.str,"n_cel=layer%s[%g].count()",end,n_lyr1)execute(wrd.str)
for n_cels=0,n_cel-1{
sprint(wrd.str,"rec_list_t_%s%g.append(new Vector()) ",end,n_lyr1)execute(wrd.str)
sprint(wrd.str,"rec_list_v_%s%g.append(new Vector())",end,n_lyr1)execute(wrd.str)
sprint(wrd.str,"layer%s[%g].o(%g).soma cvd.record(&v(0.5),rec_list_v_%s%g.o(%g),rec_list_t_%s%g(%g))",end,n_lyr1,n_cels,end,n_lyr1,n_cels,end,n_lyr1,n_cels)
print wrd.str
execute(wrd.str)
}
}
}
cvd.event(tmax,"prt2file(word,wrd2)")
}
The procedure Start_record defines the arrays and variables to record from, appends respective vectors to the already created lists and sets up the record procedure, i.e. something like this
layerP[0].o(0).soma cvd.record(&v(0.5),rec_list_v_P0.o(0),rec_list_t_P0.o(0))
if you look at what I called the mean block,The important think here is that at certain time point tmax one event should be delivered to print data to a file using
cvd.event(tmax,"prt2file(word,wrd2)")
fih0.append(new FInitializeHandler(1,"Start_record()"))
//fih0.append(new FInitializeHandler(1,"cvd.event(tmin,\"Start_record()\")"))
the result of running one or the other is quite different,the first works perfectly but the second seem to not initialize the procedure Start_record...
I will show here two short examples with only one object
FIRST CASE
fih0.append(new FInitializeHandler(1,"Start_record()"))
result: prints all my vectors from t=0 till t=tmax
time is 0 (t initial)
first instance of n_cel
layerP[0].o(0).soma cvd.record(&v(0.5),rec_list_v_P0.o(0),rec_list_t_P0.o(0))
first instance of size_v
first instance of t_v
0 -70
0.20309252 -69.93921
0.40618503 -69.87959
0.93772227 -69.728674
1.4692595 -69.58437
now I would want to start the recording of the data at tmin>0 so what I try t do is to usein this case I started recording data at t=0 and then one event is delivered saying that at tmax=150 data should be written to a file and it works fine !!!
fih0.append(new FInitializeHandler(1,"cvd.event(tmin,\"Start_record()\")"))
and the result is this
It doesn't print anything because the vectors are not initialized and when I look at the vector.size() it says -1oc>time is 82 (t initial)
first instance of n_cel
layerP[0].o(0).soma cvd.record(&v(0.5),rec_list_v_P0.o(0),rec_list_t_P0.o(0))
So, does somebody know what is wrong here??
what is the problem with the initialization?
Thanks a lot in advance for any feedback!!!
p.s. By the way, the function prt2file(word,wrd2) doesn't change from one situation to the other
OJAG