Skip to content

Commit

Permalink
Fix for nest#665 including updated topology manual.
Browse files Browse the repository at this point in the history
  • Loading branch information
heplesser committed Feb 28, 2017
1 parent e3e764e commit 88ca8d6
Show file tree
Hide file tree
Showing 20 changed files with 109 additions and 21 deletions.
9 changes: 6 additions & 3 deletions testsuite/regressiontests/issue-665.sli
Expand Up @@ -136,7 +136,8 @@ assert_or_die
{
<< /connection_type /divergent >> layer_to_det_test
}
assert_or_die
fail_or_die
clear

{
% four incoming connections, one to each neuron in layer
Expand All @@ -145,13 +146,15 @@ assert_or_die
/number_of_connections 4
/allow_multapses false >> layer_to_det_test
}
assert_or_die
fail_or_die
clear

{
% one outgoing connection from each neuron in layer
<< /connection_type /divergent
/number_of_connections 1 >> layer_to_det_test
}
assert_or_die
fail_or_die
clear

endusing
87 changes: 75 additions & 12 deletions topology/connection_creator_impl.h
Expand Up @@ -218,36 +218,39 @@ ConnectionCreator::target_driven_connect_( Layer< D >& source,
#pragma omp parallel // default(none) shared(source, target, masked_layer,
// target_begin, target_end)
{
const int thread_id = kernel().vp_manager.get_thread_id();

for ( std::vector< Node* >::const_iterator tgt_it = target_begin;
tgt_it != target_end;
++tgt_it )
{
const thread target_thread = ( *tgt_it )->get_thread();
Node* const tgt =
kernel().node_manager.get_node( ( *tgt_it )->get_gid(), thread_id );
const thread target_thread = tgt->get_thread();

if ( target_thread != kernel().vp_manager.get_thread_id() )
// check whether the target is on our thread
if ( thread_id != target_thread )
{
continue;
}

if ( target_filter_.select_model()
&& ( ( *tgt_it )->get_model_id() != target_filter_.model ) )
&& ( tgt->get_model_id() != target_filter_.model ) )
continue;

const Position< D > target_pos =
target.get_position( ( *tgt_it )->get_subnet_index() );
target.get_position( tgt->get_subnet_index() );

if ( mask_.valid() )
connect_to_target_( pool.masked_begin( target_pos ),
pool.masked_end(),
*tgt_it,
tgt,
target_pos,
target_thread,
thread_id,
source );
else
connect_to_target_( pool.begin(),
pool.end(),
*tgt_it,
target_pos,
target_thread,
source );
connect_to_target_(
pool.begin(), pool.end(), tgt, target_pos, thread_id, source );
} // for target_begin
} // omp parallel
}
Expand Down Expand Up @@ -281,6 +284,21 @@ ConnectionCreator::source_driven_connect_( Layer< D >& source,
target_end = target.local_end();
}

// protect against connecting to devices without proxies
// we need to do this before creating the first connection to leave
// the network untouched if any target does not have proxies
for ( std::vector< Node* >::const_iterator tgt_it = target_begin;
tgt_it != target_end;
++tgt_it )
{
if ( not( *tgt_it )->has_proxies() )
{
throw IllegalConnection(
"Topology Divergent connections"
" to devices are not possible." );
}
}

if ( mask_.valid() )
{

Expand Down Expand Up @@ -458,6 +476,21 @@ ConnectionCreator::convergent_connect_( Layer< D >& source, Layer< D >& target )
target_end = target.local_end();
}

// protect against connecting to devices without proxies
// we need to do this before creating the first connection to leave
// the network untouched if any target does not have proxies
for ( std::vector< Node* >::const_iterator tgt_it = target_begin;
tgt_it != target_end;
++tgt_it )
{
if ( not( *tgt_it )->has_proxies() )
{
throw IllegalConnection(
"Topology Divergent connections"
" to devices are not possible." );
}
}

