[main] renaming main to convert, adding plot and timeline
This commit is contained in:
parent
6dd148656b
commit
af98fdc2cb
@ -18,7 +18,7 @@ console = Console()
|
|||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def main(
|
def convert(
|
||||||
data_path: Path = typer.Argument(
|
data_path: Path = typer.Argument(
|
||||||
...,
|
...,
|
||||||
help="The source directory containing the Open Ephys data.",
|
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 = StimulusToNix(open_ephys, str(relacs), str(nix_path))
|
||||||
stim.create_repros_automatically()
|
stim.create_repros_automatically()
|
||||||
stim.print_table()
|
stim.print_table()
|
||||||
# stim.checks()
|
|
||||||
|
|
||||||
# if debug:
|
|
||||||
# stim.plot_stimulus()
|
|
||||||
|
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
def timeline(
|
def timeline(
|
||||||
data_path: Path = typer.Argument(
|
data_path: Path = typer.Argument(
|
||||||
...,
|
...,
|
||||||
help="The source directory containing the Open Ephys data.",
|
help="The source directory containing a dataset.",
|
||||||
exists=True,
|
exists=True,
|
||||||
file_okay=False,
|
file_okay=False,
|
||||||
dir_okay=True,
|
dir_okay=True,
|
||||||
readable=True,
|
readable=True,
|
||||||
resolve_path=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"))
|
relacs_data_paths = list(Path(data_path).rglob("*relacs/*.nix"))
|
||||||
if not relacs_data_paths:
|
if not relacs_data_paths:
|
||||||
log.error("Did not find any relacs data")
|
log.error("Did not find any relacs data")
|
||||||
raise typer.Exit()
|
raise typer.Exit()
|
||||||
|
|
||||||
dataset = rlx.Dataset(str(relacs_data_paths[0]))
|
open_ephys_data_paths = list(Path(data_path).rglob("*open-ephys"))
|
||||||
dataset.plot_timeline()
|
if not open_ephys_data_paths:
|
||||||
dataset.close()
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user