Skip to content

Instantly share code, notes, and snippets.

@russelljjarvis
Last active November 29, 2016 02:06
Show Gist options
  • Save russelljjarvis/207f7b838858c741a625bf55f829d561 to your computer and use it in GitHub Desktop.
Save russelljjarvis/207f7b838858c741a625bf55f829d561 to your computer and use it in GitHub Desktop.
sciunit_GA_optimization dev

Hi Rick,

As discussed I am trying to integrate the GA development code I initially made here.

With sciunit judge, in order to use it to optomize the Allen Brian Institute example here.

Today I was occupied with fixing minor problems such as getting pyneuroml and allenbrainsdk into the dockerbuild I have made, that builds on scidash/neuronunit-scoop-deap. I am currently trying to replicate the AIBS.ipynb using the said docker image as substrate. Incidentally when I try to run the AIBS notebook it gets stuck on the line: NameError: name 'vm' is not defined. When reading over the code vm does not appear to be declared anywhere, I am not sure how it enters the name space in the notebook. Perhaps it comes from an imported module.

I did not get the sense that vm is used in a way that has consequences for the variables that I want to optomize so now I have commented out the cells:

#from neuronunit.capabilities import spike_functions
#waveforms = spike_functions.get_spike_waveforms(vm)
#np.max(waveforms.data,axis=1)


# In[23]:
#np.max(np.array(waveforms),axis=1)
# In[26]:
#np.max(waveforms,axis=1)

And I am trying to resolve the error:

Traceback (most recent call last):
  File "AIBS.py", line 60, in <module>
    observation = aibs.get_observation(dataset_id,'rheobase')
  File "/opt/conda/lib/python3.5/site-packages/neuronunit/aibs.py", line 20, in get_observation
    cmd = ct.get_cell(dataset_id) # Cell metadata
AttributeError: 'CellTypesApi' object has no attribute 'get_cell'

To this end I have edited this file: /opt/conda/lib/python3.5/site-packages/neuronunit/aibs.py

def get_observation(dataset_id,kind,cached=True):

    ct = CellTypesApi()

    cmd = ct.get_ephys_features(dataset_id) #cmd is a dictionary data type
    #obsolete syntax.
    #cmd = ct.get_cell(dataset_id) # Cell metadata

However the file causes more errors due to using an obsolete syntax for quering allensdk, so I am trying to translate the intended meaning to the future syntax.

I have update the methods that do the same job as cmd =ct.get_cell(dataset_id) However the keys returned are some how not sanitized properly. The methods are here:

https://github.com/russelljjarvis/sciunitopt/blob/master/AIBS.py#L72-L101

One of the dictionary keys returned by these methods is: dict_keys(['t', 'RS_pop[0]/v']) when only dict_keys(['t', 'v']) is expected.

My long term strategy is to expose the GA population with outputs that arise from the application of neuronunit.tests I plan to replace the nested iterators in the code below enclosed in the multiline string in the cell below with a call to my GA.

"""
for a in np.linspace(0.015,0.045,2):
    for b in np.linspace(-3.5,-0.5,2):
        for C in np.linspace(50,150,3):
            for k in np.linspace(0.4,1.0,3):
                model = ReducedModel(LEMS_MODEL_PATH, 
                             name='a=%.3fperms_b=%.1fnS_C=%dpF_k=%.2f' % (a,b,C,k), 
                             attrs={'//izhikevich2007Cell':
                                        {'b':'%.1f nS' % b,
                                         'a':'%.3f per_ms' % a,
                                         'C':'%d pF' % C,
                                         'k':'%.2f nS_per_mV' % k,
                                         'vr':'-68 mV',
                                         'vpeak':'45 mV'}
                                   })
                #model.skip_run = True
                models3.append(model)
score_matrix3 = suite.judge(models3, verbose=False)
score_matrix3.show_mean = True
score_matrix3.sortable = True
score_matrix3
""";

However at the moment I am working on replicating as much of AIS.ipynb on the appropriate dockerimage as much as possible.

I have noticed that the file aibs.py contains allensdk queries which are no longer syntactically compitible with allensdk, so I am working on resolving those.

@russelljjarvis
Copy link
Author

russelljjarvis commented Nov 29, 2016

In the AIBS.ipynb example I only succeeded in getting the Rheobase tests to work, however the Rheobase tests may be all that is required in order to do something meaningful with DEAP optomization. Lately I have been experimenting with calling the optimizer from sciunits Test class(), as in the example [here](https://github.com/russelljjarvis/sciunitopt/blob/dev/deap_config_simple_sum.py
#L130"Title"). I have also been using an approach where I try to add code to sciunits Test class directly as I think this is what you intend. https://github.com/russelljjarvis/sciunit/blob/master/sciunit/__init__.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment