Skip to content

Commit 76e6ad1

Browse files
authored
Merge pull request #523 from yfukai/geff_update
Adding data conversion function for GEFF format
2 parents 03a8684 + 2f266a1 commit 76e6ad1

6 files changed

Lines changed: 689 additions & 9 deletions

File tree

docs/examples/file_export.ipynb

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 8,
6+
"id": "b12fc821",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"from laptrack import LapTrack\n",
11+
"from laptrack import data_conversion\n",
12+
"from laptrack import datasets\n",
13+
"import geff"
14+
]
15+
},
16+
{
17+
"cell_type": "code",
18+
"execution_count": 2,
19+
"id": "5fec4807",
20+
"metadata": {},
21+
"outputs": [],
22+
"source": [
23+
"lt = LapTrack(\n",
24+
" metric=\"sqeuclidean\",\n",
25+
" cutoff=15**2,\n",
26+
" splitting_metric=\"sqeuclidean\",\n",
27+
" merging_metric=\"sqeuclidean\",\n",
28+
" splitting_cutoff=15**2,\n",
29+
" merging_cutoff=15**2,\n",
30+
")"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": 3,
36+
"id": "49ae32cc",
37+
"metadata": {},
38+
"outputs": [
39+
{
40+
"name": "stderr",
41+
"output_type": "stream",
42+
"text": [
43+
"/Users/fukai/projects/laptrack/src/laptrack/_tracking.py:808: FutureWarning: The parameter only_coordinate_cols will be False by default in the major release.\n",
44+
" warnings.warn(\n"
45+
]
46+
}
47+
],
48+
"source": [
49+
"spots_df = datasets.simple_tracks()\n",
50+
"track_df, split_df, merge_df = lt.predict_dataframe(\n",
51+
" spots_df, coordinate_cols=[\"position_x\", \"position_y\"], frame_col=\"frame\"\n",
52+
")"
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": 4,
58+
"id": "8fe2bf20",
59+
"metadata": {},
60+
"outputs": [],
61+
"source": [
62+
"tree_geff = data_conversion.convert_dataframes_to_geff_networkx(\n",
63+
" track_df,\n",
64+
" split_df,\n",
65+
" merge_df,\n",
66+
" coordinate_cols=[\"position_x\", \"position_y\"],\n",
67+
" frame_col=\"frame\",\n",
68+
")"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": 6,
74+
"id": "56da38ad",
75+
"metadata": {},
76+
"outputs": [
77+
{
78+
"data": {
79+
"text/plain": [
80+
"{'frame': 0,\n",
81+
" 'position_x': np.float64(178.4125746427294),\n",
82+
" 'position_y': np.float64(185.18866073671265)}"
83+
]
84+
},
85+
"execution_count": 6,
86+
"metadata": {},
87+
"output_type": "execute_result"
88+
}
89+
],
90+
"source": [
91+
"tree_geff.nodes[0]"
92+
]
93+
},
94+
{
95+
"cell_type": "code",
96+
"execution_count": 11,
97+
"id": "3329e792",
98+
"metadata": {},
99+
"outputs": [],
100+
"source": [
101+
"geff.write_nx(tree_geff, \"/tmp/tree.geff\")"
102+
]
103+
},
104+
{
105+
"cell_type": "code",
106+
"execution_count": null,
107+
"id": "9274242d",
108+
"metadata": {},
109+
"outputs": [],
110+
"source": []
111+
}
112+
],
113+
"metadata": {
114+
"kernelspec": {
115+
"display_name": "laptrack-py3.13",
116+
"language": "python",
117+
"name": "python3"
118+
},
119+
"language_info": {
120+
"codemirror_mode": {
121+
"name": "ipython",
122+
"version": 3
123+
},
124+
"file_extension": ".py",
125+
"mimetype": "text/x-python",
126+
"name": "python",
127+
"nbconvert_exporter": "python",
128+
"pygments_lexer": "ipython3",
129+
"version": "3.13.2"
130+
}
131+
},
132+
"nbformat": 4,
133+
"nbformat_minor": 5
134+
}

noxfile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def safety(session: Session) -> None:
8080
def mypy(session: Session) -> None:
8181
"""Type-check using mypy."""
8282
args = session.posargs or ["src", "tests", "docs/conf.py"]
83-
session.install(".")
83+
session.install(".[all]")
8484
session.install("mypy", "pytest")
8585
session.run("mypy", *args)
8686
if not session.posargs:
@@ -90,7 +90,7 @@ def mypy(session: Session) -> None:
9090
@session(python=python_versions)
9191
def tests(session: Session) -> None:
9292
"""Run the test suite."""
93-
session.install(".")
93+
session.install(".[all]")
9494
session.install("coverage[toml]", "pytest", "pytest-datadir", "pygments")
9595
try:
9696
session.install("ray")
@@ -120,7 +120,7 @@ def coverage(session: Session) -> None:
120120
@session(python=python_versions)
121121
def typeguard(session: Session) -> None:
122122
"""Runtime type checking using Typeguard."""
123-
session.install(".")
123+
session.install(".[all]")
124124
session.install("pytest", "pytest-datadir", "typeguard", "pygments", "ray")
125125
session.run("pytest", f"--typeguard-packages={package}", *session.posargs)
126126

@@ -129,7 +129,7 @@ def typeguard(session: Session) -> None:
129129
def docs_build(session: Session) -> None:
130130
"""Build the documentation."""
131131
args = session.posargs or ["docs", "docs/_build"]
132-
session.install(".", *doc_build_packages)
132+
session.install(".[all]", *doc_build_packages)
133133

134134
build_dir = Path("docs", "_build")
135135
if build_dir.exists():
@@ -142,7 +142,7 @@ def docs_build(session: Session) -> None:
142142
def docs(session: Session) -> None:
143143
"""Build and serve the documentation with live reloading on file changes."""
144144
args = session.posargs or ["--open-browser", "docs", "docs/_build"]
145-
session.install(".", *doc_build_packages)
145+
session.install(".[all]", *doc_build_packages)
146146

147147
build_dir = Path("docs", "_build")
148148
if build_dir.exists():

0 commit comments

Comments
 (0)