Skip to content

Commit

Permalink
Add emodel_00
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaFicarelli committed Feb 15, 2024
1 parent 68b9e6a commit 765f5ff
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 0 deletions.
Empty file.
3 changes: 3 additions & 0 deletions custom_analyses/src/emodel_00/requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bluepyemodel
bluepyemodelnexus
neuron
116 changes: 116 additions & 0 deletions custom_analyses/src/emodel_00/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
aiohttp==3.9.3
aiosignal==1.3.1
appnope==0.1.4
asttokens==2.4.1
async-timeout==4.0.3
attrs==23.2.0
bluepyefe==2.3.14
bluepyemodel==0.0.83
bluepyemodelnexus==0.0.7
bluepyopt==1.14.10
cachetools==5.3.2
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
comm==0.2.1
configparser==6.0.0
contourpy==1.2.0
currentscape==0.1.0
cycler==0.12.1
deap==1.4.1
debugpy==1.8.1
decorator==5.1.1
deprecation==2.1.0
devtools==0.12.2
ecdsa==0.18.0
efel==5.5.7
elasticsearch==7.17.9
elasticsearch-dsl==7.4.0
entity-management==1.2.41
entrypoints==0.4
exceptiongroup==1.2.0
executing==2.0.1
fasteners==0.19
find-libpython==0.3.1
fonttools==4.48.1
frozendict==2.4.0
frozenlist==1.4.1
gitdb==4.0.11
GitPython==3.1.41
h5py==3.10.0
hjson==3.1.0
ICSelector==0.0.3
idna==3.6
igor2==0.5.3
ipykernel==6.29.2
ipyparallel==8.6.1
ipython==8.21.0
isodate==0.6.1
jedi==0.19.1
Jinja2==3.1.3
jupyter_client==8.6.0
jupyter_core==5.7.1
kiwisolver==1.4.5
lxml==5.1.0
MarkupSafe==2.1.5
matplotlib==3.8.3
matplotlib-inline==0.1.6
more-itertools==10.2.0
morph-tool==2.10.2
MorphIO==3.3.7
multidict==6.0.5
neo==0.13.0
nest-asyncio==1.6.0
neurom==3.2.8
NEURON==8.2.4
nexus-sdk==0.3.2
nexusforge==0.8.1
numpy==1.26.4
owlrl==5.2.3
packaging==23.2
palettable==3.3.3
pandas==2.2.0
parso==0.8.3
Pebble==5.0.6
pexpect==4.9.0
pickleshare==0.7.5
pillow==10.2.0
platformdirs==4.2.0
prettytable==2.5.0
prompt-toolkit==3.0.43
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
puremagic==1.20
pyasn1==0.5.1
Pygments==2.17.2
PyJWT==2.8.0
PyLD==2.0.3
pyparsing==3.1.1
pyshacl==0.17.2
python-dateutil==2.8.2
python-jose==3.3.0
python-keycloak==3.8.4
pytz==2024.1
PyYAML==6.0.1
pyzmq==25.1.2
quantities==0.15.0
rdflib==6.2.0
requests==2.31.0
requests-toolbelt==1.0.0
rsa==4.9
scipy==1.12.0
six==1.16.0
smmap==5.0.1
SPARQLWrapper==2.0.0
sseclient==0.0.27
stack-data==0.6.3
tornado==6.4
tqdm==4.66.2
traitlets==5.14.1
typing_extensions==4.9.0
tzdata==2024.1
urllib3==1.26.18
wcwidth==0.2.13
xmltodict==0.13.0
yarl==1.9.4
86 changes: 86 additions & 0 deletions custom_analyses/src/emodel_00/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import os
from pathlib import Path

from bluepyemodel.emodel_pipeline import plotting
from bluepyemodel.evaluation import evaluation
from bluepyemodelnexus.forge_access_point import NexusForgeAccessPoint
from bluepyemodelnexus.nexus import NexusAccessPoint
from common.utils import L, run_analysis


def _debug_nexus_env():
keys = ["NEXUS_PROJ", "NEXUS_ORG", "NEXUS_BASE", "NEXUS_FORGE_PATH"]
L.info("Nexus env:\n%s", "\n".join(f"{k}={os.getenv(k, '')}" for k in keys))


def _get_nexus_forge_access_point():
return NexusForgeAccessPoint(
project=os.getenv("NEXUS_PROJ"),
organisation=os.getenv("NEXUS_ORG"),
endpoint=os.getenv("NEXUS_BASE"),
access_token=os.getenv("NEXUS_TOKEN"),
forge_path=os.getenv("NEXUS_FORGE_PATH"),
cross_bucket=True,
)


def _get_nexus_access_point(emodel, etype, iteration_tag):
return NexusAccessPoint(
emodel=emodel,
etype=etype,
iteration_tag=iteration_tag,
project=os.getenv("NEXUS_PROJ"),
organisation=os.getenv("NEXUS_ORG"),
endpoint=os.getenv("NEXUS_BASE"),
access_token=os.getenv("NEXUS_TOKEN"),
forge_path=os.getenv("NEXUS_FORGE_PATH"),
)


def _get_metadata_from_id(emodel_id):
access_point = _get_nexus_forge_access_point()
resource = access_point.retrieve(emodel_id)
return {
"emodel": resource.emodel,
"etype": resource.etype,
"iteration": resource.iteration,
}


def _get_recording_names(access_point, cell_evaluator):
return plotting.get_recording_names(
protocol_config=access_point.get_fitness_calculator_configuration().protocols,
stimuli=cell_evaluator.fitness_protocols["main_protocol"].protocols,
)


@run_analysis
def main(analysis_config: dict) -> dict:
_debug_nexus_env()
L.info("analysis_config:\n%s", analysis_config)
metadata = _get_metadata_from_id(analysis_config["emodel_id"])
access_point = _get_nexus_access_point(
emodel=metadata["emodel"],
etype=metadata["etype"],
iteration_tag=metadata["iteration"],
)
emodel = access_point.get_emodel()
cell_evaluator = evaluation.get_evaluator_from_access_point(
access_point,
stochasticity=False,
include_validation_protocols=False,
)
L.info("cell_evaluator:\n%s", cell_evaluator)
recording_names = _get_recording_names(access_point, cell_evaluator)
responses = cell_evaluator.run_protocols(
protocols=cell_evaluator.fitness_protocols.values(),
param_values=emodel.parameters,
)
figures_dir = Path(analysis_config["output"]) / "figures"
plotting.traces(
model=emodel,
responses=responses,
recording_names=recording_names,
figures_dir=figures_dir,
)
return {"outputs": [{"path": str(f)} for f in figures_dir.iterdir() if f.is_file()]}

0 comments on commit 765f5ff

Please sign in to comment.