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

Solution to use NE python API for bimodality tests fails, due to NeuroElectro query syntax #206

Open
russelljjarvis opened this issue Apr 7, 2019 · 3 comments

Comments

@russelljjarvis
Copy link
Contributor

russelljjarvis commented Apr 7, 2019

import matplotlib
matplotlib.use('Agg')
import seaborn as sns
import urllib.request, json

import matplotlib.pyplot as plt

purkinje ={"id": 18, "name": "Cerebellum Purkinje cell", "neuron_db_id": 271, "nlex_id": "sao471801888"}
fi_basket = {"id": 65, "name": "Dentate gyrus basket cell", "neuron_db_id": None, "nlex_id": "nlx_cell_100201"}
pvis_cortex = {"id": 111, "name": "Neocortex pyramidal cell layer 5-6", "neuron_db_id": 265, "nlex_id": "nifext_50"}
#does not have rheobase
olf_mitral = {"id": 129, "name": "Olfactory bulb (main) mitral cell", "neuron_db_id": 267, "nlex_id": "nlx_anat_100201"}
ca1_pyr = {"id": 85, "name": "Hippocampus CA1 pyramidal cell", "neuron_db_id": 258, "nlex_id": "sao830368389"}
pipe = [ fi_basket, ca1_pyr, purkinje,  pvis_cortex,olf_mitral]

def properties(pipe):
    neuron_values = {}
    for val in range(1,10):
        for p in pipe:
            url_to_get = str('https://neuroelectro.org/api/1/nedm/?nlex=')+str(p["nlex_id"])+str('&e=')+str(val)+str('&limit=100')
            with urllib.request.urlopen(url_to_get) as url:
                data = json.loads(url.read().decode())
            for objects in data['objects']:
                last_label = objects['ecm']['ref_text']

            values = [ objects['val'] for objects in data['objects'] ]
            neuron_values[str(p["nlex_id"])] = {}
            neuron_values[str(p["nlex_id"])][val] = values
            if len(values):
                print(values)
                plt.clf()
                try:
                    sns.distplot(sorted(values), color="skyblue", label=str(last_label)+str(p["nlex_id"])+str(val))
                    plt.legend(loc="upper left")
                except:
                    plt.hist(sorted(values))      #use this to draw histogram of your data
                plt.savefig(str(last_label)+str(p["nlex_id"])+str(val)+str('.png'))
    return neuron_values
neuron_values = properties(pipe)
@rgerkin
Copy link
Contributor

rgerkin commented Apr 7, 2019

@russelljjarvis I don't know if __name filtering (or any filtering) was every implemented for nedm searches (i.e. for individual values taken from the literature. Also recall that if no results are found for one of the search restrictions, in some cases it just ignores that search restriction, which is obviously dumb but it hasn't risen to the top of anyone's list to fix it in NeuroElectro. Your safest bet is to do something like:

https://www.neuroelectro.org/api/1/nedm/?limit=999&n=18&e=2

Which should successfully return all 30 input resistance reports for Purkinje cells. You can check the output to make sure that the json for each entry in the returned list has ecm['e']['id']==2 and ncm['n']['id']==18 to make sure there are no bogus entries slipping in there due to API bugs.

@russelljjarvis
Copy link
Contributor Author

russelljjarvis commented Apr 8, 2019

#TODO:

Use 'R's diptest to test for bimodal. Update number of samples to reflect an entire number of experiments (possibly including multiple trials in the same organism).

Link to OSF:
https://osf.io/97xuj/

Sometimes unimodalism seems justified, other times not.

Here are some interesting distributions that might violate unimodalism, relevant to the optimization work being done. I will upload to the OSF, with metadata.

image
image
image
image
image
image
image
image
image
image
image
image
image

@russelljjarvis russelljjarvis changed the title Trying to use NE python API for bimodality tests fails, due to NeuroElectro query syntax Solution to use NE python API for bimodality tests fails, due to NeuroElectro query syntax Apr 8, 2019
@russelljjarvis
Copy link
Contributor Author

The dip-test is better supported in R. I am moving this code to the test directory, as I think stat-data-model tests, need to be included as tests if data driven optimization needs to be done. I also think that these distributions should be stored in a variable, that moves through the optimization pipeline, and gives context to solution quality.

@russelljjarvis russelljjarvis reopened this Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants