|
| 1 | +import operator |
| 2 | +import sys |
| 3 | +import warnings |
| 4 | +from pathlib import Path |
| 5 | + |
| 6 | +import numpy as np |
| 7 | +from ultrack.core.database import NodeDB |
| 8 | + |
| 9 | +from trackedit.run import run_trackedit |
| 10 | + |
| 11 | +# Databases saved with numpy>2 need np._core.numeric, which is not available in numpy<2, hence the following hack |
| 12 | +sys.modules["numpy._core.numeric"] = np.core.numeric |
| 13 | + |
| 14 | +warnings.filterwarnings("ignore", category=FutureWarning, message=".*qt_viewer.*") |
| 15 | + |
| 16 | +# **********INPUTS********* |
| 17 | +# path to the working directory that contains the database file AND metadata.toml: |
| 18 | +working_directory = Path("/home/teun.huijben/Documents/data/Ziwen/2025_07_24_A549/") |
| 19 | +# name of the database file to start from, or "latest" to start from the latest version, defaults to "data.db" |
| 20 | +db_filename_start = "latest" |
| 21 | +# maximum number of frames display, defaults to None (use all frames) |
| 22 | +tmax = 66 |
| 23 | +# (Z),Y,X, defaults to (1, 1, 1) |
| 24 | +scale = (0.1494, 0.1494) |
| 25 | +# overwrite existing database/changelog, defaults to False (not used when db_filename_start is "latest") |
| 26 | +allow_overwrite = False |
| 27 | + |
| 28 | +# OPTIONAL: imaging data |
| 29 | +imaging_zarr_file = ( |
| 30 | + "/hpc/projects/intracellular_dashboard/organelle_dynamics/rerun/" |
| 31 | + "2025_07_24_A549_SEC61_TOMM20_G3BP1_ZIKV/2-assemble/" |
| 32 | + "2025_07_24_A549_SEC61_TOMM20_G3BP1_ZIKV.zarr/A/1/000000/" |
| 33 | +) |
| 34 | +imaging_channel = "0" |
| 35 | +image_z_slice = ( |
| 36 | + 20 # (only look at specific z-slice of 3D stack, because tracking data was 2D) |
| 37 | +) |
| 38 | +image_translate = ( |
| 39 | + 0, |
| 40 | + 442 * 0.15, # (taken from 2-assemble/concatenate_cropped.yml) |
| 41 | + 161 * 0.15, # (taken from 2-assemble/concatenate_cropped.yml) |
| 42 | +) # (t,y,x) because we use image_z_slice=20, so the z-axis is collapsed |
| 43 | + |
| 44 | +# imaging_zarr_file = None |
| 45 | +# imaging_channel = None |
| 46 | +# image_translate = None |
| 47 | + |
| 48 | +# OPTIONAL: annotation mapping (default is neuromast cell types) |
| 49 | +annotation_mapping = { |
| 50 | + 1: {"name": "normal", "color": [0.0, 1.0, 0.0, 1.0]}, # green |
| 51 | + 2: {"name": "infected", "color": [1.0, 0.0, 0.0, 1.0]}, # red |
| 52 | + 3: {"name": "other", "color": [0.5, 0.5, 0.5, 1.0]}, # grey |
| 53 | +} |
| 54 | +default_start_annotation = 1 # not-infected |
| 55 | +# annotation_mapping = None |
| 56 | +# default_start_annotation = None |
| 57 | + |
| 58 | + |
| 59 | +# filter the database segments on pixel coordinates |
| 60 | +# (if only displaying a crop of the full dataset) |
| 61 | +coordinate_filters = [ |
| 62 | + (NodeDB.x, operator.lt, 1280), # lt = less than (<), coorddinates in db/pixel units |
| 63 | + (NodeDB.x, operator.gt, 161), # gt = greater than (>) |
| 64 | + (NodeDB.y, operator.lt, 1186), |
| 65 | + (NodeDB.y, operator.gt, 442), |
| 66 | +] |
| 67 | +# ************************* |
| 68 | + |
| 69 | +if __name__ == "__main__": |
| 70 | + run_trackedit( |
| 71 | + working_directory=working_directory, |
| 72 | + db_filename=db_filename_start, |
| 73 | + tmax=tmax, |
| 74 | + scale=scale, |
| 75 | + allow_overwrite=allow_overwrite, |
| 76 | + imaging_zarr_file=imaging_zarr_file, |
| 77 | + imaging_channel=imaging_channel, |
| 78 | + image_z_slice=image_z_slice, |
| 79 | + image_translate=image_translate, |
| 80 | + annotation_mapping=annotation_mapping, |
| 81 | + coordinate_filters=coordinate_filters, |
| 82 | + default_start_annotation=default_start_annotation, |
| 83 | + ) |
0 commit comments