Hoc Object not pickable

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Hoc Object not pickable

Post by mattions »

Hi Forum,

I would like to know if there is any plan (or if it is possible) to make the hoc Object pickable, using cPickle.
This would give the possibilities to save a very complex model (vectors, sections and so on) and to reuse the model to reinvestigate the results or even continue the simulation.

consider this code:

Code: Select all

import cPickle
from neuron import h
sec = h.Section()
FILE = open("test", 'w')
cPickle.dump(sec, FILE,1)
FILE.close()
If I try to execute this is the error that I get:

Code: Select all

/usr/lib/python2.6/copy_reg.pyc in _reduce_ex(self, proto)
     68     else:
     69         if base is self.__class__:
---> 70             raise TypeError, "can't pickle %s objects" % base.__name__
     71         state = base(self)
     72     args = (self.__class__, base, state)

TypeError: can't pickle Section objects
It's the same with the hoc object.

I'm using NEURON 7.0
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Hoc Object not pickable

Post by hines »

It should be doable. But to get all the details right would be a very tedious programming project
and would necessitate an understanding of the python pickle protocol. Due to SaveState, much
of the framework is possibly already in place. I don't have any present plans for implementing it.
Post Reply