This commit is contained in:
wendtalexander
2025-10-20 07:55:41 +02:00
11 changed files with 1923 additions and 572 deletions

View File

@@ -5,14 +5,28 @@ from rich.logging import RichHandler
DEFAULT_LOG_LEVEL = "DEBUG"
def setup_logging(logger: logging.Logger, level=DEFAULT_LOG_LEVEL):
def setup_logging(logger: logging.Logger, verbosity: int):
level = logging.WARNING # Default level
if verbosity == 0:
level = logging.ERROR
elif verbosity == 1:
level = logging.INFO
elif verbosity >= 2:
level = logging.DEBUG
print("Debugging enabled.")
else:
print("Invalid verbosity level. Defaulting to WARNING.")
if logger.hasHandlers():
logger.handlers.clear()
stream_handler = RichHandler(rich_tracebacks=True, show_path=False)
stream_handler = RichHandler(rich_tracebacks=True, show_path=level == logging.DEBUG)
stream_handler.setLevel(level)
fmt_shell = "%(filename)s:%(lineno)d - %(message)s"
shell_formatter = logging.Formatter(fmt_shell)
stream_handler.setFormatter(shell_formatter)
logger.addHandler(stream_handler)
logger.setLevel(level)
logger.propagate = False
# logging.basicConfig(level=level, handlers=[stream_handler], force=True)
logging.getLogger(__name__).info(f"Logging configured with level {level}.")

View File

@@ -1,5 +1,6 @@
import logging
from pathlib import Path
from typing import Annotated
import nixio
import typer
@@ -12,7 +13,6 @@ from oephys2nix.tonix import RawToNix
app = typer.Typer()
log = logging.getLogger(__name__)
setup_logging(log, level="DEBUG")
console = Console()
@@ -30,8 +30,11 @@ def main(
no_ttl: bool = typer.Option(False, help="For recordings that did not have a ttl pulse"),
overwrite: bool = typer.Option(default=True, help="Overwrites nix file"),
debug: bool = typer.Option(default=True, help="Shows more information and plots the results"),
verbose: Annotated[int, typer.Option("--verbose", "-v", count=True)] = 0,
) -> None:
"""Combines open ephys data with relacs data from data_path to a new nix file."""
setup_logging(logging.getLogger("oephys2nix"), verbosity=verbose)
log.info(f"Selected data_path is {data_path}")
open_ephys_data_paths = list(Path(data_path).rglob("*open-ephys"))
relacs_data_paths = list(Path(data_path).rglob("*relacs/*.nix"))
@@ -88,10 +91,10 @@ def main(
stim = StimulusToNix(open_ephys, str(relacs), str(nix_path))
stim.create_repros_automatically()
stim.print_table()
stim.checks()
# stim.checks()
if debug:
stim.plot_stimulus()
# if debug:
# stim.plot_stimulus()
if __name__ == "__main__":

View File

@@ -15,11 +15,9 @@ from rich.table import Table
from rlxnix.plugins.efish.utils import extract_am
from scipy import signal
from oephys2nix.logging import setup_logging
from oephys2nix.metadata import create_dict_from_section, create_metadata_from_dict
log = logging.getLogger(__name__)
setup_logging(log, level="DEBUG")
console = Console()
@@ -452,8 +450,6 @@ class StimulusToNix:
for repro_r, repro_n in zip(self.dataset.repro_runs(), nix_data_set.repro_runs()):
if repro_n.name.split("_")[0] not in important_repros:
continue
embed()
exit()
if "FileStimulus" in repro_n.name:
repro_n.stimulus_folder = "/home/alexander/stimuli/whitenoise/"

View File

@@ -11,7 +11,6 @@ from oephys2nix.logging import setup_logging
from oephys2nix.metadata import create_dict_from_section, create_metadata_from_dict
log = logging.getLogger(__name__)
setup_logging(log, level="DEBUG")
class RawToNix: