             self.showDetails(node, this)
 
   drawLinks: ->
-    links = @tree.links(@neurons)
+    links = @tree.links(@shownNeurons)
     diagonal = d3.svg.diagonal().projection((d) ->
       [ d.x, d.y ]
     )

  drawNeurons: ->
    self = this
    neuron = @svg.selectAll("g.node")
                  .data(@neurons)
                  .enter()
                  .append("g")
                  .attr("class", "node")

      for child in neuron.children
        @setChildren(child)

  hideChildren: (node) ->
    node.hidden = true
    return unless node.children
    node._children = node.children
    node.children = null
    for child in node._children
      @hideChildren(child)
    null

  showChildren: (node) ->
    node.hidden = false
    return unless node._children
    node.children = node._children
    node._children = null
    for child in node.children
      @showChildren(child)
    null

  filterShownNeurons: ->
    @shownNeurons = @neurons.filter (neuron) ->
      !neuron.hidden

  toggleNode: (node) ->
    if node.children
      @hideChildren(node)
      node.hidden = false
    else
      @showChildren(node)
    @filterShownNeurons()

    d3.select(@selector).html("")
    @createD3Elements()
    @drawSVG()
    @drawLinks()
    @drawNeurons()
    @drawWithoutParent()

  showDetails: (node, text) ->
    $popover = $(".popover")
    # format:
    $popover.find(".popover-title").html(node.title)
