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

[BBPBGLIB-1059] Integrate Oren's gap junction compensation procedure into neurodamus #195

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

WeinaJi
Copy link
Collaborator

@WeinaJi WeinaJi commented Sep 4, 2024

Context

Integrate Oren's compensation script for gap junction synapses into the neurodamus main flow. Uses are expected to use predefined parameters in the SONATA simulation config files to configure the correction steps and values. In this PR, those parameters are stored in the experimental "beta_features" section of the SONATA config files. The corresponding formal SONATA parameters are to be determined in the SONATA specifications, the libsonata parser, and the future PR in neurodamus.

Scope

At the finalize step for GapJunctionManager, if users set the right gapjunction_target_population, the user corrections defined in the new file gj_user_functions.py will be triggered. This file is implemented based on Oren's script which was used for Elisabetta's publication (/gpfs/bbp.cscs.ch/project/proj55/software/gap_junctions/pylibs/manager_python.py). It provides these corrections to be enabled by users via the SONATA simulation config file:

  1. Set deterministic = 1 for StochKv mechanisms set in the simulation config file "determanisitc_stoch"
  2. Update the conductance value of gap synapses to the value set in the simulation config file "gjc"
  3. Remove cell channel mechanisms set by "remove_channels"
  4. Update segment g_pas to fit the gjc with values set by the calibration file given in the simulation config file "load_g_pas_file"
  5. Add current clamps to certain cells where the gids and the amplitudes are read from the file given in the simulation config "manual_MEComboInfo_file"
  6. Add SEClamps to the certain cells where the gids and the amplitudes are read from the file given in the simulation config "vc_amp" and meanwhile save the SEClamp Data

Those SONATA parameters are chosen based on the setting in Elisabetta's publication /gpfs/bbp.cscs.ch/project/proj55/iavarone/releases/simulations/spontaneous_evoked/CorrectCTFiberAll_Backgroundwith_afferents_MLNoise25_CTNoise4/MLStim4/MLNoise0/CTNoise0/settings.p for which corrections 1,2,4,5 were used.

Testing

New test test_v5_gap_junction_corrections in test/scientific/test_simulation.py

Review

  • PR description is complete
  • Coding style (imports, function length, New functions, classes or files) are good
  • Unit/Scientific test added
  • Updated Readme, in-code, developer documentation

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@bbpbuildbot

This comment has been minimized.

@WeinaJi WeinaJi changed the title Integrate gap junction compensation steps from Oren [BBPBGLIB-1059] Integrate Oren's gap junction compensation procedure into neurodamus Sep 6, 2024
@bbpbuildbot

This comment has been minimized.

@WeinaJi WeinaJi marked this pull request as ready for review September 9, 2024 08:14
@bbpbuildbot
Copy link

Comment on lines 142 to 144
"load_g_pas_file": "/gpfs/bbp.cscs.ch/project/proj55/amsalem/gap_junctions/circ19_11_2019_gjs_19_20_20/rm_correction/Circ_mc2_Rt_Remove_ch_all_Det_stoch_True_Dis_holding_False_Correc_type_impedance_tool_Cm0p01_Num_iter_10/num_0/g_pas_passive.hdf5", # noqa
"manual_MEComboInfo_file": "/gpfs/bbp.cscs.ch/project/proj55/amsalem/gap_junctions/circ19_11_2019_gjs_19_20_20_new_holding/find_holding_current/vc_ampFile/Circ_mc2_Rt_Remove_ch_none_Det_stoch_True_Dis_holding_False_gjc0p2_Change_mecomb_False_manual_MEComboInfoFile_False_Load_g_pas_True_Correc_iter_loadlast/num_0/holding_per_gid.hdf5" # noqa
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WeinaJi : Just a comment: at a minimum, we should move this to proj12?

In general, as we want to move the CI out of gitlab / BB5 very soon, it would be good to have tests that are not dependent on BB5/GitLab. Because very soon, we need to work on removing gitlab dependency.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was my comment also, would be nice to avoid depending on bb5 for the tests...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sure, for this test I will create small, local and dummy calibration files to read as I am not test the final results.

@jorblancoa
Copy link
Collaborator

General comment:
Do we want to merge those in beta_features? or shall we wait to define them in the sonata-extension and then implement the necessary changes in libsonata first?

@orena1
Copy link

