consecutive join
@@ -547,17 +547,22 @@ def _align(files, display):
save_locs(base + "_align.hdf5", locs_, info)
-def _join(files):
+def _join(files, nosum=True):
from .io import load_locs, save_locs
from os.path import splitext
from numpy import append
import numpy as np
locs, info = load_locs(files[0])
+ total_frames = info[0]['Frames']
join_info = {"Generated by": "Picasso Join", "Files": [files[0]]}
for path in files[1:]:
locs_, info_ = load_locs(path)
try:
+ n_frames = info[0]['Frames']
+ total_frames += n_frames
+ if not nosum:
+ locs_['frame'] += total_frames-n_frames
locs = append(locs, locs_)
join_info["Files"].append(path)
except TypeError:
@@ -566,6 +571,8 @@ def _join(files):
" Make sure they have the same columns.")
base, ext = splitext(files[0])
info.append(join_info)
+ if not nosum:
+ info[0]['Frames'] = total_frames
locs.sort(kind="mergesort", order="frame")
locs = locs.view(np.recarray)
save_locs(base + "_join.hdf5", locs, info)
@@ -1207,11 +1214,14 @@ def main():
# join
join_parser = subparsers.add_parser(
- "join", help="join hdf5 localization lists"
+ "join", help="join hdf5 localization lists. frame numbers of consecutive files will be added up."
)
join_parser.add_argument(
"file", nargs="+", help="the hdf5 localization files to be joined"
)
+ join_parser.add_argument(
+ "-n", "--nosum", help="do not change frame numbers", action="store_true"
+ )
# group properties
groupprops_parser = subparsers.add_parser(
@@ -1506,7 +1516,7 @@ def main():
elif args.command == "align":
_align(args.file, args.display)
elif args.command == "join":
- _join(args.file)
+ _join(args.file, args.nosum)
elif args.command == "groupprops":
_groupprops(args.files)
elif args.command == "pc":
