Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions scripts/demo_neuromast.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,30 @@

# **********INPUTS*********
# path to the working directory that contains the database file AND metadata.toml:

working_directory = Path(
"/home/teun.huijben/Documents/data/Akila/20241003/neuromast4_t851/adjusted/"
)

# working_directory = Path(
# "/mnt/md0/Teun/data/Chromatrace/2024_08_14/adjusted/"
# )

# name of the database file to start from, or "latest" to start from the latest version, defaults to "data.db"
db_filename_start = "latest"
db_filename_start = "data_updated.db"
# maximum number of frames display, defaults to None (use all frames)
tmax = 600
# (Z),Y,X, defaults to (1, 1, 1)
scale = (2.31, 1, 1)
scale = (4, 1, 1)
# overwrite existing database/changelog, defaults to False (not used when db_filename_start is "latest")
allow_overwrite = False
# NEW:
work_in_existing_db = True
flag_show_hierarchy = True
# focus_id = 7000031
focus_id = 3000020
# focus_id = None
margin = 150

# OPTIONAL: imaging data
# imaging_zarr_file = (
Expand All @@ -44,6 +57,10 @@
tmax=tmax,
scale=scale,
allow_overwrite=allow_overwrite,
work_in_existing_db=work_in_existing_db,
imaging_zarr_file=imaging_zarr_file,
imaging_channel=imaging_channel,
flag_show_hierarchy=flag_show_hierarchy,
focus_id=focus_id,
margin=margin,
)
85 changes: 85 additions & 0 deletions scripts/test_large_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from pathlib import Path

import napari
from ultrack.config import MainConfig

from trackedit.widgets.HierarchyWidget import HierarchyVizWidget

# def check_database(db_path: Path):
# """Check if database exists and print its structure"""
# if not db_path.exists():
# print(f"Database file does not exist at: {db_path}")
# return False

# print(f"Database file found at: {db_path}")
# print(f"File size: {db_path.stat().st_size / (1024*1024):.2f} MB")

# # Try to connect and list tables
# engine = sqla.create_engine(f"sqlite:///{db_path}")
# inspector = inspect(engine)
# tables = inspector.get_table_names()
# print(f"Tables in database: {tables}")

# # Print column information for each table
# for table_name in tables:
# columns = inspector.get_columns(table_name)
# print(f"\nColumns in {table_name} table:")
# for column in columns:
# print(f" - {column['name']}: {column['type']}")

# # Get a sample row from each table
# with engine.connect() as conn:
# for table_name in tables:
# result = conn.execute(
# text(f"SELECT * FROM {table_name} LIMIT 1")
# ).fetchone()
# if result:
# print(f"\nSample row from {table_name}:")
# print(result)

# return True


def initialize_config():
working_directory = Path("/mnt/md0/Teun/data/Chromatrace/2024_08_14/")
db_filename = "data.db"
# db_path = working_directory / db_filename

# if not check_database(db_path):
# raise FileNotFoundError(f"Database not found or invalid at {db_path}")

# import db filename properly into an Ultrack config
config_adjusted = MainConfig()
config_adjusted.data_config.working_dir = working_directory
config_adjusted.data_config.database_file_name = db_filename
return config_adjusted


# def main():
# config = initialize_config()
# ultrack_array = HierarchyArray(config)

# labels_layer = HierarchyLabels(
# data=ultrack_array, scale=(4,1,1), name="hierarchy"
# )
# viewer = napari.Viewer()
# viewer.add_layer(labels_layer)
# labels_layer.refresh()
# labels_layer.mode = "pan_zoom"
# napari.run()


def main2():
config = initialize_config()
viewer = napari.Viewer()
hier_widget = HierarchyVizWidget(
viewer=viewer,
scale=(4, 1, 1),
config=config,
)
viewer.window.add_dock_widget(hier_widget, area="bottom")
napari.run()


if __name__ == "__main__":
main2()
Loading
Loading