Skip to content

Commit

Permalink
Merge branch 'CSNG-MFF:master' into lgn_playground_2
Browse files Browse the repository at this point in the history
  • Loading branch information
rozsatib authored May 7, 2024
2 parents 9f5a369 + 4b22727 commit 3634eb0
Show file tree
Hide file tree
Showing 16 changed files with 333 additions and 65 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/fast-model-mpi-explosion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

name: Fast model MPI tests

on: [push, pull_request]

jobs:

pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Pytest Unit Tests
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install prerequisites
run: |
sudo apt-get update
sudo apt-get install python3-setuptools subversion git libopenmpi-dev g++ libjpeg8 libjpeg8-dev libfreetype6 libfreetype6-dev zlib1g-dev libpng++-dev libncurses5 libncurses5-dev libreadline-dev liblapack-dev libblas-dev gfortran libgsl0-dev openmpi-bin python-tk cmake
pip3 install pytest pytest-cov pytest-randomly coverage black
# TODO: Remove fixed numpy and pynn versions after the PyNN pull request
# https://github.com/NeuralEnsemble/PyNN/pull/762 is accepted
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo==0.12.0 cython pynn==0.10.0 psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
- name: Download and install imagen
run: |
git clone https://github.com/antolikjan/imagen.git
cd imagen
python setup.py install
cd ..
- name: Install Nest
run: |
wget https://github.com/nest/nest-simulator/archive/v3.1.tar.gz
tar xvfz v3.1.tar.gz
cd nest-simulator-3.1
cmake -Dwith-mpi=ON -Dwith-boost=ON -DCMAKE_INSTALL_PREFIX:PATH=$pythonLocation -Dwith-optimize='-O3' ./
make -j8
make -j8 install
cd ..
python -c 'import nest'
- name: Install mozaik
run: python setup.py install

- name: Test with pytest
run: pytest -m "mpi and not not_github and mpi_explosion" ./tests/full_model/test_models_mpi.py --cov=mozaik
4 changes: 2 additions & 2 deletions .github/workflows/fast-model-mpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
pip3 install pytest pytest-cov pytest-randomly coverage black
# TODO: Remove fixed numpy and pynn versions after the PyNN pull request
# https://github.com/NeuralEnsemble/PyNN/pull/762 is accepted
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo cython pynn==0.10.0 psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo==0.12.0 cython pynn==0.10.0 psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
- name: Download and install imagen
run: |
git clone https://github.com/antolikjan/imagen.git
Expand All @@ -41,4 +41,4 @@ jobs:
run: python setup.py install

- name: Test with pytest
run: pytest -v -s -m "mpi and not not_github" ./tests/full_model/test_models_mpi.py --cov=mozaik
run: pytest -m "mpi and not not_github and not mpi_explosion" ./tests/full_model/test_models_mpi.py --cov=mozaik
6 changes: 3 additions & 3 deletions .github/workflows/fast-model-stepcurrentmodule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
pip3 install pytest pytest-cov pytest-randomly coverage black
# TODO: Remove fixed numpy and pynn versions after the PyNN pull request
# https://github.com/NeuralEnsemble/PyNN/pull/762 is accepted
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo cython psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo==0.12.0 cython psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
- name: Download and install imagen
run: |
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Download and install PyNN
run: |
git clone https://github.com/RCagnol/PyNN.git
git clone https://github.com/CSNG-MFF/PyNN.git
cd PyNN
git checkout PyNNStepCurrentModule
pip install .
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Install stepcurrentmodule
run: |
git clone https://github.com/RCagnol/nest-step-current-module.git
git clone https://github.com/CSNG-MFF/nest-step-current-module.git
cd nest-step-current-module
cmake -Dwith-mpi=ON -Dwith-boost=ON -Dwith-nest=$pythonLocation/bin/nest-config -Dwith-optimize='-O3' ./
make -j8
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fast-model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
pip3 install pytest pytest-cov pytest-randomly coverage black
# TODO: Remove fixed numpy and pynn versions after the PyNN pull request
# https://github.com/NeuralEnsemble/PyNN/pull/762 is accepted
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo cython pynn==0.10.0 psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo==0.12.0 cython pynn==0.10.0 psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
- name: Download and install imagen
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lsv1m-model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
pip3 install pytest pytest-cov pytest-randomly coverage black
# TODO: Remove fixed numpy and pynn versions after the PyNN pull request
# https://github.com/NeuralEnsemble/PyNN/pull/762 is accepted
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo cython pynn==0.10.0 psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo==0.12.0 cython pynn==0.10.0 psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
- name: Download and install imagen
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
pip3 install pytest pytest-cov pytest-randomly coverage black
# TODO: Remove fixed numpy and pynn versions after the PyNN pull request
# https://github.com/NeuralEnsemble/PyNN/pull/762 is accepted
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo cython pynn==0.10.0 psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo==0.12.0 cython pynn==0.10.0 psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
- name: Download and install imagen
run: |
Expand Down
13 changes: 6 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ ____________

