Class: Loader_GraphML

Inherits:
Loader
  • Object
show all
Defined in:
lib/Yinspire/Loaders/Loader_GraphML.rb

Constant Summary collapse

TYPE_MAP =
{
  'NEURONTYPE_KBLIF' => 'Neuron_SRM01',
  'NEURONTYPE_EKERNEL' => 'Neuron_SRM02',
  'SYNAPSE_DEFAULT' => 'Synapse',
  'SYNAPSE_HEBB' => 'Synapse_Hebb'
}
PARAM_MAP =
{
  'absRefPeriod' => ['abs_refr_duration', 'real'],
  'neuronLFT' => ['last_fire_time', 'real'],
  'neuronLSET' => ['last_spike_time', 'real'],
  'neuron_tauM' => ['tau_m', 'real'],
  'neuron_tauRef' => ['tau_ref', 'real'],
  'neuron_constThreshold' => ['const_threshold', 'real'],
  'neuron_refWeight' => ['ref_weight', 'real'],
  'neuron_arpTime' => ['abs_refr_duration', 'real'],
  'synapse_weight' => ['weight', 'real'],
  'synapse_delay' => ['delay', 'real'],
  'neuronPSP' => ['mem_pot', 'real'],
  'neuronReset' => ['reset', 'real'],
  'neuron_tauM' => ['tau_m', 'real'],
  'neuron_tauRecov' => ['tau_ref', 'real'],
  'neuron_uReset' => ['u_reset', 'real'],
  'neuron_threshold' => ['const_threshold', 'real']
}

Instance Method Summary collapse

Methods inherited from Loader

#initialize

Constructor Details

This class inherits a constructor from Loader

Instance Method Details

#load(file) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/Yinspire/Loaders/Loader_GraphML.rb', line 38

def load(file)
  File.open(file) do |f|
    gml = GraphML.parse(f)
    g = gml.graphs.values.first
    default_neuron_type = g.data['graph_default_neuron_type']
    default_synapse_type = g.data['graph_default_synapse_type']

    #
    # Create Neurons
    #
    g.nodes.each_value {|node|
      create(node.id, node.data, default_neuron_type, 'neuron_type')
    }

    # 
    # Create Synapses
    #
    g.edges.each_value {|edge|
      create(edge.id, edge.data, default_synapse_type, 'synapse_type')
    }

    #
    # Create Connections between Neurons and Synapses.
    #
    g.edges.each_value {|edge|
      a = @entities[edge.source.id] || raise
      b = @entities[edge.id] || raise
      c = @entities[edge.target.id] || raise
      a.connect(b)
      b.connect(c)
    }
  end
end