BluePyOpt icon indicating copy to clipboard operation
BluePyOpt copied to clipboard

Implement LFPy backend

Open alejoe91 opened this issue 3 years ago • 19 comments
trafficstars

LFPy-related changes

  • Added LFPy as a backend for simulation
  • Added extracellular efeatures class extraFELFeature that supports computing features from extracellular "template" (avg action potential). Features include:
    • "peak_to_valley": duration between negative and positive peak
    • "halfwidth": full width alf maximum of negative peak
    • "peak_trough_ratio": ratio between peak and trough
    • "repolarization_slope": slope from the first peak to baseline
    • "recovery_slope": slop from second peak to baseline
    • "neg_peak_relative": relative amplitude of negative peaks with respect to max channel
    • "pos_peak_relative": relative amplitude of positive peaks with respect to max channel
    • "neg_peak_diff": relative timing of negative peaks with respect to max channel
    • "pos_peak_diff": relative timing of positive peaks with respect to max channel
    • "neg_image": normalized potential at time of negative peak
    • "pos_image": normalized potential at time of positive peak

Other changes

  • Add param_dependancies in parameters
  • Add **morhp_modifiers_kwargs to Morphology
  • Implement NrnSegmentSectionDistanceScaler (base class also for NrnSegmentSomaDistanceScaler)

alejoe91 avatar Mar 01 '22 14:03 alejoe91

The setup.py needs to be updated to include LFPy. Also we will need tests to maintain the test coverage above 90%.

It was not added on purpose to make the LFPy dependency weak. All LFPy imports are local so one can still run normal BPO without having LFPy installed

alejoe91 avatar Jul 14 '22 10:07 alejoe91

The setup.py needs to be updated to include LFPy. Also we will need tests to maintain the test coverage above 90%.

It was not added on purpose to make the LFPy dependency weak. All LFPy imports are local so one can still run normal BPO without having LFPy installed

LFP needs to be in an extra require then:

extras_require={
        "LFPy": ["LFPy"]
}

DrTaDa avatar Jul 14 '22 10:07 DrTaDa

yeah that could work!

alejoe91 avatar Jul 14 '22 10:07 alejoe91

So it seems LFPy requires mpi4py? Installation seems to fail during the tests. Can we disable mpi4py in LFPy, since I assume we don't need it?

wvangeit avatar Jul 25 '22 07:07 wvangeit

So it seems LFPy requires mpi4py? Installation seems to fail during the tests. Can we disable mpi4py in LFPy, since I assume we don't need it?

Unfortunately it's a requirement: https://github.com/LFPy/LFPy/blob/master/requirements.txt

alejoe91 avatar Jul 25 '22 08:07 alejoe91