Now you can install all other dependencies in this protected environment::

pip3 install numpy scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo cython psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo cython psutil future requests elephant pytest-xdist pytest-timeout junitparser numba
pip3 install numpy==1.23.5 scipy mpi4py matplotlib quantities lazyarray interval Pillow param==1.5.1 parameters neo==0.12.0 cython psutil future requests elephant pytest-xdist pytest-timeout junitparser numba

Next we will manually install several packages. It is probably the best if you create a separate directory in an appropriate
place, where you will download and install the packages from.
Expand All @@ -61,18 +60,18 @@ First install the *imagen* package::

git clone https://github.com/CSNG-MFF/imagen.git
cd imagen
python setup.py install
pip install .

Then install the *PyNN* package from the PyNNStepCurrentModule branch::

git clone https://github.com/CSNG-MFF/PyNN.git
cd PyNN
git checkout PyNNStepCurrentModule
python setup.py install
pip install .

Next install the *Nest* simulator (always in the virtual environment):

- download the latest version from their `website <http://www.nest-initiative.org/index.php/Software:Download>`_
- download the latest version from their `website <http://www.nest-initiative.org/index.php/Software:Download>`_::
wget https://github.com/nest/nest-simulator/archive/refs/tags/v3.4.tar.gz
Expand Down Expand Up @@ -109,7 +108,7 @@ Then install the *stepcurrentmodule* Nest module:
git clone https://github.com/CSNG-MFF/nest-step-current-module.git
cd nest-step-current-module

- then configure it relatively to your nest-config installation path (should reside in $HOME/virt_env/mozaik/bin/nest-config)::
- then, in the following command, replace NEST_CONFIG_PATH by your nest-config installation path (should reside in $HOME/virt_env/mozaik/bin/nest-config) and run it::
(mozaik)$ cmake -Dwith-mpi=ON -Dwith-boost=ON -Dwith-optimize='-O3' -Dwith-nest=NEST_CONFIG_PATH ./

Expand All @@ -126,7 +125,7 @@ And, finally, Mozaik::
git clone https://github.com/CSNG-MFF/mozaik.git
cd mozaik
python setup.py install
pip install .

