49 for (
int i = 0; i < D; ++i )
51 displ[ i ] -= from_pos[ i ];
55 if ( displ[ i ] < -0.5 *
extent_[ i ] )
67 const std::vector< double >& to_pos,
68 const unsigned int dimension )
const
70 double displacement = to_pos[ dimension ] - from_pos[ dimension ];
125 assert( target_abs );
130 connector.
connect( *
this, source_nc, tgt, target_nc );
132 catch ( std::bad_cast& e )
134 throw BadProperty(
"Target layer must have same number of dimensions as source layer." );
139std::shared_ptr< Ntree< D, size_t > >
157std::shared_ptr< Ntree< D, size_t > >
167 for (
int i = 0; i < D; ++i )
169 if ( not periodic[ i ] )
188std::shared_ptr< Ntree< D, size_t > >
209std::vector< std::pair< Position< D >,
size_t > >*
220 cached_vector_ =
new std::vector< std::pair< Position< D >,
size_t > >;
226 typename std::back_insert_iterator< std::vector< std::pair< Position< D >,
size_t > > > to =
247std::vector< std::pair< Position< D >,
size_t > >
250 bool allow_oversized,
253 MaskedLayer< D > masked_layer( *
this, mask, allow_oversized, node_collection );
254 std::vector< std::pair< Position< D >,
size_t > > positions;
259 positions.push_back( *iter );
268 const std::vector< double >& anchor,
269 bool allow_oversized,
272 MaskedLayer< D > masked_layer( *
this, mask, allow_oversized, node_collection );
273 std::vector< size_t > nodes;
276 nodes.push_back( i->second );
289 out << ( *it ).node_id <<
' ';
300 const std::string& syn_model )
314 size_t previous_source_node_id = 0;
316 for (
const auto& conn_part : connectome )
318 for (
const auto& conn : conn_part )
320 const size_t source_node_id = conn.get_source_node_id();
323 if ( source_node_id != previous_source_node_id )
325 const auto it = std::find_if( src_vec->begin(),
327 [ source_node_id ](
const std::pair<
Position< D >,
size_t >& p ) { return p.second == source_node_id; } );
328 assert( it != src_vec->end() );
330 source_pos = it->first;
331 previous_source_node_id = source_node_id;
335 conn.get_target_node_id(),
336 conn.get_target_thread(),
337 conn.get_synapse_model_id(),
345 const long tnode_lid = tgt_layer->node_collection_->get_nc_index( target_node_id );
346 assert( tnode_lid >= 0 );
349 out << source_node_id <<
' ' << target_node_id <<
' ' << weight <<
' ' << delay <<
' ';
350 tgt_layer->compute_displacement( source_pos, tnode_lid ).print( out );
360 if ( not
mask_.get() )
373 if ( grid_layer == 0 )
375 throw BadProperty(
"Grid masks can only be used with grid layers." );
381 if ( not allow_oversized )
383 bool oversize =
false;
384 for (
int i = 0; i < D; ++i )
392 "Mask size must not exceed layer size; set allow_oversized_mask to "
400 const double y = lower_left[ 1 ];
401 lower_left[ 1 ] = -upper_right[ 1 ];
402 upper_right[ 1 ] = -y;
406 catch ( std::bad_cast& )
415 if ( not allow_oversized )
417 const Box< D > bb = mask.get_bbox();
418 bool oversize =
false;
419 for (
int i = 0; i < D; ++i )
427 "Mask size must not exceed layer size; set allow_oversized_mask to "
432 catch ( std::bad_cast& )
434 throw BadProperty(
"Mask is incompatible with layer." );
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
T get(const std::string &key) const
Get the value at key in the specified type.
Definition dictionary.h:710
AbstractLayer()
Definition layer.h:54
static NodeCollectionMetadataPTR cached_ntree_md_
Metadata for the layer for which we cache global position information.
Definition layer.h:187
NodeCollectionPTR node_collection_
The NodeCollection to which the layer belongs.
Definition layer.h:182
static NodeCollectionMetadataPTR cached_vector_md_
Metadata for the layer for which we cache global position information.
Definition layer.h:192
Mask which covers all of space.
Definition mask.h:155
Exception to be thrown if a status parameter is incomplete or inconsistent.
Definition exceptions.h:680
Mask defining a box region.
Definition mask.h:209
This class is a representation of the dictionary of connection properties given as an argument to the...
Definition connection_creator.h:66
void connect(Layer< D > &source, NodeCollectionPTR source_nc, Layer< D > &target, NodeCollectionPTR target_nc)
Connect two layers.
Definition connection_creator_impl.h:38
Dictionary get_synapse_status(const size_t source_node_id, const size_t target_node_id, const size_t tid, const synindex syn_id, const size_t lcid) const
Definition connection_manager.cpp:245
std::vector< std::deque< ConnectionID > > get_connections(const Dictionary ¶ms)
Return connections between pairs of neurons.
Definition connection_manager.cpp:1129
Layer with neurons placed in a grid.
Definition grid_layer.h:40
Position< D, size_t > get_dims() const
Definition grid_layer.h:169
Mask defined in terms of grid points rather than spacial coordinates.
Definition grid_mask.h:40
Position< D, int > get_lower_right() const
Definition grid_mask.h:95
Position< D, int > get_upper_left() const
Definition grid_mask.h:89
Abstract base class for Layer of given dimension (D=2 or 3).
Definition layer.h:218
void clear_vector_cache_() const override
Clear the cache for global position information.
Definition layer.h:681
static std::vector< std::pair< Position< D >, size_t > > * cached_vector_
Definition layer.h:447
virtual void insert_global_positions_ntree_(Ntree< D, size_t > &tree, NodeCollectionPTR node_collection)=0
Insert global position info into ntree.
std::shared_ptr< Ntree< D, size_t > > get_global_positions_ntree(NodeCollectionPTR node_collection)
Get positions for all nodes in layer, including nodes on other MPI processes.
Definition layer_impl.h:140
void clear_ntree_cache_() const override
Clear the cache for global position information.
Definition layer.h:673
Position< D > extent_
size of layer
Definition layer.h:440
Layer()
Creates an empty layer.
Definition layer.h:590
Position< D > compute_displacement(const Position< D > &from_pos, const Position< D > &to_pos) const
Returns displacement of a position from another position.
Definition layer_impl.h:46
std::shared_ptr< Ntree< D, size_t > > do_get_global_positions_ntree_(NodeCollectionPTR node_collection)
Definition layer_impl.h:189
void set_status(const Dictionary &) override
Change properties of the layer according to the entries in the dictionary.
Definition layer_impl.h:80
void connect(NodeCollectionPTR source_nc, AbstractLayerPTR target, NodeCollectionPTR target_nc, ConnectionCreator &connector) override
Connect this layer to the given target layer.
Definition layer_impl.h:117
void dump_nodes(std::ostream &os) const override
Write layer data to stream.
Definition layer_impl.h:283
std::bitset< D > get_periodic_mask() const
Definition layer.h:277
std::vector< size_t > get_global_nodes(const MaskPTR mask, const std::vector< double > &anchor, bool allow_oversized, NodeCollectionPTR node_collection) override
Return a vector with the node IDs of the nodes inside the mask.
Definition layer_impl.h:267
const Position< D > & get_extent() const
Definition layer.h:259
friend class MaskedLayer< D >
Definition layer.h:449
void get_status(Dictionary &, NodeCollection const *const) const override
Retrieve status, slice according to node collection if given.
Definition layer_impl.h:93
std::bitset< D > periodic_
periodic b.c.
Definition layer.h:441
static std::shared_ptr< Ntree< D, size_t > > cached_ntree_
Global position information for a single layer.
Definition layer.h:446
void dump_connections(std::ostream &out, NodeCollectionPTR node_collection, AbstractLayerPTR target_layer, const std::string &syn_model) override
Dumps information about all connections of the given type having their source in the given layer to t...
Definition layer_impl.h:297
std::vector< std::pair< Position< D >, size_t > > * get_global_positions_vector(NodeCollectionPTR node_collection)
Definition layer_impl.h:210
virtual void insert_global_positions_vector_(std::vector< std::pair< Position< D >, size_t > > &, NodeCollectionPTR)=0
Insert global position info into vector.
Position< D > lower_left_
lower left corner (minimum coordinates) of layer
Definition layer.h:439
Abstract base class for masks with given dimension.
Definition mask.h:101
void check_mask_(Layer< D > &layer, bool allow_oversized)
Will check that the mask can be applied to the layer.
Definition layer_impl.h:358
Ntree< D, size_t >::masked_iterator begin(const Position< D > &anchor)
Iterate over nodes inside mask.
Definition layer.h:570
Ntree< D, size_t >::masked_iterator end()
Definition layer.h:584
MaskPTR mask_
Definition layer.h:520
Superclass for NodeCollections.
Definition node_collection.h:565
nc_const_iterator const_iterator
Definition node_collection.h:569
virtual size_t size() const =0
Get the size of the NodeCollection.
Iterator iterating the nodes in a Quadtree.
Definition ntree.h:69
Iterator iterating the nodes in a Quadtree inside a Mask.
Definition ntree.h:153
A Ntree object represents a subtree or leaf in a Ntree structure.
Definition ntree.h:55
ConnectionManager connection_manager
Definition kernel_manager.h:239
const std::string delay("delay")
const std::string network_size("network_size")
const std::string center("center")
const std::string edge_wrap("edge_wrap")
const std::string target("target")
const std::string weight("weight")
const std::string extent("extent")
const std::string source("source")
const std::string synapse_model("synapse_model")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
std::shared_ptr< NodeCollectionMetadata > NodeCollectionMetadataPTR
Definition node_collection.h:51
KernelManager & kernel()
Definition kernel_manager.h:311
std::shared_ptr< AbstractLayer > AbstractLayerPTR
Definition layer.h:46
std::shared_ptr< NodeCollection > NodeCollectionPTR
Definition node_collection.h:50
std::vector< std::vector< double > > displacement(NodeCollectionPTR layer_to_nc, NodeCollectionPTR layer_from_nc)
Definition spatial.cpp:137
std::shared_ptr< AbstractMask > MaskPTR
Definition mask.h:44
std::vector< std::vector< double > > get_position(NodeCollectionPTR layer_nc)
Definition spatial.cpp:83
A box is defined by the lower left corner (minimum coordinates) and the upper right corner (maximum c...
Definition position.h:321
Position< D > lower_left
Definition position.h:331
Position< D > upper_right
Definition position.h:332