NEST main@caf0ae8
 
Loading...
Searching...
No Matches
weight_recorder.h
Go to the documentation of this file.
1/*
2 * weight_recorder.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef WEIGHT_RECORDER_H
24#define WEIGHT_RECORDER_H
25
26// C++ includes:
27#include <vector>
28
29// Includes from nestkernel:
30#include "device_node.h"
31#include "event.h"
32#include "exceptions.h"
33#include "kernel_manager.h"
34#include "nest_types.h"
35#include "recording_device.h"
36
37/* BeginUserDocs: device, recorder
38
39Short description
40+++++++++++++++++
41
42Recording weights from synapses
43
44Description
45+++++++++++
46
47The change in synaptic weights over time is a key observable property in
48studies of plasticity in neuronal network models. To access this information, the
49``weight_recorder`` can be used. In contrast to other recording
50devices, which are connected to a specific set of neurons, the weight
51recorder is instead set as a parameter in the synapse model.
52
53After assigning an instance of a weight recorder to the synapse model
54by setting its ``weight_recorder`` property, the weight
55recorder collects the global IDs of source and target neurons together
56with the weight for each spike event that travels through the observed
57synapses.
58
59To only record from a subset of connected synapses, the
60weight recorder accepts NodeCollections in the parameters ``senders`` and
61``targets``. If set, they restrict the recording of data to only
62synapses that fulfill the given criteria.
63
64::
65
66 >>> wr = nest.Create("weight_recorder")
67 >>> nest.CopyModel("stdp_synapse", "stdp_synapse_rec", {"weight_recorder": wr})
68
69 >>> pre = nest.Create("iaf_psc_alpha", 10)
70 >>> post = nest.Create("iaf_psc_alpha", 10)
71
72 >>> nest.Connect(pre, post, syn_spec="stdp_synapse_rec")
73
74.. include:: ../models/recording_device.rst
75
76See also
77++++++++
78
79
80Examples using this model
81+++++++++++++++++++++++++
82
83.. listexamples:: weight_recorder
84
85EndUserDocs */
86
87namespace nest
88{
89
90void register_weight_recorder( const std::string& name );
91
93{
94
95public:
98
99 bool
100 has_proxies() const override
101 {
102 return false;
103 }
104
105 bool
106 local_receiver() const override
107 {
108 return true;
109 }
110
111 std::string
112 get_element_type() const override
113 {
114 return names::recorder;
115 }
116
122 using Node::handle;
125
126 void handle( WeightRecorderEvent& ) override;
127
128 size_t handles_test_event( WeightRecorderEvent&, size_t ) override;
129
130 Type get_type() const override;
131 SignalType receives_signal() const override;
132
133 void get_status( Dictionary& ) const override;
134 void set_status( const Dictionary& ) override;
135
136private:
137 void pre_run_hook() override;
138 void update( Time const&, const long, const long ) override;
139
141 {
144
145 Parameters_();
146 Parameters_( const Parameters_& ) = default;
147 Parameters_& operator=( const Parameters_& ) = default;
148 void get( Dictionary& ) const;
149 void set( const Dictionary& );
150 };
151
153};
154
155inline size_t
157{
158 if ( receptor_type != 0 )
159 {
160 throw UnknownReceptorType( receptor_type, get_name() );
161 }
162 return 0;
163}
164
165inline SignalType
167{
168 return ALL;
169}
170
171} // namespace
172
173#endif /* #ifndef WEIGHT_RECORDER_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
virtual SignalType receives_signal() const
Definition node.h:974
std::string get_name() const
Return class name.
Definition node.cpp:105
Base class for all recording devices.
Definition recording_device.h:157
Type
Definition recording_device.h:169
Definition nest_time.h:135
Exception to be thrown if the specified receptor type does not exist in the node.
Definition exceptions.h:417
Event for recording the weight of a spike.
Definition event.h:459
Definition weight_recorder.h:93
void get_status(Dictionary &) const override
Export properties of the node by setting entries in the status dictionary.
Definition weight_recorder.cpp:123
Parameters_ P_
Definition weight_recorder.h:152
weight_recorder()
Definition weight_recorder.cpp:46
void pre_run_hook() override
Set internal variables before calls to SimulationManager::run()
Definition weight_recorder.cpp:106
std::string get_element_type() const override
Return the element type of the node.
Definition weight_recorder.h:112
SignalType receives_signal() const override
Definition weight_recorder.h:166
void handle(WeightRecorderEvent &) override
Handle incoming weight recording events.
Definition weight_recorder.cpp:160
void update(Time const &, const long, const long) override
Advance the state of the node in time through the given interval.
Definition weight_recorder.cpp:112
Type get_type() const override
Definition weight_recorder.cpp:117
void set_status(const Dictionary &) override
Change properties of the node according to the entries in the dictionary.
Definition weight_recorder.cpp:149
bool has_proxies() const override
Returns true if the node has proxies on remote threads.
Definition weight_recorder.h:100
bool local_receiver() const override
Returns true if the node only receives events from nodes/devices on the same thread.
Definition weight_recorder.h:106
size_t handles_test_event(WeightRecorderEvent &, size_t) override
Definition weight_recorder.h:156
virtual size_t handles_test_event(SpikeEvent &, size_t receptor_type)
Check if the node can handle a particular event and receptor type.
Definition node.cpp:271
virtual void handle(SpikeEvent &e)
Handle incoming spike events.
Definition node.cpp:265
const std::string recorder("recorder")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
void register_weight_recorder(const std::string &name)
Definition weight_recorder.cpp:40
std::shared_ptr< NodeCollection > NodeCollectionPTR
Definition node_collection.h:50
SignalType
enum type of signal conveyed by spike events of a node.
Definition nest_types.h:165
@ ALL
Definition nest_types.h:169
Definition weight_recorder.h:141
void get(Dictionary &) const
Definition weight_recorder.cpp:67
Parameters_ & operator=(const Parameters_ &)=default
Parameters_()
Definition weight_recorder.cpp:60
NodeCollectionPTR targets_
Definition weight_recorder.h:143
NodeCollectionPTR senders_
Definition weight_recorder.h:142
Parameters_(const Parameters_ &)=default
void set(const Dictionary &)
Definition weight_recorder.cpp:74