Neuron from Matlab dos command

Post Reply
JimH
Posts: 54
Joined: Tue Apr 10, 2007 3:36 pm
Location: Duke University

Neuron from Matlab dos command

Post by JimH »

I'm trying to call a hoc file from matlab in windows xp, although the code I have isn't working.

Code: Select all

dos('C:\nrn60\bin\nrniv.exe -nogui runstim2.hoc')
The code works fine (outputs show up in Matlab and files are created, a printf statement in the hoc code indicates running until the end of the code) but Matlab remains busy (it does not progress on to further code and says busy on the lower left). I've almost found a work around using "winopen" and file creation to tell when the code has finished, although I'd prefer to get the other method working and this causes new windows to open up. I've tried omitting -nogui although I think the problem is that Neuron is waiting for input and matlab is waiting a quit or done signal. Thoughts?

Along related lines, is it possible to autoclose the window that opens up when a hoc file runs instead of clicking on it and pressing ctrl + d? Thanks.
JimH
Posts: 54
Joined: Tue Apr 10, 2007 3:36 pm
Location: Duke University

Alternate Solution

Post by JimH »

I've found an alternate matlab approach that works although again it has it's own issues.

Code: Select all

!C:\nrn60\bin\nrniv.exe -nogui runstim2.hoc &
This code works and the & symbol stops matlab from being busy. The files that I save at the end of the simulation, and notably the first one that I save after the run() command contain ouput lines that would normally be seen on the command line like the 1s. Can I supress those? I can get around that on reading the file with some Matlab code, although I'm not sure why this happens.

That pertinent code is:

Code: Select all

run()
current_matrix = new Matrix() 
savcurrent1 = new File()
savcurrent1.wopen("Axon.csv")
savcurrent2 = new File()
savcurrent2.wopen("APAxon.csv")
savcurrent3 = new File()
savcurrent3.wopen("Xs.csv")
	
//SAVING THE AXON VOLTAGES
current_matrix.resize(rec.object(0).size(),segs)
for ii = 0, rec.count()-1 {
	current_matrix.setcol(ii,rec.object(ii)) 
} 
current_matrix.fprint(0,savcurrent1, " %g") 
savcurrent1.close() 
Axon.csv will contain outputs that would typically go to the command window. Running the hoc file normally doesn't produce the extra lines at the beginning of the file.
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

Many procs return "status codes" that are printed to stdout. To suppress the
appearance of these, wrap the offending statements { inside curly brackets }.
Post Reply