Xopen / load_file not working

The basics of how to develop, test, and use models.
Post Reply
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

Xopen / load_file not working

Post by Bill Connelly »

So I went to create a new model. I already had nrn7.1 but I thought I should install the new version. I did not delete the old one. Installation appeared to go fine.

On the desktop I made the folder I was going to work in "TC1" and within that folder I put a folder "cells" which was going to containing the geometry of the cells I was going to work on.

I created my .hoc file. (mosinit.hoc) in the folder "TC1". And in the folder "cells" I placed tc200.geo

mosinit.hoc contains two lines

Code: Select all

load_file("nrngui.hoc")
xopen("cells/tc200.geo")
I was sure this morning, this gave no errors.

I changed the way I was opening .hoc files, so that when I doubled clicked on them, they were opened in a code editor. Now I am dragging and dropping the .hoc file onto the nrngui shortcut to open them.

However, now I get the error. I have read that xopen and load_file both check "$HOC_LIBRARY_PATH" i.e. they start from the directory TC1. Is this not correct?

I am not 100% sure that changing how I open the files is the problem, but it seems to be the only thing it could be. I tried to fix this problem by reinstalling nrn7.2 however, it does reset the file handling.

Code: Select all

        1 
nrniv: Can't open  cells/tc200.geo
 in /cygdrive/C/Users/Bill/Desktop/TC1/mosinit.hoc near line 2
 xopen("cells/tc200.geo")
                         ^
xopen("cells/tc200.geo"        )
I'm pulling my hair our! How do I open the geometry file in a way such that I can create a portable directory?
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

Re: Xopen / load_file not working

Post by Bill Connelly »

I might also add that when I right click on the mosinit.hoc file, and tell it to run with neuron.exe if I perform getcwd() I get...

Code: Select all

oc>getcwd()
/cygdrive/c/Windows/system32/
On the other hand, if I drag and drop the mosinit.hoc onto the neurongui shortcut, I get

Code: Select all

oc>getcwd()
/cygdrive/c/
I assume this is where the issue is coming from. Any ideas on why the working directory isn't being set to where the mosinit file is?

I can get around the issue by using

Code: Select all

chdir("/cygdrive/C/Users/Bill/Desktop/TC1/")
However, this does not load any of the mechanisms...
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Xopen / load_file not working

Post by ted »

Bill Connelly wrote:I already had nrn7.1 but I thought I should install the new version. I did not delete the old one. Installation appeared to go fine.
Under MSWin it has always been advised to uninstall a previous version (via the NEURON program group's uninstaller) before installing a new version. I'd be concerned about MSWin's registry settings getting messed up. If you are able to launch and run the new version's neurondemo, maybe there isn't a problem with your new installation--but I'd bet dollars to donuts that the old one has a few punctures.
I changed the way I was opening .hoc files, so that when I doubled clicked on them, they were opened in a code editor.
Now I am dragging and dropping the .hoc file onto the nrngui shortcut to open them.

However, now I get the error.
. . .

Code: Select all

nrniv: Can't open  cells/tc200.geo
 in /cygdrive/C/Users/Bill/Desktop/TC1/mosinit.hoc near line 2
 xopen("cells/tc200.geo")
                         ^
xopen("cells/tc200.geo"        )
Sounds like dragging and dropping the mosinit.hoc file isn't setting the current working directory to /cygdrive/C/Users/Bill/Desktop/TC1
I have read that xopen and load_file both check "$HOC_LIBRARY_PATH" i.e. they start from the directory TC1.
No, $HOC_LIBRARY_PATH is an environment variable that won't even exist unless you tell MSWin that it should and what it should contain. And if you rely on $HOC_LIBRARY_PATH for this particular project, you'd have to change it in order for drag & drop to work for a different project whose files are in a different folder on your desktop or anywhere else.

Try adding a third line to your mosinit.hoc so it reads

Code: Select all

load_file("nrngui.hoc")
chdir("/cygdrive/C/Users/Bill/Desktop/TC1")
xopen("cells/tc200.geo")
and see if that helps.
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Xopen / load_file not working

Post by ted »

The more I think about it, the less I like the solution I proposed. The chief problem is that your code won't work if you move it to another directory or try it on a different machine. None of this happens if you configure Windows to launch NEURON when you double click on a hoc file, and use drag and drop to open your hoc files in a text editor; I put a shortcut to my favorite text editor right on the desktop for that very purpose.
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

Re: Xopen / load_file not working

Post by Bill Connelly »

Yes, you're absolutely right Ted. I've been moving the model around onto various different computers to try and improve speed and I'm dealing with just this issue. I can report that by re-associating the files with neuron.exe the problem goes away. Strange that drag and dropping doesn't do the same thing.

Also, just in case anyone is stuck in a situation the way I was, you also need to follow up with nrn_load_dll("nrnmech.dll") after you chdir("/cygdrive/C/Users/Bill/Desktop/TC2/")
Post Reply