Merge branch 'main' of https://whale.am28.uni-tuebingen.de/git/awendt/oephys2nix
This commit is contained in:
commit
77eab8d7db
1
doc/.gitignore
vendored
1
doc/.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
api/
|
||||
objects.json
|
||||
_site/
|
||||
_freeze/
|
||||
|
@ -2,8 +2,6 @@
|
||||
project:
|
||||
type: website
|
||||
output-dir: _site
|
||||
preview:
|
||||
port: 7000
|
||||
|
||||
format:
|
||||
html:
|
||||
@ -39,6 +37,7 @@ website:
|
||||
- section: "Tutorials"
|
||||
contents:
|
||||
- "usage.qmd"
|
||||
- "calibration.qmd"
|
||||
- section: "API"
|
||||
href: "api/index.qmd"
|
||||
contents:
|
||||
@ -60,4 +59,3 @@ quartodoc:
|
||||
|
||||
execute:
|
||||
freeze: auto
|
||||
|
||||
|
122
doc/calibration.qmd
Normal file
122
doc/calibration.qmd
Normal file
@ -0,0 +1,122 @@
|
||||
---
|
||||
title: Calibration
|
||||
---
|
||||
|
||||
### Calibration of the Amplitude
|
||||
```{python}
|
||||
import rlxnix as rlx
|
||||
import plotly.graph_objects as go
|
||||
import numpy as np
|
||||
from plotly.subplots import make_subplots
|
||||
|
||||
|
||||
dataset = rlx.Dataset("../oephys2nix/test/Test1/2025-10-08-aa-invivo-2-recording.nix")
|
||||
relacs = rlx.Dataset("../oephys2nix/test/Test1/2025-10-08-aa-invivo-2_relacs/2025-10-08-aa-invivo-2.nix")
|
||||
repro_d = dataset.repro_runs("CalibEfield_1")[0]
|
||||
repro_r = relacs.repro_runs("CalibEfield_1")[0]
|
||||
|
||||
fig = make_subplots(
|
||||
rows=4,
|
||||
cols=1,
|
||||
shared_xaxes=True,
|
||||
subplot_titles=(
|
||||
"Stimulus Comparison",
|
||||
"Local EOD Comparison",
|
||||
"Global EOD Comparison",
|
||||
"Sinus Comparison",
|
||||
),)
|
||||
|
||||
|
||||
sinus, t = repro_d.trace_data("sinus")
|
||||
sinus_r, t_r = repro_r.trace_data("V-1")
|
||||
|
||||
|
||||
stimulus_oe, t = repro_d.trace_data("stimulus")
|
||||
stimulus_re, t_r = repro_r.trace_data("GlobalEFieldStimulus")
|
||||
|
||||
local_eod_oe, t = repro_d.trace_data("local-eod")
|
||||
local_eod_re, t_r = repro_r.trace_data("LocalEOD-1")
|
||||
|
||||
global_eod_oe, t = repro_d.trace_data("global-eod")
|
||||
global_eod_re, t_r = repro_r.trace_data("EOD")
|
||||
|
||||
ttl, t = repro_d.trace_data("ttl-line")
|
||||
# 2. Add traces to the FIRST subplot (row=1, col=1)
|
||||
# Note: Plotly rows and columns are 1-indexed
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t_r, y=stimulus_re, name="stimulus (relacs)", line_color="blue"),
|
||||
row=1,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(
|
||||
x=t,
|
||||
y=stimulus_oe - np.mean(stimulus_oe), # The same data transformation
|
||||
name="stimulus (open-ephys)",
|
||||
line_color="red",
|
||||
),
|
||||
row=1,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t, y=ttl, name="ttl-line", line_color="black"),
|
||||
row=1,
|
||||
col=1,
|
||||
)
|
||||
|
||||
|
||||
# 3. Add traces to the SECOND subplot (row=2, col=1)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t_r, y=local_eod_re, name="local EOD (relacs)", line_color="blue"),
|
||||
row=2,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t, y=local_eod_oe, name="local EOD (open-ephys)", line_color="red"),
|
||||
row=2,
|
||||
col=1,
|
||||
)
|
||||
|
||||
|
||||
# 4. Add traces to the THIRD subplot (row=3, col=1)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t_r, y=global_eod_re, name="global EOD (relacs)", line_color="blue"),
|
||||
row=3,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(
|
||||
x=t, y=global_eod_oe, name="global EOD (open-ephys)", line_color="red"
|
||||
),
|
||||
row=3,
|
||||
col=1,
|
||||
)
|
||||
|
||||
|
||||
# 5. Add traces to the FOURTH subplot (row=4, col=1)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t_r, y=sinus_r, name="sinus (relacs)", line_color="blue"),
|
||||
row=4,
|
||||
col=1,
|
||||
)
|
||||
fig.add_trace(
|
||||
go.Scatter(x=t, y=sinus, name="sinus (open-ephys)", line_color="red"),
|
||||
row=4,
|
||||
col=1,
|
||||
)
|
||||
|
||||
|
||||
# 6. Update the layout for a cleaner look
|
||||
fig.update_layout(
|
||||
title_text="Relacs vs. Open Ephys Data Alignment",
|
||||
height=800, # Set the figure height in pixels
|
||||
# Control the legend
|
||||
legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1),
|
||||
)
|
||||
# Add a label to the shared x-axis (targeting the last subplot)
|
||||
fig.update_xaxes(title_text="Time (s)", row=4, col=1)
|
||||
|
||||
|
||||
# 7. Show the figure
|
||||
fig.show()
|
||||
```
|
@ -52,9 +52,12 @@ different sampling rates. If you start a stimulus a TTL pulse is send from
|
||||
relacs to the open-ephys recording controler.
|
||||
|
||||
:::{.callout-caution}
|
||||
The Folder strucutre should be like two folders with one from relacs and one from open-ephys.
|
||||
The Folder strucutre should be like two folders with one from relacs and one
|
||||
from open-ephys.
|
||||
```bash
|
||||
relax_folder/
|
||||
open-ephys_folder/
|
||||
```
|
||||
the name `relacs` and `open-ephys` is essential for finding the different data
|
||||
streams so make sure they are present in the folder names.
|
||||
:::
|
||||
|
@ -1,3 +1,11 @@
|
||||
---
|
||||
title: How to use it
|
||||
---
|
||||
|
||||
If you have a folder or multiple folders with each containing two recordings one from `relacs` and one from `open-ephys` you can simply run the CLI like this:
|
||||
|
||||
```{python}
|
||||
# leave out the ! at the beginning if you running this in your shell
|
||||
!oephys2nix ../oephys2nix/test/Test1/
|
||||
```
|
||||
which provides you with information about the transition of the stimuli into the new 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}.")
|
||||
|
@ -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__":
|
||||
|
@ -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/"
|
||||
|
@ -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:
|
||||
|
@ -18,6 +18,9 @@ oephys2nix = "oephys2nix.main:app"
|
||||
|
||||
[project.optional-dependencies]
|
||||
docs = [
|
||||
"jupyter>=1.1.1",
|
||||
"jupyterlab>=4.4.9",
|
||||
"plotly>=6.3.1",
|
||||
"quartodoc>=0.11.1",
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user