Skip to content

Commit

Permalink
Merge branch 'CSNG-MFF:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
juliakrizanova authored Jun 13, 2024
2 parents 47781f3 + 4b22727 commit beab7c4
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fast-model-mpi-explosion.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 Down
2 changes: 1 addition & 1 deletion .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 Down
2 changes: 1 addition & 1 deletion .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 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
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ____________

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

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 @@ -60,14 +60,14 @@ 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):

Expand Down Expand Up @@ -125,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
59 changes: 36 additions & 23 deletions mozaik/visualization/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from neo.core.analogsignal import AnalogSignal as NeoAnalogSignal
from neo.core.spiketrain import SpikeTrain as NeoSpikeTrain
from .simple_plot import StandardStyleLinePlot, SpikeRasterPlot, \
SpikeHistogramPlot, ConductancesPlot, PixelMovie, \
SpikeHistogramPlot, ConductancePlot, ConductancesPlot, PixelMovie, \
ScatterPlotMovie, ScatterPlot, ConnectionPlot, SimplePlot, HistogramPlot, CorticalColumnSpikeRasterPlot, OrderedAnalogSignalListPlot
from .plot_constructors import LinePlot, PerStimulusPlot, PerStimulusADSPlot, ADSGridPlot, MultipleFilesPlot

Expand Down Expand Up @@ -712,51 +712,60 @@ class GSynPlot(Plotting):
spontaneous : bool
Whether to also show the spontaneous activity the preceded the stimulus.
"""
separated : bool
Whether the excitatory and inhibitory conductances should be plotted separately.
"""

required_parameters = ParameterSet({
'neuron': int, # we can only plot one neuron - which one ?
'sheet_name': str,
'spontaneous' : bool, # whether to also show the spontaneous activity the preceded the stimulus
'separated': bool, # Whether the excitatory and inhibitory conductances should be plotted separately
})

def subplot(self, subplotspec):
dsv = queries.param_filter_query(self.datastore,sheet_name=self.parameters.sheet_name)
return PerStimulusPlot(dsv, function=self._ploter, title_style="Standard"
).make_line_plot(subplotspec)

@staticmethod
def concat_asl(asl1,asl2):
assert asl1.sampling_period == asl2.sampling_period
assert asl1.units == asl2.units

return NeoAnalogSignal(numpy.concatenate((asl1.magnitude,asl2.magnitude)),t_start=-asl1.t_stop,
sampling_period=asl1.sampling_period,
units=asl1.units)


def _ploter(self, dsv,gs):
def _ploter(self, dsv, subplotspec):
if self.parameters.separated:
gs = gridspec.GridSpecFromSubplotSpec(2, 1, subplot_spec=subplotspec,hspace=0.3, wspace=0.45)
else:
gs = gridspec.GridSpecFromSubplotSpec(1, 1, subplot_spec=subplotspec)

segs = sorted(dsv.get_segments(),key = lambda x : MozaikParametrized.idd(x.annotations['stimulus']).trial)
gsyn_es = [s.get_esyn(self.parameters.neuron) for s in segs]
gsyn_is = [s.get_isyn(self.parameters.neuron) for s in segs]
params = OrderedDict()

if self.parameters.spontaneous:
segs = sorted(dsv.get_segments(null=True),key = lambda x : MozaikParametrized.idd(x.annotations['stimulus']).trial)
spont_gsyn_es = [s.get_esyn(self.parameters.neuron) for s in segs]
spont_gsyn_is = [s.get_isyn(self.parameters.neuron) for s in segs]
gsyn_es = [GSynPlot.concat_asl(s,n) for n,s in zip(gsyn_es,spont_gsyn_es)]
gsyn_is = [GSynPlot.concat_asl(s,n) for n,s in zip(gsyn_is,spont_gsyn_is)]
spont_gsyn_es = [s.get_esyn(self.parameters.neuron) for s in segs]
spont_gsyn_is = [s.get_isyn(self.parameters.neuron) for s in segs]

gsyn_es = [GSynPlot.concat_asl(s,n) for n,s in zip(gsyn_es,spont_gsyn_es)]
gsyn_is = [GSynPlot.concat_asl(s,n) for n,s in zip(gsyn_is,spont_gsyn_is)]
t_start = - spont_gsyn_es[0].t_stop.magnitude
t_stop = gsyn_es[0].t_stop.magnitude
params = {'x_ticks' : [t_start,0, t_stop/2, t_stop]}
return [("ConductancesPlot",ConductancesPlot(gsyn_es, gsyn_is),gs,params)]





if self.parameters.separated:
return [("ConductancePlotExc",ConductancePlot(gsyn_es,'exc'),gs[0,0],params),
("ConductancePlotInh",ConductancePlot(gsyn_is,'inh'),gs[1,0],params)]
else:
return [("ConductancesPlot",ConductancesPlot(gsyn_es, gsyn_is),gs[0,0],params)]



Expand Down Expand Up @@ -820,7 +829,7 @@ def _ploter(self, dsv,subplotspec):

("Conductance_plot",GSynPlot(dsv,
ParameterSet({'sheet_name': self.parameters.sheet_name,'spontaneous' : self.parameters.spontaneous,
'neuron': self.parameters.neuron})
'separated' : False, 'neuron': self.parameters.neuron})
),gs[1 + offset, 0], {'x_label' : None, 'x_tick_style' : 'Custom' , 'x_tick_labels' : None, 'title' : None}),

("Vm_plot",VmPlot(dsv,
Expand Down Expand Up @@ -1186,6 +1195,9 @@ class PerNeuronValuePlot(Plotting):
cortical_view : bool
Whether to show cortical view or histogram (see class description for full detail.)
neuron_ids : list
List of neurons to plot
Notes
-----
So far doesn't support the situation where several types of PerNeuronValue analysys data structures are present in the supplied
Expand All @@ -1194,6 +1206,7 @@ class PerNeuronValuePlot(Plotting):

required_parameters = ParameterSet({
'cortical_view': bool, #Whether to show cortical view or histogram (see class description for full detail.)
'neuron_ids': list,
})

def __init__(self, datastore, parameters, plot_file_name=None,
Expand All @@ -1215,9 +1228,9 @@ def _ploter(self, dsv, gs):
assert len(pnvs) <= 1, logger.error("We can only display single stimulus parametrization in cortical view, but you have suplied multiple in datastore.")
pnv = pnvs[0]
pos = self.dsv.get_neuron_positions()[pnv.sheet_name]
posx = pos[0,self.datastore.get_sheet_indexes(pnv.sheet_name,pnv.ids)]
posy = pos[1,self.datastore.get_sheet_indexes(pnv.sheet_name,pnv.ids)]
values = pnv.values
posx = pos[0,self.datastore.get_sheet_indexes(pnv.sheet_name,self.parameters.neuron_ids)]
posy = pos[1,self.datastore.get_sheet_indexes(pnv.sheet_name,self.parameters.neuron_ids)]
values = pnv.get_value_by_id(self.parameters.neuron_ids)
if pnv.period != None:
periodic = True
period = pnv.period
Expand All @@ -1240,9 +1253,9 @@ def _ploter(self, dsv, gs):
a = sorted([(','.join([p + ' : ' + str(getattr(MozaikParametrized.idd(pnv.stimulus_id),p)) for p in varying_stim_parameters]),pnv) for pnv in pnvs],key=lambda x: x[0])

if len(a) > 1:
return [("HistogramPlot",HistogramPlot([z[1].values for z in a],labels=[z[0] for z in a]),gs,params)]
return [("HistogramPlot",HistogramPlot([z[1].get_value_by_id(self.parameters.neuron_ids) for z in a],labels=[z[0] for z in a]),gs,params)]
else:
return [("HistogramPlot",HistogramPlot([pnvs[0].values]),gs,params)]
return [("HistogramPlot",HistogramPlot([pnvs[0].get_value_by_id(self.parameters.neuron_ids)]),gs,params)]



Expand Down
Loading

0 comments on commit beab7c4

Please sign in to comment.