.. _ref-run:
Expand Down
42 changes: 21 additions & 21 deletions mozaik/experiments/optogenetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ def stimulating_signal_function(sheet, coor_x, coor_y, update_interval, paramete

def __init__(self, model, parameters):
CorticalStimulationWithOptogeneticArray.__init__(self, model, parameters)
self.parameters.stimulator_array_parameters[
"stimulating_signal"
] = self.parameters.stimulating_signal
self.parameters.stimulator_array_parameters[
"stimulating_signal_parameters"
] = self.parameters.stimulating_signal_parameters
self.parameters.stimulator_array_parameters["stimulating_signal"] = (
self.parameters.stimulating_signal
)
self.parameters.stimulator_array_parameters["stimulating_signal_parameters"] = (
self.parameters.stimulating_signal_parameters
)

self.append_direct_stim(model, self.parameters.stimulator_array_parameters)

Expand Down Expand Up @@ -333,9 +333,9 @@ class OptogeneticArrayStimulusCircles(CorticalStimulationWithOptogeneticArray):
def __init__(self, model, parameters):
CorticalStimulationWithOptogeneticArray.__init__(self, model, parameters)
sap = self.parameters.stimulator_array_parameters
sap[
"stimulating_signal"
] = "mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
sap["stimulating_signal"] = (
"mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
)
sap["stimulating_signal_parameters"] = ParameterSet(
{
"shape": "circle",
Expand Down Expand Up @@ -457,9 +457,9 @@ class OptogeneticArrayStimulusHexagonalTiling(CorticalStimulationWithOptogenetic
def __init__(self, model, parameters):
CorticalStimulationWithOptogeneticArray.__init__(self, model, parameters)
sap = self.parameters.stimulator_array_parameters
sap[
"stimulating_signal"
] = "mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
sap["stimulating_signal"] = (
"mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
)
sap["stimulating_signal_parameters"] = ParameterSet(
{
"shape": "hexagon",
Expand Down Expand Up @@ -621,9 +621,9 @@ class OptogeneticArrayImageStimulus(CorticalStimulationWithOptogeneticArray):
def __init__(self, model, parameters):
CorticalStimulationWithOptogeneticArray.__init__(self, model, parameters)
sap = self.parameters.stimulator_array_parameters
sap[
"stimulating_signal"
] = "mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
sap["stimulating_signal"] = (
"mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
)
sap["stimulating_signal_parameters"] = ParameterSet(
{
"shape": "image",
Expand Down Expand Up @@ -741,9 +741,9 @@ def __init__(self, model, parameters):
self.parameters["sheet_intensity_scaler"] = [1 for s in sl]
self.parameters["sheet_transfection_proportion"] = [1 for s in sl]
sap = self.parameters.stimulator_array_parameters
sap[
"stimulating_signal"
] = "mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
sap["stimulating_signal"] = (
"mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
)
sap["stimulating_signal_parameters"] = ParameterSet(
{
"shape": "or_map",
Expand Down Expand Up @@ -885,9 +885,9 @@ def __init__(self, model, parameters):
self.parameters["sheet_intensity_scaler"] = [1 for s in sl]
self.parameters["sheet_transfection_proportion"] = [1 for s in sl]
sap = self.parameters.stimulator_array_parameters
sap[
"stimulating_signal"
] = "mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
sap["stimulating_signal"] = (
"mozaik.sheets.direct_stimulator.stimulating_pattern_flash"
)
sap["stimulating_signal_parameters"] = ParameterSet(
{
"shape": "or_map",
Expand Down
24 changes: 24 additions & 0 deletions mozaik/storage/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,30 @@ def get_analysis_result(self, **kwargs):
"""
return filter_query(self.analysis_results,**kwargs)

def sort_analysis_results(self, key, reverse=False):
if key[0:3] == 'st_':
ads_id = []
ads_id_nkey = []
ads_nid = []
for ads in self.analysis_results:
if ads.stimulus_id is None:
ads_nid.append(ads)
else:
if hasattr(MozaikParametrized.idd(ads.stimulus_id),key[3:]):
ads_id.append(ads)
else:
ads_id_nkey.append(ads)
self.analysis_results = ads_nid + ads_id_nkey + sorted(ads_id, key= lambda x:getattr(MozaikParametrized.idd(x.stimulus_id),key[3:]),reverse=reverse)
else:
ads_key = []
ads_nkey = []
for ads in self.analysis_results:
if hasattr(ads,key):
ads_key.append(ads)
else:
ads_nkey.append(ads)
self.analysis_results = ads_nkey + sorted(ads_key, key= lambda x:getattr(x,key),reverse=reverse)

def get_sensory_stimulus(self, stimuli=None):
"""
Return the raw sensory stimulus that has been presented to the model due to stimuli specified by the stimuli argument.
Expand Down
Loading

0 comments on commit 3634eb0

Please sign in to comment.