Saving Session records data in single precision

Anything that doesn't fit elsewhere.
Post Reply
aluchko

Saving Session records data in single precision

Post by aluchko » Thu Jul 29, 2010 10:28 pm

I've found an issue with the following steps

1. Create a new Multiple Run Fitter and from there add a New Function Fitness generator.

2. Go to Vector > "Retrieve from File" and load some double precision data. Than in the generator go to Regions > "Data from Clipboard" to load that data.

3. Print some of the ydat data in the generator and notice it's in double precision.

4. Save the session.

5. Exit neuron and reload the session. Notice the data is now in single precision.

Here's a couple files to make the reproduction easier, I added a procedure called query() to print the relevant data directly, just run check() and you'll see

Code: Select all

oc> check()
value is 2.34567890123457
But after saving and restarting

Code: Select all

oc> check()
value is 2.345680000000000
Here's the other files I used.

test.hoc

Code: Select all

load_file("nrngui.hoc")
xopen("test.ses")
proc check() {
        printf("value is %.15f\n",RegionFitness[1].ydat.x[2])
}
test.dat

Code: Select all

testData:
1 1.234567890123456789012345678
2 2.345678901234567890123456789
test.ses

Code: Select all

{load_file("nrngui.hoc")}
objectvar save_window_, rvp_
objectvar scene_vector_[3]
objectvar ocbox_, ocbox_list_, scene_, scene_list_
{ocbox_list_ = new List()  scene_list_ = new List()}
{pwman_place(0,0,0)}

//Begin MulRunFitter[0]
{
load_file("mulfit.hoc", "MulRunFitter")
}
{
ocbox_ = new MulRunFitter(1)
}
{object_push(ocbox_)}
{
version(5)
ranfac = 2
fspec = new File("test.ses.ft1")
fdat = new File("test.ses.fd1")
read_data()
build()
}
{p.gengui(0, 392, 73, 355.2, 312.96)}
{object_pop()}
{
ocbox_.map("MulRunFitter[0]", 603, 207, 324.48, 191.04)
}
objref ocbox_
//End MulRunFitter[0]

objectvar scene_vector_[1]
{doNotify()}
test.ses.ft1

Code: Select all

ParmFitness: Unnamed multiple run protocol
        FitnessFunction: Unnamed Function Fitness
                exp(-$1)
                RegionFitness:

        Parameters:
End ParmFitness
In test.ses.fd1 one can see the data is saved in single precision.

Code: Select all

RegionFitness xdat ydat boundary weight (lines=14) 1
||
3
0
1
2

0
1.23457
2.34568

2
0
2

0
1

0

ted
Site Admin
Posts: 5570
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Saving Session records data in single precision

Post by ted » Fri Jul 30, 2010 7:00 pm

If it is necessary to save parameter values to double precision, don't rely on ses files--use printf statements with appropriate formatting. But also ask: is this a serious issue when dealing with models of biological neurons and neural circuits? There are at least three reasons to answer "no."

1. There is no instance in which any parameter of any biological neural system has been determined with even single precision accuracy, let alone double precision.

2. In computational neuroscience, models are highly underconstrained, and several papers have reported that equally good fits can be obtained with parameters that lie on a manifold in parameter space.

3. From a strictly practical standpoint, it is unlikely that any important biological process requires high precision of any parameter, because small perturbations of such a parameter would have serious consequences for the organism. Biological systems display a robustness that argues strongly against high precision being critical for proper operation.* This may be in part due to the inherent robustness of certain kinds of nonlinear systems (in their book Theory of Oscillators, Andronov, Vitt, and Khaikin called such systems "coarse systems" meaning that they would operate even if constructed from "coarse" components, i.e. parts with large error tolerances).

*--Does this imply that, if there is some phenomenon that depends critically on a particular set of parameter values, that phenomenon cannot be relevant to the proper operation of a biological system?

aluchko

Re: Saving Session records data in single precision

Post by aluchko » Tue Aug 03, 2010 4:49 pm

Well in this case I'm debugging a reimplementation I made of another simulation that uses double precision, so I need the double precision to figure out where/why the implementations diverge (though there are a couple workarounds I should be able to use so it's not a big issue in this case).

But regardless of the utility of double precision I think the real issue is that saving the session causes the data in that session to change. When developing it's very useful to reproduce old results as a sanity check and this makes doing so more difficult.

hines
Site Admin
Posts: 1575
Joined: Wed May 18, 2005 3:32 pm

Re: Saving Session records data in single precision

Post by hines » Wed Aug 04, 2010 11:26 am

You can modify the precision of the double to string format conversion to save the full 17 decimal place precision.
If you are usin g RegionFitness, this would be in
...lib/hoc/mulfit/e_norm.hoc in
proc wfile at line 244. The lines that print the data to the file are:
xdat.printf($o1)
ydat.printf($o1)
and should be changed to, e.g
xdat.printf($o1, "%.20g\n")

aluchko

Re: Saving Session records data in single precision

Post by aluchko » Mon Sep 27, 2010 8:09 pm

Thanks, that fixed my problem. Is there a reason why xdat.printf($o1, "%.20g\n") isn't used in the distributed code?

ted
Site Admin
Posts: 5570
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Saving Session records data in single precision

Post by ted » Mon Sep 27, 2010 11:08 pm

I'd guess the answer is "lack of perceived need and absence of requests from users." Recall that many users are wet-lab experimentalists who have a healthy skepticism about the precision of experimentally-determined parameters.

Post Reply