Skip to content

Refactor SBX binary conversion for current IO flow#1242

Open
ytsimon2004 wants to merge 2 commits into
MouseLand:mainfrom
ytsimon2004:fix/sbx-to-binary-v1x
Open

Refactor SBX binary conversion for current IO flow#1242
ytsimon2004 wants to merge 2 commits into
MouseLand:mainfrom
ytsimon2004:fix/sbx-to-binary-v1x

Conversation

@ytsimon2004

@ytsimon2004 ytsimon2004 commented May 29, 2026

Copy link
Copy Markdown

Summary

This PR contains two fixes from ytsimon2004:fix/sbx-to-binary-v1x:

  • updates suite2p.io.sbx.sbx_to_binary to match the current v1.x binary conversion handler interface used by run_s2p
  • casts the scipy.stats.mode result in sparsedetect.py to an integer scalar before it is used downstream

SBX Conversion

sbx_to_binary still used the old API and called init_settings() / find_files_open_binaries(), which are no longer active in the current IO flow. That caused SBX input conversion to fail when run_s2p called the handler with (dbs, settings, files, files_chan2).

The updated SBX converter now:

  • accepts (dbs, settings, reg_file, reg_file_chan2) like the other current converters
  • reads input files from dbs[0]["file_list"]
  • writes through the already-open binary file handles
  • updates and saves per-plane db.npy / settings.npy
  • computes mean images from frame sums
  • counts functional-channel frames once for two-channel recordings
  • keeps sbx_ndeadcols auto-detection defaulting to -1
  • keeps sbx_ndeadrows defaulting to 0, so row auto-detection only happens when users explicitly set db["sbx_ndeadrows"] = -1

Sparse Detection

estimate_spatial_scale() returned the mode(..., keepdims=True) output as a NumPy array. Later code expected an integer scalar, which could raise:

TypeError: only 0-dimensional arrays can be converted to Python scalars

The fix returns int(im.item()).

Validation

Validated by successfully running Suite2p on .sbx files from both single-plane and multi-plane recordings

@ytsimon2004 ytsimon2004 marked this pull request as ready for review May 29, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant