BlueBrain / snap

The Blue Brain Pythonic Simulation and Network Analysis Productivity layer
https://bluebrainsnap.readthedocs.io/
GNU Lesser General Public License v3.0
17 stars 10 forks source link

Simplify report access #144

Open asanin-epfl opened 3 years ago

asanin-epfl commented 3 years ago

The problem: Sonata specs force very complicated API to access reports.

When there is a report file, you want to open simply and access its data directly. Sonata specs, and hence bluepysnap, require additional steps:

  1. Point to a simulation config that was used to generate the report.
  2. The simulation config must have the "network" field that points to a Sonata circuit config that was used by the simulation config.
  3. The simulation config must have the "run" field that contains the parameters for simulation. These parameters must be the same in the report file. Otherwise it won't open.
  4. The simulation config must have the "reports" field where the report file, we want to open, is specified.

So, we have to use this:

    sim = Simulation('path/to/simulation/config')
    pop_rep = sim.reports['node-population-name']['report-name']
    t = 2 # 2nd sec of simulation
    id = [45, 67] # node ids
    print(pop_rep.get(id, t, t))

plus complicated configs of simulation and circuit:

{
  "network": "path/to/sonata/circuit/config.json",
  "output": {
    "output_dir": "/path/to/dir/where/report/located"
  },
  "run": {
    // the exact parameters of report otherwise bluepysnap will throw an error
  },
  "format": "HDF5",
  "reports": {
    "report-name": {
      "file_name": "report-filename"
    }
  }
}

sonata circuit config:

{
  // all the required keys like "network", "components" etc.
}

Instead of an easy access API like:

from bluepysnap import Report

report = Report('path/to/report')
t = 2 # 2nd sec of simulation
id = [45, 67] # node ids
print(report[t, id])

The proposition would be to create the easy access API. Currently libsonata offers such. The only thing it lacks is array indexing of report data https://github.com/BlueBrain/libsonata/issues/153.

cc @mgeplf

eleftherioszisis commented 3 years ago

Isn't the goal of snap to allow access to datasets from within the circuit context? This is the reason why snap does not allow for example to access the node and edge populations as standalone files. This is the job of libsonata's low level api.

asanin-epfl commented 3 years ago

Yes. That's why I mentioned libsonata at the end of my comment. I created this issue for information only as inquired by @mgeplf.