if ( mask_.valid() )
{

Expand Down Expand Up @@ -727,6 +760,36 @@ template < int D >
void
ConnectionCreator::divergent_connect_( Layer< D >& source, Layer< D >& target )
{
// protect against connecting to devices without proxies
// we need to do this before creating the first connection to leave
// the network untouched if any target does not have proxies
// Nodes in the subnet are grouped by depth, so to select by depth, we
// just adjust the begin and end pointers:
std::vector< Node* >::const_iterator target_begin;
std::vector< Node* >::const_iterator target_end;
if ( target_filter_.select_depth() )
{
target_begin = target.local_begin( target_filter_.depth );
target_end = target.local_end( target_filter_.depth );
}
else
{
target_begin = target.local_begin();
target_end = target.local_end();
}

for ( std::vector< Node* >::const_iterator tgt_it = target_begin;
tgt_it != target_end;
++tgt_it )
{
if ( not( *tgt_it )->has_proxies() )
{
throw IllegalConnection(
"Topology Divergent connections"
" to devices are not possible." );
}
}

// Divergent connections (fixed fan out)
//
// For each (global) source: (All connections made on all mpi procs)
Expand Down
Binary file modified topology/doc/Topology_UserManual.pdf
Binary file not shown.
16 changes: 15 additions & 1 deletion topology/doc/Topology_UserManual.tex
Expand Up @@ -1095,11 +1095,25 @@ \section{Connecting devices to subregions of layers}\label{sec:dev_subregions}
needs to be specified and optionally also an anchor for shifting the
center of the mask.
As demonstrated in the following example, stimulation devices require the
divergent and recording devices the convergent connection type:
divergent connection type
\lstinputlisting[linerange=conn9-end]{user_manual_scripts/connections.py}
while recording devices require the convergent connection type (see also
Sec.~\ref{sec:rec_dev}):
\lstinputlisting[linerange=conn10-end]{user_manual_scripts/connections.py}

\section{Layers and recording devices}\label{sec:rec_dev}

Generally, one should not create a layer of recording devices, especially
spike detectors, to record from a topology layer. Instead, create a single
spike detector, and connect all neurons in the layer to that spike detector
using a normal connect command:
\lstinputlisting[linerange=conn11-end]{user_manual_scripts/connections.py}

Connections to a layer of recording devices as described in
Sec.~\ref{sec:dev_subregions}, such as spike detectors, are
only possible using the convergent connection type without a fixed number
of connections. Note that voltmeter and multimeter are not suffering from
this restriction, since they are connected as sources, not as targets.

\chapter{Inspecting Layers}\label{sec:inspection}

Expand Down
Binary file modified topology/doc/user_manual_figures/conn1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/conn2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/conn3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/conn4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/conn5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/conn6.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/conn_3d.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/layer1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/layer2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/layer3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/layer3a.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/layer4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/layer4_3d.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/player.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified topology/doc/user_manual_figures/vislayer.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 13 additions & 5 deletions topology/doc/user_manual_scripts/connections.py
Expand Up @@ -545,9 +545,9 @@ def pn_fig(fig, loc, ldict, cdict,
# ----------------------------

#{ conn9 #}
nrns = tp.CreateLayer({'rows': 20,
'columns': 20,
'elements': 'iaf_psc_alpha'})
nrn_layer = tp.CreateLayer({'rows': 20,
'columns': 20,
'elements': 'iaf_psc_alpha'})

stim = tp.CreateLayer({'rows': 1,
'columns': 1,
Expand All @@ -557,7 +557,7 @@ def pn_fig(fig, loc, ldict, cdict,
'mask': {'circular': {'radius': 0.1},
'anchor': [0.2, 0.2]}}

tp.ConnectLayers(stim, nrns, cdict_stim)
tp.ConnectLayers(stim, nrn_layer, cdict_stim)
#{ end #}


Expand All @@ -572,5 +572,13 @@ def pn_fig(fig, loc, ldict, cdict,
'mask': {'circular': {'radius': 0.1},
'anchor': [-0.2, 0.2]}}

tp.ConnectLayers(nrns, rec, cdict_rec)
tp.ConnectLayers(nrn_layer, rec, cdict_rec)
#{ end #}

# ----------------------------

#{ conn11 #}
rec = nest.Create('spike_detector')
nrns = nest.GetLeaves(nrn_layer, local_only=True)
nest.Connect(nrns, rec)
#{ end #}

0 comments on commit 88ca8d6

Please sign in to comment.