[main] renaming main to convert, adding plot and timeline

This commit is contained in:
wendtalexander 2025-10-21 11:55:52 +02:00
parent 6dd148656b
commit af98fdc2cb

View File

@ -18,7 +18,7 @@ console = Console()
@app.command()
def main(
def convert(
data_path: Path = typer.Argument(
...,
help="The source directory containing the Open Ephys data.",
@ -92,32 +92,68 @@ def main(
stim = StimulusToNix(open_ephys, str(relacs), str(nix_path))
stim.create_repros_automatically()
stim.print_table()
# stim.checks()
# if debug:
# stim.plot_stimulus()
@app.command()
def timeline(
data_path: Path = typer.Argument(
...,
help="The source directory containing the Open Ephys data.",
help="The source directory containing a dataset.",
exists=True,
file_okay=False,
dir_okay=True,
readable=True,
resolve_path=True,
),
):
) -> None:
"""Plot the timeline for a given dataset."""
dataset = list(Path(data_path).rglob("*.nix"))
if not dataset:
log.error("Did not find any dataset")
raise typer.Exit()
if len(dataset) > 1:
log.info(f"Found multiple datasets {len(dataset)} taking the first one")
dataset = rlx.Dataset(str(dataset[0]))
dataset.plot_timeline()
dataset.close()
@app.command()
def plot(
data_path: Path = typer.Argument(
...,
help="The source directory containing the open-ephys and relacs data.",
exists=True,
file_okay=False,
dir_okay=True,
readable=True,
resolve_path=True,
),
) -> None:
"""Plot the stimulus, TTL and the relacs stimulus.
You can run this if you converted already the nix-file.
"""
relacs_data_paths = list(Path(data_path).rglob("*relacs/*.nix"))
if not relacs_data_paths:
log.error("Did not find any relacs data")
raise typer.Exit()
dataset = rlx.Dataset(str(relacs_data_paths[0]))
dataset.plot_timeline()
dataset.close()
open_ephys_data_paths = list(Path(data_path).rglob("*open-ephys"))
if not open_ephys_data_paths:
log.error("Did not find any open-ephys data")
raise typer.Exit()
nix_file_name = relacs_data_paths[0].parent.name.split("_")[0] + "-recording.nix"
nix_path = relacs_data_paths[0].parent.parent / nix_file_name
if not nix_path.is_file:
log.error("Did not find any converted nix file")
raise typer.Exit()
stim = StimulusToNix(open_ephys_data_paths[0], str(relacs_data_paths[0]), str(nix_path))
stim.plot_stimulus()
stim.close()
if __name__ == "__main__":