Skip to content

Commit

Permalink
Add CLI to convert and import inferred spikes in CSV format
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaFicarelli committed Jan 30, 2024
1 parent fa05d03 commit 5f8d410
Show file tree
Hide file tree
Showing 11 changed files with 524 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Changelog
=========

Version 0.5.0
-------------

New Features
~~~~~~~~~~~~

- Add CLI to convert and import inferred spikes in CSV format.


Version 0.4.4
-------------

Expand Down
40 changes: 40 additions & 0 deletions src/blueetl/apps/convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""Convert CLI."""

import logging
from pathlib import Path

import click

from blueetl.converters.convert_spikes import main
from blueetl.utils import setup_logging


@click.command()
@click.argument("input-file", type=click.Path(exists=True, path_type=Path))
@click.argument("output-dir", type=click.Path(exists=False, path_type=Path))
@click.option(
"--node-population",
help="Name of the node population to create.",
default="synthetic",
show_default=True,
)
@click.option("-v", "--verbose", count=True, help="-v for INFO, -vv for DEBUG")
def convert_spikes(input_file, output_dir, node_population, verbose):
"""Convert spikes in CSV format.
Read a CSV file containing the spikes, and write synthetic files to be used with BlueETL.
The input file should contain:
\b
- headers: node_ids timestamps (or: ids times)
- values: space separated
"""
loglevel = (logging.WARNING, logging.INFO, logging.DEBUG)[min(verbose, 2)]
setup_logging(loglevel=loglevel, force=True)
main(
input_file=input_file,
output_dir=output_dir,
node_population=node_population,
)
click.secho("Conversion successful.", fg="green")
2 changes: 2 additions & 0 deletions src/blueetl/apps/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import click

from blueetl import __version__
from blueetl.apps.convert import convert_spikes
from blueetl.apps.migrate import migrate_config
from blueetl.apps.run import run
from blueetl.apps.validate import validate_config
Expand All @@ -25,3 +26,4 @@ def cli():
cli.add_command(run)
cli.add_command(migrate_config)
cli.add_command(validate_config)
cli.add_command(convert_spikes)
1 change: 1 addition & 0 deletions src/blueetl/converters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Conversion utilities."""
Loading

0 comments on commit 5f8d410

Please sign in to comment.