Skip to content

Commit 748e7c6

Browse files
Merge pull request #10 from TravisWheelerLab/dipui_file
Dipui file
2 parents 25859e7 + cdfcea4 commit 748e7c6

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

diplomat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
A tool providing multi-animal tracking capabilities on top of other Deep learning based tracking software.
33
"""
44

5-
__version__ = "0.1.2"
5+
__version__ = "0.1.3"
66
# Can be used by functions to determine if diplomat was invoked through it's CLI interface.
77
CLI_RUN = False
88

diplomat/core_ops.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ def track_with(
174174
predictor: Optional[str] = None,
175175
predictor_settings: Optional[Dict[str, Any]] = None,
176176
help_extra: Flag = False,
177+
dipui_file: Optional[PathLike] = None,
177178
**extra_args
178179
):
179180
"""
@@ -238,6 +239,7 @@ def track_with(
238239
num_outputs=num_outputs,
239240
predictor=predictor,
240241
predictor_settings=predictor_settings,
242+
dipui_file=dipui_file,
241243
**_get_casted_args(selected_frontend.analyze_frames, extra_args)
242244
)
243245

diplomat/frontends/deeplabcut/predict_videos_dlc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ def analyze_videos(
169169
save_as_csv,
170170
destination_folder,
171171
predictor_cls,
172-
predictor_settings
172+
predictor_settings,
173+
dipui_file=None
173174
)
174175
else:
175176
print("No videos found!")

diplomat/predictors/fpe/frame_pass_engine.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,11 @@ def get_settings(cls) -> ConfigSpec:
477477
SparseTrackingData.SparseModes.OFFSET_DOMINATION.name,
478478
type_casters.Literal(*[mode.name for mode in SparseTrackingData.SparseModes]),
479479
"The mode to utilize during sparsification."
480-
)
480+
),
481+
"dipui_file": (
482+
None, type_casters.Union(type_casters.Literal(None), str),
483+
"A path specifying where to save the dipui file"
484+
),
481485
}
482486

483487

diplomat/predictors/sfpe/segmented_frame_pass_engine.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import shutil
44
from enum import Enum
5+
from datetime import datetime
56
from pathlib import Path
67
from typing import List, Tuple, Optional, Any, Callable, Sequence, Iterable, BinaryIO
78
import numpy as np
@@ -463,7 +464,16 @@ def get_frame_holder(self):
463464
Returns:
464465
DiskBackedForwardBackwardData: An object that holds and manages access to the frames data.
465466
"""
467+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
466468
output_path = Path(self.video_metadata["output-file-path"]).resolve()
469+
if self.settings.dipui_file is not None:
470+
dipui_path = str(self.settings.dipui_file)
471+
if os.path.exists(dipui_path):
472+
output_path = dipui_path.replace(".dipui","") + f"_{timestamp}.dipui"
473+
output_path = Path(output_path).resolve()
474+
else:
475+
output_path = output_path.parent / f"{output_path.stem}_{timestamp}{output_path.suffix}"
476+
467477
video_path = Path(self.video_metadata["orig-video-path"]).resolve()
468478
disk_path = output_path.parent / (output_path.stem + ".dipui")
469479

@@ -1584,7 +1594,8 @@ def get_settings(cls) -> ConfigSpec:
15841594
100,
15851595
type_casters.RangedInteger(1, np.inf),
15861596
"Size of lifo cache used to temporarily store frames loaded from disk if running in disk storage_mode."
1587-
)
1597+
),
1598+
"dipui_file": (None, type_casters.Union(type_casters.Literal(None), str), "A path specifying where to save the dipui file"),
15881599
}
15891600

15901601
@classmethod

0 commit comments

Comments
 (0)