{"action":"created","issue":{"url":"https://api.github.com/repos/nest/nest-simulator/issues/497","repository_url":"https://api.github.com/repos/nest/nest-simulator","labels_url":"https://api.github.com/repos/nest/nest-simulator/issues/497/labels{/name}","comments_url":"https://api.github.com/repos/nest/nest-simulator/issues/497/comments","events_url":"https://api.github.com/repos/nest/nest-simulator/issues/497/events","html_url":"https://github.com/nest/nest-simulator/pull/497","id":179798425,"number":497,"title":"Device for recording weights of plastic synapses","user":{"login":"weidel-p","id":12795254,"avatar_url":"https://avatars.githubusercontent.com/u/12795254?v=3","gravatar_id":"","url":"https://api.github.com/users/weidel-p","html_url":"https://github.com/weidel-p","followers_url":"https://api.github.com/users/weidel-p/followers","following_url":"https://api.github.com/users/weidel-p/following{/other_user}","gists_url":"https://api.github.com/users/weidel-p/gists{/gist_id}","starred_url":"https://api.github.com/users/weidel-p/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weidel-p/subscriptions","organizations_url":"https://api.github.com/users/weidel-p/orgs","repos_url":"https://api.github.com/users/weidel-p/repos","events_url":"https://api.github.com/users/weidel-p/events{/privacy}","received_events_url":"https://api.github.com/users/weidel-p/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-09-28T14:59:43Z","updated_at":"2016-09-29T09:40:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nest/nest-simulator/pulls/497","html_url":"https://github.com/nest/nest-simulator/pull/497","diff_url":"https://github.com/nest/nest-simulator/pull/497.diff","patch_url":"https://github.com/nest/nest-simulator/pull/497.patch"},"body":"Hi,\r\n\r\nwith this PR I'd like to add a device (`weight_recorder`)  to NEST allowing the user to record the weight-changes of plastic synapses during the simulation.\r\n\r\nUntil now, it was necessary to stop the simulation, read the synaptic weights using `GetConnections` and `GetStatus` and resume the simulation  in order to record the changes of the synaptic strengths during a simulation. With the `weight_recorder` the changes of synaptic strengths are recorded on the fly and without the need to stop the simulation.\r\n\r\nTo achieve a consistent user experience and for minimizing the memory overhead, the usage of the `weight_recorder` is based on the `volume_transmitter`; the `weight_recorder` is registered to a synapse in the `CommonSynapsePorperties` using `SetDefaults` or `CopyModel`.\r\n\r\nHere is an example pyNEST script using the `weight_recorder` with the `stdp_synapse`:\r\n\r\n```\r\nimport nest\r\n\r\nwr = nest.Create('weight_recorder', 1, {\"to_file\": True})\r\nnest.CopyModel(\"stdp_synapse\", \"stdp_synapse_rec\", {\"weight_recorder\": wr[0]})\r\n\r\nsg = nest.Create(\"spike_generator\", params={\"spike_times\": [10., 15., 55., 70.]})\r\npre = nest.Create(\"parrot_neuron\", 1)\r\npost = nest.Create(\"parrot_neuron\", 1)\r\n\r\nnest.Connect(pre, post, syn_spec=\"stdp_synapse_rec\")\r\nnest.Connect(sg, pre)\r\n\r\nnest.Simulate(100)\r\n```\r\n\r\nInternally, the `weight_recorder` is based on the `spike_detector` but handles `WeightRecorderEvent` instead of `SpikeEvent` and can not be used as a global receiver. \r\nAs a synapse has no `id` in NEST,  the `WeightRecorderEvent` has an additional field `receiver_gid` containing the gid of the postynaptic neuron, which allows the user to identify a synapse by the gid of the pre- and postsynaptic neuron. (This, of course, can not work for multapses)\r\n\r\nHere is the output of the `weight_recorder` running the example script above:\r\nThe columns containing the `sender_gid`, `receiver_gid`, `time`, `weight` in this order.\r\n```\r\n3       4       11.000  1.000   \r\n3       4       16.000  1.879   \r\n3       4       56.000  3.450   \r\n3       4       71.000  4.504\r\n```\r\n\r\nAs mentioned above, the `weight_recorder` is registered to a synapse in the `CommonSynapseProperties`.  Also worth mentioning is that the `WeightRecorderEvent` is sent to the `weight_recorder` in `connector_base.h`. This implementation leads to an easy and general solution: every existing and future synapse can make use of the `weight_recorder` without changing the implementation or caring about it. The drawback of this solution is one additional `if` statement in the send function, which might slow down the simulation.\r\n\r\nThis PR also contains a pyNEST unittest, testing for consistent results of the weights recorded by the `weight_recorder` using a single and multiple threads."},"comment":{"url":"https://api.github.com/repos/nest/nest-simulator/issues/comments/250419074","html_url":"https://github.com/nest/nest-simulator/pull/497#issuecomment-250419074","issue_url":"https://api.github.com/repos/nest/nest-simulator/issues/497","id":250419074,"user":{"login":"weidel-p","id":12795254,"avatar_url":"https://avatars.githubusercontent.com/u/12795254?v=3","gravatar_id":"","url":"https://api.github.com/users/weidel-p","html_url":"https://github.com/weidel-p","followers_url":"https://api.github.com/users/weidel-p/followers","following_url":"https://api.github.com/users/weidel-p/following{/other_user}","gists_url":"https://api.github.com/users/weidel-p/gists{/gist_id}","starred_url":"https://api.github.com/users/weidel-p/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weidel-p/subscriptions","organizations_url":"https://api.github.com/users/weidel-p/orgs","repos_url":"https://api.github.com/users/weidel-p/repos","events_url":"https://api.github.com/users/weidel-p/events{/privacy}","received_events_url":"https://api.github.com/users/weidel-p/received_events","type":"User","site_admin":false},"created_at":"2016-09-29T09:40:46Z","updated_at":"2016-09-29T09:40:46Z","body":"@abigailm: Recording the weight-changes of all synapses in a large scale simulation will lead to a large amount of data. To limit the amount of recorded data, the user can specify subpopulations using a `weight_recorder` before/during the wiring of the network using `CopyModel`. \r\n\r\nSo in general this PR covers this aspect, but I agree that the workflow could be nicer. I would prefer to register a `weight_recorder` to a subset ob synapses after wiring the network using `SetStatus` on selected connections. This means that the `weight_recorder` would have to be registered in the properties of every synapse instead of in the `CommonSynapseProperties` resulting in an increased memory overhead. I don't know how bad this would be for HPC applications, but I didn't want to limit the HPC capacity of NEST with this device. \r\n\r\nI am open for suggestions to improve the implementation. Maybe I missed a smart way to implement a nicer workflow without increasing the memory overhead."}}
{"actor":{"display_login":"weidel-p"}}