Skip to content

Commit c9d925e

Browse files
Merge pull request #648 from tbenst/fix-skip-neuropil
fix case when neuropil_ipix not assigned
2 parents e822e41 + 76ac9ee commit c9d925e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

suite2p/extraction/extract.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,16 @@ def extract_traces(ops, cell_masks, neuropil_masks, reg_file):
6464

6565
cell_ipix = [cell_mask[0].astype(np.int64) for cell_mask in cell_masks]
6666
cell_lam = [cell_mask[1].astype(np.float32) for cell_mask in cell_masks]
67+
6768
if neuropil_masks is not None:
6869
if isinstance(neuropil_masks, np.ndarray) and neuropil_masks.shape[1] == Ly*Lx:
6970
neuropil_masks = [np.nonzero(neuropil_mask)[0] for neuropil_mask in neuropil_masks]
7071
else:
7172
neuropil_masks = [neuropil_mask.astype(np.int64) for neuropil_mask in neuropil_masks]
7273
neuropil_ipix = neuropil_masks
7374
neuropil_npix = np.array([len(neuropil_ipixi) for neuropil_ipixi in neuropil_ipix]).astype(np.float32)
75+
else:
76+
neuropil_ipix = None
7477

7578
ix = 0
7679
for k, (_, data) in enumerate(reg_file.iter_frames(batch_size=ops['batch_size'])):
@@ -174,7 +177,8 @@ def create_masks_and_extract(ops, stat, cell_masks=None, neuropil_masks=None):
174177
for k in range(F.shape[0]):
175178
stat[k]['skew'] = sk[k]
176179
stat[k]['std'] = sd[k]
177-
stat[k]['neuropil_mask'] = neuropil_masks[k]
180+
if not neuropil_masks is None:
181+
stat[k]['neuropil_mask'] = neuropil_masks[k]
178182

179183
return ops, stat, F, Fneu, F_chan2, Fneu_chan2
180184

0 commit comments

Comments
 (0)