lbm_suite2p_python 3.2.0__py3-none-any.whl → 3.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lbm_suite2p_python/cli.py +11 -1
- lbm_suite2p_python/run_lsp.py +115 -36
- lbm_suite2p_python/utils.py +85 -0
- {lbm_suite2p_python-3.2.0.dist-info → lbm_suite2p_python-3.2.1.dist-info}/METADATA +1 -1
- {lbm_suite2p_python-3.2.0.dist-info → lbm_suite2p_python-3.2.1.dist-info}/RECORD +9 -9
- {lbm_suite2p_python-3.2.0.dist-info → lbm_suite2p_python-3.2.1.dist-info}/WHEEL +0 -0
- {lbm_suite2p_python-3.2.0.dist-info → lbm_suite2p_python-3.2.1.dist-info}/entry_points.txt +0 -0
- {lbm_suite2p_python-3.2.0.dist-info → lbm_suite2p_python-3.2.1.dist-info}/licenses/LICENSE.md +0 -0
- {lbm_suite2p_python-3.2.0.dist-info → lbm_suite2p_python-3.2.1.dist-info}/top_level.txt +0 -0
lbm_suite2p_python/cli.py
CHANGED
|
@@ -134,13 +134,21 @@ Examples:
|
|
|
134
134
|
"--planes", nargs="*", type=int, dest="planes",
|
|
135
135
|
help="z-planes to process (1-indexed, e.g., --planes 1 2 3)"
|
|
136
136
|
)
|
|
137
|
+
pipeline.add_argument(
|
|
138
|
+
"--timepoints", nargs="*", type=int, dest="timepoints",
|
|
139
|
+
help="timepoints to process (1-indexed, e.g., --timepoints 1 50 100)"
|
|
140
|
+
)
|
|
137
141
|
pipeline.add_argument(
|
|
138
142
|
"--roi-mode", "--roi", type=int, dest="roi_mode",
|
|
139
143
|
help="ROI mode: None=stitch, 0=split all, N=specific ROI"
|
|
140
144
|
)
|
|
141
145
|
pipeline.add_argument(
|
|
142
146
|
"--num-timepoints", "--frames", type=int, dest="num_timepoints",
|
|
143
|
-
help="number of
|
|
147
|
+
help="number of timepoints to process (first N, for quick testing)"
|
|
148
|
+
)
|
|
149
|
+
pipeline.add_argument(
|
|
150
|
+
"--num-zplanes", type=int, dest="num_zplanes",
|
|
151
|
+
help="number of z-planes to process (first N)"
|
|
144
152
|
)
|
|
145
153
|
pipeline.add_argument(
|
|
146
154
|
"--overwrite", action="store_true",
|
|
@@ -566,8 +574,10 @@ def main():
|
|
|
566
574
|
save_path=output_path,
|
|
567
575
|
ops=ops,
|
|
568
576
|
planes=args.planes,
|
|
577
|
+
timepoints=args.timepoints,
|
|
569
578
|
roi_mode=args.roi_mode,
|
|
570
579
|
num_timepoints=args.num_timepoints,
|
|
580
|
+
num_zplanes=args.num_zplanes,
|
|
571
581
|
keep_reg=args.keep_reg,
|
|
572
582
|
keep_raw=args.keep_raw,
|
|
573
583
|
force_reg=args.force_reg or args.overwrite,
|
lbm_suite2p_python/run_lsp.py
CHANGED
|
@@ -446,14 +446,15 @@ def _is_valid_torch_checkpoint(path) -> bool:
|
|
|
446
446
|
def _prewarm_cellpose_model(ops) -> None:
|
|
447
447
|
"""Download the cellpose model once, in the parent, before workers fan out.
|
|
448
448
|
|
|
449
|
-
cellpose's
|
|
450
|
-
|
|
449
|
+
cellpose's model cache downloads to a temp file then renames with no
|
|
450
|
+
cross-process lock. Multiple workers hitting an empty cache at once
|
|
451
451
|
race: one wins the rename, the rest fail (Windows WinError 32/183) or read a
|
|
452
452
|
half-written file (PytorchStreamReader miniz error). Warming here serializes
|
|
453
453
|
the download so workers only ever read a complete file. A corrupt leftover
|
|
454
454
|
from a prior failed run is removed and re-downloaded.
|
|
455
455
|
"""
|
|
456
|
-
if not (ops.get("roidetect", True)
|
|
456
|
+
if not (ops.get("roidetect", True)
|
|
457
|
+
and (ops.get("anatomical_only", 0) > 0 or ops.get("algorithm") == "cellpose")):
|
|
457
458
|
return
|
|
458
459
|
try:
|
|
459
460
|
from cellpose import models as cp_models
|
|
@@ -467,7 +468,11 @@ def _prewarm_cellpose_model(ops) -> None:
|
|
|
467
468
|
except OSError:
|
|
468
469
|
pass
|
|
469
470
|
try:
|
|
470
|
-
|
|
471
|
+
# cellpose 4.x renamed cache_CPSAM_model_path() -> cache_model_path(backbone)
|
|
472
|
+
if hasattr(cp_models, "cache_model_path"):
|
|
473
|
+
cp_models.cache_model_path("cpsam")
|
|
474
|
+
else:
|
|
475
|
+
cp_models.cache_CPSAM_model_path()
|
|
471
476
|
except Exception as exc:
|
|
472
477
|
print(
|
|
473
478
|
f"Warning: could not pre-download cellpose model ({exc}); "
|
|
@@ -780,6 +785,38 @@ def _prepare_plane_ops(*, base_ops, plane_idx, num_planes, input_arr,
|
|
|
780
785
|
return current_ops
|
|
781
786
|
|
|
782
787
|
|
|
788
|
+
def _resolve_timepoints(timepoints=None, frames=None, frame_indices=None):
|
|
789
|
+
"""Resolve the canonical 1-based ``timepoints`` selection.
|
|
790
|
+
|
|
791
|
+
``frames`` (1-based) and ``frame_indices`` (0-based) are deprecated
|
|
792
|
+
aliases and emit a DeprecationWarning. Returns a 1-based list, or
|
|
793
|
+
None for all timepoints.
|
|
794
|
+
"""
|
|
795
|
+
import warnings
|
|
796
|
+
|
|
797
|
+
if frames is not None:
|
|
798
|
+
warnings.warn(
|
|
799
|
+
"'frames' is deprecated, use 'timepoints' (1-based)",
|
|
800
|
+
DeprecationWarning,
|
|
801
|
+
stacklevel=3,
|
|
802
|
+
)
|
|
803
|
+
if timepoints is None:
|
|
804
|
+
timepoints = frames
|
|
805
|
+
if frame_indices is not None:
|
|
806
|
+
warnings.warn(
|
|
807
|
+
"'frame_indices' is deprecated, use 'timepoints' (1-based)",
|
|
808
|
+
DeprecationWarning,
|
|
809
|
+
stacklevel=3,
|
|
810
|
+
)
|
|
811
|
+
if timepoints is None:
|
|
812
|
+
timepoints = [int(i) + 1 for i in frame_indices]
|
|
813
|
+
if timepoints is None:
|
|
814
|
+
return None
|
|
815
|
+
if isinstance(timepoints, (int, np.integer)):
|
|
816
|
+
return [int(timepoints)]
|
|
817
|
+
return [int(t) for t in timepoints]
|
|
818
|
+
|
|
819
|
+
|
|
783
820
|
def pipeline(
|
|
784
821
|
input_data,
|
|
785
822
|
save_path: str | Path = None,
|
|
@@ -793,7 +830,9 @@ def pipeline(
|
|
|
793
830
|
force_reg: bool = False,
|
|
794
831
|
force_detect: bool = False,
|
|
795
832
|
replot: bool = True,
|
|
833
|
+
timepoints: list | int | None = None,
|
|
796
834
|
num_timepoints: int = None,
|
|
835
|
+
num_zplanes: int = None,
|
|
797
836
|
frame_indices: list | None = None,
|
|
798
837
|
dff_window_size: int = None,
|
|
799
838
|
dff_percentile: int = 20,
|
|
@@ -859,16 +898,21 @@ def pipeline(
|
|
|
859
898
|
Regenerate per-plane figures. Set False to skip per-plane figure
|
|
860
899
|
regeneration (e.g. the volumetric aggregate over already-plotted
|
|
861
900
|
planes); suite2p and the volumetric plots are unaffected.
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
``frame_indices`` instead.
|
|
866
|
-
frame_indices : list[int], optional
|
|
867
|
-
Explicit 0-based frame indices to process. Supports stride
|
|
868
|
-
(e.g. ``list(range(0, 1574, 2))`` for every other frame).
|
|
901
|
+
timepoints : list[int] or int, optional
|
|
902
|
+
Explicit 1-based timepoints to process. Supports stride
|
|
903
|
+
(e.g. ``list(range(1, 1575, 2))`` for every other timepoint).
|
|
869
904
|
When provided, the implicit stride is used by `OutputMetadata`
|
|
870
905
|
to reactively scale `fs` (e.g. stride of 2 → `fs / 2` in the
|
|
871
906
|
output ops.npy). Takes precedence over ``num_timepoints``.
|
|
907
|
+
num_timepoints : int, optional
|
|
908
|
+
Limit processing to first N timepoints (truncation only). For an
|
|
909
|
+
explicit set or a strided selection, use ``timepoints`` instead.
|
|
910
|
+
num_zplanes : int, optional
|
|
911
|
+
Limit processing to the first N z-planes. Shortcut for
|
|
912
|
+
``planes=[1..N]``; ignored when ``planes`` is given.
|
|
913
|
+
frame_indices : list[int], optional
|
|
914
|
+
Deprecated alias for ``timepoints`` (0-based). Emits a
|
|
915
|
+
DeprecationWarning.
|
|
872
916
|
dff_window_size : int, optional
|
|
873
917
|
Window size for rolling percentile dF/F baseline (frames).
|
|
874
918
|
If None, auto-calculated as ~10 * tau * fs.
|
|
@@ -981,7 +1025,15 @@ def pipeline(
|
|
|
981
1025
|
DeprecationWarning,
|
|
982
1026
|
stacklevel=2,
|
|
983
1027
|
)
|
|
984
|
-
num_timepoints
|
|
1028
|
+
if num_timepoints is None:
|
|
1029
|
+
num_timepoints = num_frames
|
|
1030
|
+
|
|
1031
|
+
# canonical 1-based timepoint selection (frames/frame_indices deprecated).
|
|
1032
|
+
timepoints = _resolve_timepoints(timepoints, kwargs.pop("frames", None), frame_indices)
|
|
1033
|
+
frame_indices = None
|
|
1034
|
+
# num_zplanes is a count shortcut for planes=[1..N].
|
|
1035
|
+
if num_zplanes is not None and planes is None:
|
|
1036
|
+
planes = list(range(1, int(num_zplanes) + 1))
|
|
985
1037
|
|
|
986
1038
|
# flatten (db, settings) into ops so downstream run_volume / run_plane
|
|
987
1039
|
# don't each need to forward the pair. explicit ops keys still win.
|
|
@@ -991,14 +1043,10 @@ def pipeline(
|
|
|
991
1043
|
|
|
992
1044
|
reader_kwargs = reader_kwargs or {}
|
|
993
1045
|
writer_kwargs = writer_kwargs or {}
|
|
1046
|
+
# num_timepoints truncation reaches the writer; an explicit `timepoints`
|
|
1047
|
+
# selection is forwarded as a param and rebuilt by run_plane.
|
|
994
1048
|
if num_timepoints is not None:
|
|
995
|
-
writer_kwargs["
|
|
996
|
-
|
|
997
|
-
# 1-based frame numbers.
|
|
998
|
-
if frame_indices is not None:
|
|
999
|
-
writer_kwargs["frames"] = [int(i) + 1 for i in frame_indices]
|
|
1000
|
-
# don't double-pass num_frames; len(frame_indices) is implicit
|
|
1001
|
-
writer_kwargs.pop("num_frames", None)
|
|
1049
|
+
writer_kwargs["num_timepoints"] = num_timepoints
|
|
1002
1050
|
|
|
1003
1051
|
# Always load array to check dimensions and ensure downstream functions have the array shape
|
|
1004
1052
|
# If input is already array, this is fast. If path or list of paths, it loads lazy array.
|
|
@@ -1034,7 +1082,7 @@ def pipeline(
|
|
|
1034
1082
|
force_reg=force_reg,
|
|
1035
1083
|
force_detect=force_detect,
|
|
1036
1084
|
replot=replot,
|
|
1037
|
-
|
|
1085
|
+
timepoints=timepoints,
|
|
1038
1086
|
dff_window_size=dff_window_size,
|
|
1039
1087
|
dff_percentile=dff_percentile,
|
|
1040
1088
|
dff_smooth_window=dff_smooth_window,
|
|
@@ -1074,7 +1122,7 @@ def pipeline(
|
|
|
1074
1122
|
force_reg=force_reg,
|
|
1075
1123
|
force_detect=force_detect,
|
|
1076
1124
|
replot=replot,
|
|
1077
|
-
|
|
1125
|
+
timepoints=timepoints,
|
|
1078
1126
|
dff_window_size=dff_window_size,
|
|
1079
1127
|
dff_percentile=dff_percentile,
|
|
1080
1128
|
dff_smooth_window=dff_smooth_window,
|
|
@@ -1246,6 +1294,9 @@ def run_volume(
|
|
|
1246
1294
|
force_reg: bool = False,
|
|
1247
1295
|
force_detect: bool = False,
|
|
1248
1296
|
replot: bool = True,
|
|
1297
|
+
timepoints: list | int | None = None,
|
|
1298
|
+
num_timepoints: int = None,
|
|
1299
|
+
num_zplanes: int = None,
|
|
1249
1300
|
frame_indices: list | None = None,
|
|
1250
1301
|
dff_window_size: int = None,
|
|
1251
1302
|
dff_percentile: int = 20,
|
|
@@ -1337,6 +1388,17 @@ def run_volume(
|
|
|
1337
1388
|
_resolve_gpu_env()
|
|
1338
1389
|
_apply_thread_limits(threads_per_worker)
|
|
1339
1390
|
|
|
1391
|
+
# canonical 1-based timepoints (frames/frame_indices deprecated); keep a
|
|
1392
|
+
# 0-based frame_indices for this function's reactive-metadata plumbing,
|
|
1393
|
+
# and forward `timepoints` to run_plane.
|
|
1394
|
+
timepoints = _resolve_timepoints(timepoints, kwargs.pop("frames", None), frame_indices)
|
|
1395
|
+
frame_indices = [int(t) - 1 for t in timepoints] if timepoints is not None else None
|
|
1396
|
+
if num_zplanes is not None and planes is None:
|
|
1397
|
+
planes = list(range(1, int(num_zplanes) + 1))
|
|
1398
|
+
writer_kwargs = dict(writer_kwargs or {})
|
|
1399
|
+
if num_timepoints is not None:
|
|
1400
|
+
writer_kwargs.setdefault("num_timepoints", num_timepoints)
|
|
1401
|
+
|
|
1340
1402
|
# Handle input data
|
|
1341
1403
|
input_arr = None
|
|
1342
1404
|
input_paths = []
|
|
@@ -1430,7 +1492,7 @@ def run_volume(
|
|
|
1430
1492
|
force_reg=force_reg,
|
|
1431
1493
|
force_detect=force_detect,
|
|
1432
1494
|
replot=replot,
|
|
1433
|
-
|
|
1495
|
+
timepoints=timepoints,
|
|
1434
1496
|
dff_window_size=dff_window_size,
|
|
1435
1497
|
dff_percentile=dff_percentile,
|
|
1436
1498
|
dff_smooth_window=dff_smooth_window,
|
|
@@ -2283,6 +2345,8 @@ def run_plane(
|
|
|
2283
2345
|
force_reg: bool = False,
|
|
2284
2346
|
force_detect: bool = False,
|
|
2285
2347
|
replot: bool = True,
|
|
2348
|
+
timepoints: list | int | None = None,
|
|
2349
|
+
num_timepoints: int = None,
|
|
2286
2350
|
frame_indices: list | None = None,
|
|
2287
2351
|
dff_window_size: int = None,
|
|
2288
2352
|
dff_percentile: int = 20,
|
|
@@ -2353,13 +2417,18 @@ def run_plane(
|
|
|
2353
2417
|
Example: {"n_clusters": 50, "n_PCs": 64}.
|
|
2354
2418
|
save_json : bool, default False
|
|
2355
2419
|
Save ops as JSON.
|
|
2356
|
-
|
|
2357
|
-
Explicit
|
|
2358
|
-
(e.g. ``list(range(
|
|
2420
|
+
timepoints : list[int] or int, optional
|
|
2421
|
+
Explicit 1-based timepoints. Supports stride
|
|
2422
|
+
(e.g. ``list(range(1, 1575, 2))`` for every other timepoint).
|
|
2359
2423
|
When provided, the binary on disk contains exactly these
|
|
2360
|
-
|
|
2361
|
-
based on the implicit stride. Takes precedence over
|
|
2362
|
-
``
|
|
2424
|
+
timepoints, and `OutputMetadata` reactively scales `fs` in ops.npy
|
|
2425
|
+
based on the implicit stride. Takes precedence over
|
|
2426
|
+
``num_timepoints``.
|
|
2427
|
+
num_timepoints : int, optional
|
|
2428
|
+
Limit processing to first N timepoints (truncation only).
|
|
2429
|
+
frame_indices : list[int], optional
|
|
2430
|
+
Deprecated alias for ``timepoints`` (0-based). Emits a
|
|
2431
|
+
DeprecationWarning.
|
|
2363
2432
|
plane_name : str, optional
|
|
2364
2433
|
Custom name for the plane subdirectory.
|
|
2365
2434
|
reader_kwargs : dict, optional
|
|
@@ -2379,6 +2448,14 @@ def run_plane(
|
|
|
2379
2448
|
|
|
2380
2449
|
_resolve_gpu_env()
|
|
2381
2450
|
|
|
2451
|
+
# canonical 1-based timepoints (frames/frame_indices deprecated); convert to
|
|
2452
|
+
# the 0-based frame_indices this function consumes internally.
|
|
2453
|
+
timepoints = _resolve_timepoints(timepoints, kwargs.pop("frames", None), frame_indices)
|
|
2454
|
+
frame_indices = [int(t) - 1 for t in timepoints] if timepoints is not None else None
|
|
2455
|
+
writer_kwargs = dict(writer_kwargs or {})
|
|
2456
|
+
if num_timepoints is not None:
|
|
2457
|
+
writer_kwargs.setdefault("num_timepoints", num_timepoints)
|
|
2458
|
+
|
|
2382
2459
|
progress_callback = kwargs.pop("progress_callback", None)
|
|
2383
2460
|
|
|
2384
2461
|
if "debug" in kwargs:
|
|
@@ -2637,7 +2714,8 @@ def run_plane(
|
|
|
2637
2714
|
else:
|
|
2638
2715
|
# prefer the user-specified frame limit over raw array shape
|
|
2639
2716
|
nframes_hint = (
|
|
2640
|
-
writer_kwargs.get("
|
|
2717
|
+
writer_kwargs.get("num_timepoints")
|
|
2718
|
+
or writer_kwargs.get("num_frames")
|
|
2641
2719
|
or ops.get("nframes")
|
|
2642
2720
|
)
|
|
2643
2721
|
if not nframes_hint and input_arr is not None and hasattr(input_arr, "shape"):
|
|
@@ -2666,8 +2744,8 @@ def run_plane(
|
|
|
2666
2744
|
ops_file = plane_dir / "ops.npy"
|
|
2667
2745
|
|
|
2668
2746
|
# extract expected dims from input for cache validation
|
|
2669
|
-
# honors
|
|
2670
|
-
exp_nframes = writer_kwargs.get("num_frames")
|
|
2747
|
+
# honors num_timepoints truncation if user requested fewer frames
|
|
2748
|
+
exp_nframes = writer_kwargs.get("num_timepoints") or writer_kwargs.get("num_frames")
|
|
2671
2749
|
exp_ly = exp_lx = None
|
|
2672
2750
|
if input_arr is not None and hasattr(input_arr, "shape"):
|
|
2673
2751
|
if exp_nframes is None:
|
|
@@ -2796,12 +2874,13 @@ def run_plane(
|
|
|
2796
2874
|
write_planes = [plane] if _get_num_planes(file) > 1 else None
|
|
2797
2875
|
|
|
2798
2876
|
write_kw = dict(writer_kwargs)
|
|
2799
|
-
# If the caller gave us explicit
|
|
2800
|
-
# `
|
|
2801
|
-
#
|
|
2802
|
-
#
|
|
2877
|
+
# If the caller gave us explicit timepoints, pass them as
|
|
2878
|
+
# `timepoints=` (1-based) to imwrite. This wins over any stale
|
|
2879
|
+
# truncation count in writer_kwargs — strided semantics require an
|
|
2880
|
+
# explicit index list, not a count.
|
|
2803
2881
|
if frame_indices is not None:
|
|
2804
|
-
write_kw["
|
|
2882
|
+
write_kw["timepoints"] = [int(i) + 1 for i in frame_indices]
|
|
2883
|
+
write_kw.pop("num_timepoints", None)
|
|
2805
2884
|
write_kw.pop("num_frames", None)
|
|
2806
2885
|
|
|
2807
2886
|
imwrite(
|
lbm_suite2p_python/utils.py
CHANGED
|
@@ -111,6 +111,91 @@ def get_common_path(ops_files: list | tuple):
|
|
|
111
111
|
return Path(os.path.commonpath(ops_files))
|
|
112
112
|
|
|
113
113
|
|
|
114
|
+
def estimate_peak_memory(ops, Ly, Lx, n_frames, device="cuda", workers=1):
|
|
115
|
+
"""
|
|
116
|
+
Estimate peak memory for one Suite2p plane from its parameters.
|
|
117
|
+
|
|
118
|
+
Registration and detection run sequentially in suite2p's pipeline, so
|
|
119
|
+
the peak for a plane is ``max(registration, detection)``, not the sum.
|
|
120
|
+
The two stages load different pools:
|
|
121
|
+
|
|
122
|
+
- Registration compute runs on ``device``. When ``device`` is cuda the
|
|
123
|
+
per-batch float32/FFT buffers live in VRAM, scaled by
|
|
124
|
+
``batch_size * Ly * Lx``. The reference-image correlation
|
|
125
|
+
(``pick_initial_reference``) and the binary read stay on host.
|
|
126
|
+
- Detection's binned movie is a host numpy array, and the default
|
|
127
|
+
``sparsery`` / ``sourcery`` detectors run on CPU. ``device`` is only
|
|
128
|
+
used by the cellpose path, which sees the 2D meanImg / max_proj, not
|
|
129
|
+
the movie. So the binned movie never enters VRAM.
|
|
130
|
+
|
|
131
|
+
Host RAM therefore peaks during detection (binned movie plus the
|
|
132
|
+
high-pass / sparsery copies, ~2.5x); VRAM peaks during registration
|
|
133
|
+
(or cellpose inference, when enabled). Neither VRAM term scales with
|
|
134
|
+
``n_frames``; host detection plateaus once ``n_frames // bin_size``
|
|
135
|
+
exceeds ``nbins``.
|
|
136
|
+
|
|
137
|
+
Parameters
|
|
138
|
+
----------
|
|
139
|
+
ops : dict
|
|
140
|
+
Flat Suite2p ops. Reads ``nimg_init``, ``batch_size`` (registration
|
|
141
|
+
batch), ``nbins``, ``bin_size``, ``tau``, ``fs``, ``nchannels``, and
|
|
142
|
+
``anatomical_only``. Missing keys fall back to suite2p defaults.
|
|
143
|
+
Ly, Lx : int
|
|
144
|
+
Frame height and width in pixels. The detection crop (yrange/xrange)
|
|
145
|
+
is unknown before registration, so full ``Ly``/``Lx`` are used as an
|
|
146
|
+
upper bound.
|
|
147
|
+
n_frames : int
|
|
148
|
+
Number of frames in the plane.
|
|
149
|
+
device : str, optional (default "cuda")
|
|
150
|
+
Torch device. VRAM terms are reported only when this starts with
|
|
151
|
+
"cuda".
|
|
152
|
+
workers : int, optional (default 1)
|
|
153
|
+
Concurrent plane workers. Per-plane peaks are multiplied by this for
|
|
154
|
+
the ``*_total`` fields.
|
|
155
|
+
|
|
156
|
+
Returns
|
|
157
|
+
-------
|
|
158
|
+
dict
|
|
159
|
+
Bytes for ``host_per_plane``, ``vram_per_plane``, ``host_total``,
|
|
160
|
+
``vram_total``. VRAM fields are 0 when ``device`` is not cuda.
|
|
161
|
+
|
|
162
|
+
Notes
|
|
163
|
+
-----
|
|
164
|
+
The 2.5x detection multiplier and the cpsam VRAM constant are rough; the
|
|
165
|
+
real values depend on data and hardware. Calibrate with
|
|
166
|
+
``torch.cuda.max_memory_allocated()`` and an RSS sample around the
|
|
167
|
+
registration / detection calls for tight bounds.
|
|
168
|
+
"""
|
|
169
|
+
cuda = str(device).startswith("cuda")
|
|
170
|
+
|
|
171
|
+
nimg_init = min(int(ops.get("nimg_init", 400)), n_frames)
|
|
172
|
+
reg_host = nimg_init * Ly * Lx * 10 # int16 frames + float64 ref corr (CPU)
|
|
173
|
+
|
|
174
|
+
nbins = int(ops.get("nbins", 5000))
|
|
175
|
+
bin_size = ops.get("bin_size") or max(
|
|
176
|
+
1, n_frames // nbins, round(ops.get("tau", 1.0) * ops.get("fs", 10.0))
|
|
177
|
+
)
|
|
178
|
+
nbinned = min(nbins, n_frames // bin_size)
|
|
179
|
+
detect_host = int(2.5 * nbinned * Ly * Lx * 4) # binned movie + hp/sparsery copies (CPU)
|
|
180
|
+
|
|
181
|
+
host_peak = max(reg_host, detect_host)
|
|
182
|
+
|
|
183
|
+
vram_peak = 0
|
|
184
|
+
if cuda:
|
|
185
|
+
reg_batch = int(ops.get("batch_size", 100))
|
|
186
|
+
nchan = int(ops.get("nchannels", 1))
|
|
187
|
+
reg_vram = nchan * 8 * reg_batch * Ly * Lx * 4 # ~8 float32/FFT buffers per batch
|
|
188
|
+
cpsam_vram = 1_500_000_000 if ops.get("anatomical_only", 0) else 0 # cpsam weights + activations
|
|
189
|
+
vram_peak = max(reg_vram, cpsam_vram)
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
"host_per_plane": host_peak,
|
|
193
|
+
"vram_per_plane": vram_peak,
|
|
194
|
+
"host_total": host_peak * max(1, workers),
|
|
195
|
+
"vram_total": vram_peak * max(1, workers),
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
114
199
|
def bin1d(X, bin_size, axis=0):
|
|
115
200
|
"""
|
|
116
201
|
Mean bin over `axis` of `X` with bin `bin_size`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: lbm_suite2p_python
|
|
3
|
-
Version: 3.2.
|
|
3
|
+
Version: 3.2.1
|
|
4
4
|
Summary: Calcium Imaging Pipeline built with Suite2p, Cellpose and Rastermap
|
|
5
5
|
License-Expression: BSD-3-Clause
|
|
6
6
|
Project-URL: homepage, https://github.com/MillerBrainObservatory/LBM-Suite2p-Python
|
|
@@ -2,7 +2,7 @@ lbm_suite2p_python/__init__.py,sha256=vllkrB3KK_xr6INPgzfqPHNmiH1MxfHObycRJbP7Tm
|
|
|
2
2
|
lbm_suite2p_python/__main__.py,sha256=lMnZnMkCbv8OTh5i5uZlG1sF33PEs42zITw8aG8YKwI,131
|
|
3
3
|
lbm_suite2p_python/_benchmarking.py,sha256=oi7q5VDShYa-YqEiZluJEmOeq-_X2jzz-bjxIalhLZ4,172
|
|
4
4
|
lbm_suite2p_python/cellpose.py,sha256=a7H1-458YYUiZhAGbqDdAosPmQlsDbkllm1ec_joCc0,63246
|
|
5
|
-
lbm_suite2p_python/cli.py,sha256=
|
|
5
|
+
lbm_suite2p_python/cli.py,sha256=qwJV2U9umPHnJXOEOHRIF6H-2N0MygBXVvKTYLQsH6o,21713
|
|
6
6
|
lbm_suite2p_python/conversion.py,sha256=PnrtlpzBXIX0QYu2WxjuJfdWwc-KIr9DhCIo7hSi0f4,31910
|
|
7
7
|
lbm_suite2p_python/db_settings.py,sha256=kYJuv_-7eqPdngdEj5uYlJjavEoZyRWxCEeByABX0QE,22519
|
|
8
8
|
lbm_suite2p_python/default_ops.py,sha256=muReAJIzuBTsS-pmvPeYacmUz4DZptKteQNQhDUoago,3594
|
|
@@ -10,13 +10,13 @@ lbm_suite2p_python/grid_search.py,sha256=4Sgl2Nx95jHrpm4S9yj0z4R6tR8CrslPRAM8xiD
|
|
|
10
10
|
lbm_suite2p_python/gui.py,sha256=jA8dg1yEM0ikMNJ0UrE_6joQkuqsmDj9I_pIb-E0YpA,10594
|
|
11
11
|
lbm_suite2p_python/merging.py,sha256=qcQmAnaJPPniSMDDVeu_uZTcstXMYNfvWUBU4zVKLEI,13928
|
|
12
12
|
lbm_suite2p_python/postprocessing.py,sha256=ESCQCIpxyjwAJTk-pS-Y1LPJ0f1zeXkc7sPYXwbscEA,59560
|
|
13
|
-
lbm_suite2p_python/run_lsp.py,sha256=
|
|
14
|
-
lbm_suite2p_python/utils.py,sha256=
|
|
13
|
+
lbm_suite2p_python/run_lsp.py,sha256=Z_r-cqika-YBTPQYOB2LccpsRwmWjmXeZdehEZFx0Wo,134031
|
|
14
|
+
lbm_suite2p_python/utils.py,sha256=MmUe5lhOIQb-TBB3KtW_wu4l4jw8hbpkwNUOFGF9S9o,7557
|
|
15
15
|
lbm_suite2p_python/volume.py,sha256=kk_YLXQBPGkzdTVhxfH_Sc4TJLN9I_WztkHZPu8x-tc,80784
|
|
16
16
|
lbm_suite2p_python/zplane.py,sha256=BQ6fZidHHPl2GHoPY2R_Po6givVZjAEzH4I2tQfnI8s,177426
|
|
17
|
-
lbm_suite2p_python-3.2.
|
|
18
|
-
lbm_suite2p_python-3.2.
|
|
19
|
-
lbm_suite2p_python-3.2.
|
|
20
|
-
lbm_suite2p_python-3.2.
|
|
21
|
-
lbm_suite2p_python-3.2.
|
|
22
|
-
lbm_suite2p_python-3.2.
|
|
17
|
+
lbm_suite2p_python-3.2.1.dist-info/licenses/LICENSE.md,sha256=iZa6bLG-5EfV2LXTfQQ7wdDwslaIc9SrOfyKRtzvCoQ,1981
|
|
18
|
+
lbm_suite2p_python-3.2.1.dist-info/METADATA,sha256=-wygW7hl3Yk-ILODucXbo9h3dmqZdasM16jkNCM0Frs,8830
|
|
19
|
+
lbm_suite2p_python-3.2.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
20
|
+
lbm_suite2p_python-3.2.1.dist-info/entry_points.txt,sha256=Ow6TsVyBZI0viAeQP6Ty7GJAmoXD7RmMhIxongAWAVM,100
|
|
21
|
+
lbm_suite2p_python-3.2.1.dist-info/top_level.txt,sha256=WhCsVG68YLKWeTNJVwueG_4H3uuiI22I_TERsF-5mGk,19
|
|
22
|
+
lbm_suite2p_python-3.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{lbm_suite2p_python-3.2.0.dist-info → lbm_suite2p_python-3.2.1.dist-info}/licenses/LICENSE.md
RENAMED
|
File without changes
|
|
File without changes
|