File: run_pointnet.py

package info (click to toggle)
bmtk 1.1.1%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 204,040 kB
  • sloc: python: 37,064; javascript: 1,998; makefile: 42; sh: 33
file content (33 lines) | stat: -rw-r--r-- 1,150 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os, sys
from bmtk.simulator import pointnet
from bmtk.analyzer.spike_trains import plot_raster
import matplotlib.pyplot as plt

def run(config_file):
    configure = pointnet.Config.from_json(config_file)
    configure.build_env()

    network = pointnet.PointNetwork.from_config(configure)
    sim = pointnet.PointSimulator.from_config(configure, network)
    sim.run()

    plot_raster(config_file='simulation_config.json', group_by='pop_name')
    # assert (spike_files_equal('output/spikes.csv', 'expected/spikes.csv'))


if __name__ == '__main__':
    # Find the appropriate config.json file
    config_path = None
    if __file__ != sys.argv[-1]:
        config_path = sys.argv[-1]
        if not os.path.exists(config_path):
            raise AttributeError('configuration file {} does not exist.'.format(config_path))
    else:
        for cfg_path in ['config.json', 'config.simulation.json', 'simulation_config.json']:
            if os.path.exists(cfg_path):
                config_path = cfg_path
                break
        else:
            raise AttributeError('Could not find configuration json file.')

    run(config_path)