From 5d6bbc0a5b82b0e6d9aea8ae9a6480c19a3ecf61 Mon Sep 17 00:00:00 2001 From: Horst Obenhaus Date: Wed, 12 Feb 2025 18:25:57 +0100 Subject: [PATCH 1/2] put n_frames into BinaryFile constructor --- suite2p/extraction/extract.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/suite2p/extraction/extract.py b/suite2p/extraction/extract.py index 8a5093453..a802ab3da 100644 --- a/suite2p/extraction/extract.py +++ b/suite2p/extraction/extract.py @@ -141,8 +141,9 @@ def extract_traces_from_masks(ops, cell_masks, neuropil_masks): """ batch_size = ops["batch_size"] + nframes = ops["nframes"] F_chan2, Fneu_chan2 = [], [] - with BinaryFile(Ly=ops["Ly"], Lx=ops["Lx"], filename=ops["reg_file"]) as f: + with BinaryFile(Ly=ops["Ly"], Lx=ops["Lx"], filename=ops["reg_file"], n_frames=nframes) as f: F, Fneu = extract_traces(f, cell_masks, neuropil_masks, batch_size=batch_size) if "reg_file_chan2" in ops: with BinaryFile(Ly=ops["Ly"], Lx=ops["Lx"], From c716dce8b090a9d823e801e3b5bcb36405938b30 Mon Sep 17 00:00:00 2001 From: Horst Obenhaus Date: Wed, 12 Feb 2025 18:44:26 +0100 Subject: [PATCH 2/2] added the parameter in other places too --- suite2p/extraction/extract.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/suite2p/extraction/extract.py b/suite2p/extraction/extract.py index a802ab3da..ac23970b3 100644 --- a/suite2p/extraction/extract.py +++ b/suite2p/extraction/extract.py @@ -147,7 +147,7 @@ def extract_traces_from_masks(ops, cell_masks, neuropil_masks): F, Fneu = extract_traces(f, cell_masks, neuropil_masks, batch_size=batch_size) if "reg_file_chan2" in ops: with BinaryFile(Ly=ops["Ly"], Lx=ops["Lx"], - filename=ops["reg_file_chan2"]) as f: + filename=ops["reg_file_chan2"], n_frames=nframes) as f: F_chan2, Fneu_chan2 = extract_traces(f, cell_masks, neuropil_masks, batch_size=batch_size) return F, Fneu, F_chan2, Fneu_chan2 @@ -251,10 +251,11 @@ def create_masks_and_extract(ops, stat, cell_masks=None, neuropil_masks=None): # create cell and neuropil masks Ly, Lx = ops["Ly"], ops["Lx"] + nframes = ops["nframes"] reg_file = ops["reg_file"] reg_file_alt = ops.get("reg_file_chan2", ops["reg_file"]) - with BinaryFile(Ly=Ly, Lx=Lx, filename=reg_file) as f_in,\ - BinaryFile(Ly=Ly, Lx=Lx, filename=reg_file_alt) as f_in_chan2: + with BinaryFile(Ly=Ly, Lx=Lx, filename=reg_file, n_frames=nframes) as f_in,\ + BinaryFile(Ly=Ly, Lx=Lx, filename=reg_file_alt, n_frames=nframes) as f_in_chan2: if ops["nchannels"] == 1: f_in_chan2.close() f_in_chan2 = None