input synaptic weights from MATLAB to NEURON session

Moderator: wwlytton

Post Reply
KG_UIUC
Posts: 6
Joined: Thu Nov 08, 2012 12:45 pm

input synaptic weights from MATLAB to NEURON session

Post by KG_UIUC »

I have a session file containing 10 cells which creates spike plot and I save the output as. dat file

I want to use these .dat files to do MATLAB analysis and if it doesn't meet the required conditions I would send new synaptic weights and delay time to create new spike plot and create .dat file and use it in MATLAB again.

what I have until now

1. .ses file that can create spike plot (thanks to network tutorials).

2. .hoc file which has a procedure to save spike data as a vector in .dat file

what I want to do

1. I want to input synaptic weights and delay time in a matrix and send it to cells e.g here in an excerpt from my .ses file. I want to change the 4 & 5 arguments in nc_append.

I tried to do this load_file("synaptic weights.txt")% which contains the synaptic weights and delay time in a matrix but dont know what to do next?

/Network instantiation


/* R13 -> L11.g0 */ nc_append(3, 1, 0, 0.01,1)
/* S0 -> L11.a1 */ nc_append(0, 1, 1, 0.01,1)
/* L11 -> L11.a1 */ nc_append(1, 1, 1, 0.0001,1)
/* L11 -> L11.n2 */ nc_append(1, 1, 2, 0.0006,1)
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: input synaptic weights from MATLAB to NEURON session

Post by ted »

KG_UIUC wrote:I want to input synaptic weights and delay time in a matrix and send it to cells e.g here in an excerpt from my .ses file. I want to change the 4 & 5 arguments in nc_append.
Attempts to load_file("synaptic weights.txt") will fail unless "synaptic weights.txt" consists entirely of valid hoc statements. I don't know what your "synaptic weights.txt" file looks like, but it isn't going to be a simple table ("matrix") of numbers that specify weights and delays.

Maybe you meant to say that your "synaptic weights.txt" file actually contained the following statements?

Code: Select all

//Network instantiation
  /* R13 -> L11.g0 */  nc_append(3,   1, 0,  0.01,1)
  /* S0 -> L11.a1 */  nc_append(0,   1, 1,  0.01,1)
  /* L11 -> L11.a1 */  nc_append(1,   1, 1,  0.0001,1)
  /* L11 -> L11.n2 */  nc_append(1,   1, 2,  0.0006,1)
If the answer is yes, and if you also tell me that your network was already set up before you executed load_file("synaptic weights.txt"), then I must point out that nc_append() does not affect the parameters of any existing NetCon. Instead, it adds a new NetCon to the model. This means your network would have twice as many synaptic connections as it did previously.

To provide further advice, I'll have to know exactly what the contents of your "synaptic weights.txt" file look like. A convenient file format would be a series of lines with 3 numbers on each line, where the first number specifies which NetCon is to be changed, the second number specifies the weight, and the third number specifies the delay in milliseconds. This would allow taking advantage of the nclist object that the Network Builder sets up. Each NetCon that is created by calling nc_append() is automatically appended to nclist; the total number of NetCons in nclist is nclist.count, and they are accessible to hoc by using the List class's .o method--that is, the ith NetCon is nclist.o(i-1). The elements in a List are numbered from 0 to nclist.count()-1.
KG_UIUC
Posts: 6
Joined: Thu Nov 08, 2012 12:45 pm

Re: input synaptic weights from MATLAB to NEURON session

Post by KG_UIUC »

Thanks Ted
So I did use nclst.o to change the synaptic weights and it WORKED :)

now my problem is when I load_file("wt.txt") which is synaptic weights from MATLAB
>> save test.dat synwt -ascii %%% matlab command

I dont know how out read these file contents. I want to input these in a matrix and then use them to change them synaptic weight

%%% load file
save it in matrix where first column has new synaptic weights form matlab and second column has delays for all netcons
and then call them

for i=0, nclist.count-1 {

nclist.o(i).weight = m.x[0]
nclist.o(i).delay = m.x[1]
}
KG_UIUC
Posts: 6
Joined: Thu Nov 08, 2012 12:45 pm

Re: input synaptic weights from MATLAB to NEURON session

Post by KG_UIUC »

Ted

I did try lots of things

I created a file "wt.txt" where I entered
0.1
0.001
0.3
and save it as ANSI .txt file

now when I write
objref f1
f1 = new file()
f1.wopen("wt.txt")
0 // is what I get on command window
stdref tstr
f1.getname(tstr)

wt.txt //is what get

xopen(tstr)
can't open wt.txt// is what i get

I want to read the file contents and save it in a matrix
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: input synaptic weights from MATLAB to NEURON session

Post by ted »

Suggest you read the Programmer's Reference documentation of the File class.
Post Reply