Could we ask to get it removed from the hard requirements (or to make an extra that doesn't require it?). I'm a bit reluctant to make mpi4py a requirement for the bpopt tests if it is not required.

wvangeit avatar Jul 25 '22 08:07 wvangeit

Could we ask to get it removed from the hard requirements (or to make an extra that doesn't require it?). I'm a bit reluctant to make mpi4py a requirement for the bpopt tests if it is not required.

https://github.com/LFPy/LFPy/issues/429

alejoe91 avatar Jul 25 '22 10:07 alejoe91

@alejoe91 If you agree, I will rollback the changes to parameters,py and parameterscalers.py. We were using them for the Hallermann model but it is not use anymore. It will also require us to do some changes on the multimodal fitting repo such as removing https://github.com/alejoe91/multimodalfitting/blob/cb49b63d0e76433448b9e4ca6ca825cf74598ffa/multimodalfitting/models/model.py#L305

DrTaDa avatar Jul 25 '22 11:07 DrTaDa

@alejoe91 thinking about it more, it might be useful for someone else some day. I am not sure what should be done.

DrTaDa avatar Jul 25 '22 11:07 DrTaDa

I think we still use them for the AIS!

alejoe91 avatar Jul 25 '22 11:07 alejoe91

It doesn't look like it: https://github.com/alejoe91/multimodalfitting/blob/master/cell_models/hay_ais/parameters.json

DrTaDa avatar Jul 25 '22 12:07 DrTaDa

in the exp models: https://github.com/alejoe91/multimodalfitting/blob/master/cell_models/cell1_211011_3436/parameters.json#L656-L670

alejoe91 avatar Jul 25 '22 12:07 alejoe91

I'll fix the typos

alejoe91 avatar Jul 25 '22 12:07 alejoe91

in the exp models: https://github.com/alejoe91/multimodalfitting/blob/master/cell_models/cell1_211011_3436/parameters.json#L656-L670

Maybe I misunderstood, but that still works with vanilla BPO as it does not use a parameter dependency.

DrTaDa avatar Jul 26 '22 07:07 DrTaDa

in the exp models: https://github.com/alejoe91/multimodalfitting/blob/master/cell_models/cell1_211011_3436/parameters.json#L656-L670

Maybe I misunderstood, but that still works with vanilla BPO as it does not use a parameter dependency.

Maybe you are right! We just need to test that both the hay and the experimental models un fine.

alejoe91 avatar Jul 26 '22 08:07 alejoe91

@anilbey thank for your comments. We are patching this PR on the side. maybe wait a bit before reviewing the code more.

DrTaDa avatar Jul 28 '22 09:07 DrTaDa

Hi @alejoe91, @wvangeit; as mpi4py appeared to be a problem, I've made a PR to LFPy (https://github.com/LFPy/LFPy/pull/433) that removes this package dependency altogether (by using similar MPI communication provided via neuron.h.ParallelContext()). Seems to work in my own testing but it should be tested also with this PR before merging.

espenhgn avatar Aug 19 '22 06:08 espenhgn

There are just some formatting issues at the moment.

wvangeit avatar Aug 22 '22 10:08 wvangeit

I think the formatting issues have been solved in the master branch of BlueBrain/BluePyOpt. So a merge branch 'master' into 'lfpy' should solve them.

AurelienJaquier avatar Aug 22 '22 13:08 AurelienJaquier

Codecov Report

Merging #385 (1e56736) into master (519b2fc) will decrease coverage by 0.69%. The diff coverage is 86.18%.

@@            Coverage Diff             @@
##           master     #385      +/-   ##
==========================================
- Coverage   89.53%   88.84%   -0.70%     
==========================================
  Files          34       35       +1     
  Lines        2361     2977     +616     
==========================================
+ Hits         2114     2645     +531     
- Misses        247      332      +85     
Impacted Files Coverage Δ
bluepyopt/ephys/morphologies.py 96.51% <75.00%> (+0.12%) :arrow_up:
bluepyopt/ephys/stimuli.py 95.23% <76.66%> (-4.77%) :arrow_down:
bluepyopt/ephys/models.py 86.36% <78.81%> (-4.74%) :arrow_down:
bluepyopt/ephys/simulators.py 86.95% <80.64%> (-2.33%) :arrow_down:
bluepyopt/ephys/efeatures.py 85.45% <83.06%> (-4.09%) :arrow_down:
bluepyopt/ephys/parameters.py 88.46% <83.33%> (-1.34%) :arrow_down:
bluepyopt/ephys/responses.py 86.66% <87.50%> (+0.30%) :arrow_up:
bluepyopt/ephys/parameterscalers.py 91.13% <88.57%> (-0.39%) :arrow_down:
bluepyopt/ephys/protocols.py 83.44% <93.33%> (+0.46%) :arrow_up:
bluepyopt/ephys/recordings.py 97.22% <94.44%> (-2.78%) :arrow_down:
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Dec 06 '22 10:12 codecov-commenter

Should we merge this, @alejoe91 @DrTaDa @AurelienJaquier ?

wvangeit avatar Dec 06 '22 10:12 wvangeit

Yes !

DrTaDa avatar Dec 06 '22 11:12 DrTaDa