orena1 commented Sep 10, 2024

Hi @WeinaJi I think it looks good, but is there a way to test it?

@orena1
Copy link

orena1 commented Sep 10, 2024

Very cool, a bit off-topic, but there is also the code that generates the GJs and use them. I'll try to get it on github and we can refer to it.

@WeinaJi
Copy link
Collaborator Author

WeinaJi commented Sep 10, 2024

General comment: Do we want to merge those in beta_features? or shall we wait to define them in the sonata-extension and then implement the necessary changes in libsonata first?

Thinking about the time left, I am inclined to merge them in beta_features so @PolinaL can use in her thalamus simulation asap. This way we don't need the approval for the SONATA specs and the libsonata API.
For the SONATA specs, we need to define proper naming for all required parameters, and possibly store them in a proper section. Maybe we could brainstorm with scientists if time permits, @jamesgking ?

@WeinaJi
Copy link
Collaborator Author

WeinaJi commented Sep 10, 2024

Hi @WeinaJi I think it looks good, but is there a way to test it?

Hello @orena1 , can you access our bb5 cluster? If yes, you can clone this branch into your directory, load the thalamus module, and overwrite the neurodamus component with your local copy. Something like:

git clone [email protected]:BlueBrain/neurodamus.git -b weji/oren
module load unstable neurodamus-thalamus
export PYTHONPATH=$(pwd)/neurodamus:$PYTHONPATH
srun dplace special -mpi -python $NEURODAMUS_PYTHON/init.py --configFile=simulation_config.json

The config file simulation_config.json should contain the beta_features section like

{
"beta_features" :{
        "gapjunction_target_population": "thalamus_neurons",
        "determanisitc_stoch": true,
        "procedure_type": "validation_sim",
        "gjc": 0.2,
        "load_g_pas_file": "/gpfs/bbp.cscs.ch/project/proj55/amsalem/gap_junctions/circ19_11_2019_gjs_19_20_20/rm_correction/Circ_mc2_Rt_Remove_ch_all_Det_stoch_True_Dis_holding_False_Correc_type_impedance_tool_Cm0p01_Num_iter_10/num_0/g_pas_passive.hdf5",
        "manual_MEComboInfo_file": "/gpfs/bbp.cscs.ch/project/proj55/amsalem/gap_junctions/circ19_11_2019_gjs_19_20_20_new_holding/find_holding_current/vc_ampFile/Circ_mc2_Rt_Remove_ch_none_Det_stoch_True_Dis_holding_False_gjc0p2_Change_mecomb_False_manual_MEComboInfoFile_False_Load_g_pas_True_Correc_iter_loadlast/num_0/holding_per_gid.hdf5"
    },
}

An example from my test config file /gpfs/bbp.cscs.ch/home/weji/JIRA/thalamus_elsabetta/0/simulation_config.json

Also cc @PolinaL

@WeinaJi
Copy link
Collaborator Author

WeinaJi commented Sep 10, 2024

Very cool, a bit off-topic, but there is also the code that generates the GJs and use them. I'll try to get it on github and we can refer to it.

That will be great. Please let me know if you would like to push something in this repo. I can give you the write permission.

In fact, I have another version of your script which includes these commented code:

# if load_g_pas_correction_file:
#     logging.info("Loading g_pas_correction_file")
#     exec(open('/gpfs/bbp.cscs.ch/home/amsalem/Dropbox/Blue_Brain/Experiments_Reproduction/Coupling_Coefficient/pylibs/gap_junction_conductance_search_damus.py').read())

Is it still needed? I can't find the script gap_junction_conductance_search_damus.py any more.

import logging
import numpy as np
import pickle
from neurodamus.core import MPI
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from neurodamus.core import MPI
from .core import MPI



def _update_gpas(node_manager, filename, gjc, correction_iteration_load):
import h5py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: maybe we would better import h5py at module level. It is not really optional, right?

def _update_gpas(node_manager, filename, gjc, correction_iteration_load):
import h5py
processed_cells = 0
g_pas_file = h5py.File(filename, 'r')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick:
maybe there should be some error handling here? (same below)

try:
    g_pas_file = h5py.File(filename, 'r')
except IOError as e:
    raise ConfigurationError(f"Error opening....: {e}")

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

Successfully merging this pull request may close these issues.

6 participants