Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to use HippoUnit with hocobjects? #62

Open
git-abra opened this issue Jun 21, 2021 · 3 comments
Open

Is there a way to use HippoUnit with hocobjects? #62

git-abra opened this issue Jun 21, 2021 · 3 comments

Comments

@git-abra
Copy link

Hello all,

as my title states, I would like to know if there is a way or pragmatic workaround to use HippoUnit with HocObjects.

To clarify what I mean:

In HippoUnit the cells get instantiated in the scope with the hocinterpreter like

h("objref cell")
h("cell = new templatename()")

I would like to instantiate my cells for hippounit from a python hocobject cell, i.e. use a hocobject as hippounit input.
My python cell, which is a hocobject, looks like this:

cell = h.templatename()

In my case, I update this hocobject cell with new parameter values (like ion channel conductances) and as an instantiated hocobject it doesn't change/overwrite the hoc file with which the cell got created.

I would like to use this then updated hocobject cell as input for HippoUnit, so I could run the tests over the updated cell with updated parameter values and an unchanged hoc file.

I see a relatively rough workaround for it atm:
If I would create a new hoc file each time for it, I could just let HippoUnit run each time for a new hoc file. This works to some extend but as the number of cells increases it becomes worse and I don't see a way to automate this process of creating new hoc files.

Any ideas?

Thanks in advance

@sasaray
Copy link
Contributor

sasaray commented Jun 23, 2021

Hi,

As the easiest solution, I would suggest to let HippoUnit instantiate your hoc template and modify your parameters within the initialise function of the ModelLoader class of HippoUnit.
In the attached utils.py file you can find an example class (ModelLoader_multi_run_ca1_pc_nsg_EA) which we use for modifying our model's parameters without changing the hoc file. This class inherits from the ModelLoader class, implements a "set_parameters" function and reimplements the "initialise" function with the only difference from the original one, that here it calls the "set_parameters" function.
The parameter values are now can be set after instantiating this class (instead of the original ModelLoader):

model = ModelLoader_multi_run_ca1_pc_nsg_EA(mod_files_path = mod_files_path)
model.parameters = [1,2,3]

Please let me know whether you like this solution, or if you have any questions regarding it.

If you still think that the only solution for your project would be to use the hocobject as input to HippoUnit, I can try to find the way to modify HippoUnit accordingly. For this, can you please send me an example hoc template I can use for testing?

Best,

Sára

utils.py.zip

@git-abra
Copy link
Author

Hi,

I see your solution. Your kind of updating the parameters was like I did it on my project when I wrote it the first time. I forgot that totally to do it like that, because I changed to an automatic way of iterating and setting everything accordingly, which only works with having access to h.psection() dictionary for the hocobject.

Your solution is very helpful in this case, thanks. I just have to implement the HippoUnit runs now as a loop over the range of all parameter combinations, and I will hardcode the indices of the parameter combinations which match the ion channel and conductance names of the sections to update them by adapting your method.

The advantage of using the HocObject would be that I don't have to set the parameters anymore on it and can just use it straight out of my pipeline.
We can keep this issue open and I will respond again when it either can be closed because I just did it with the set_parameters() like stated above or when there are issues with doing it like that.

Thanks Thanks

@git-abra
Copy link
Author

git-abra commented Jun 27, 2021

Hi,

I implemented my parameters into your subclass and will attach how I did it. You will find there a way to dynamically set parameters instead of using 100 lines to manually set each of them.

To use it in Jupyter as an addition, you have to set

  1. The parameter vectors, which is e.g. a list of lists of different parameter combinations.:
    x = model.readJSON(parameter_path = "path_to_file")

  2. Choose which combination of all in the list or dict you read in from JSON (e.g. first listelement):
    model.parameters = x[0]

  3. Give sectionlist names of your model:
    model.sectionlist_list = ['sectionlist1', 'sectionlist2']

  4. You can set keywords, which channels you want to change
    model.parameterkeywords = ['bar', 'pas']

ModelLoader_parameters.py.zip

So it is working now as expected. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants