Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combine sbx files #748

Closed
smilingtoad opened this issue Oct 12, 2021 · 7 comments
Closed

combine sbx files #748

smilingtoad opened this issue Oct 12, 2021 · 7 comments

Comments

@smilingtoad
Copy link

Hi suite2p community -

I have a small issue I am hoping people can help me out with.

We are using the MATLAB based suite2p along with Scanbox for image acquisition. Scanbox saves files in .sbx format and I need a way to combine a bunch of these small .sbx files into one continuous .sbx file. Dario Ringach of Scanbox seems to think there is a way to do this using suite2p.

Any help or advice would be great!

@generalciao
Copy link

In the python version, multiple .sbx files placed into the data directory will all be processed as a single (concatenated) session. You could switch to the latest python version (which handles your .sbx files fine), then use the resulting .mat file for further work.

Or you can just concatenate the .sbx files yourself before running suite2p. They are binary files, so under Windows, open a CMD prompt and use the "copy" command with the /b flag and the plus operator. Like so:

copy st1_000_001.sbx /B + st1_000_002.sbx /B + st1_000_003.sbx /B st1_000_concatenated.sbx /B

You could also use wildcards, but I haven't tested this myself. For example to concatenate all .sbx files in a directory:

copy *.sbx /B st1_000_concatenated.sbx /B

PS: The trailing /B might not be necessary, I'm not sure, but it works for me as above.

@smilingtoad
Copy link
Author

Thanks much generalciao, I will give this a shot. So far my PI is resisting the switch to python but I will keep pushing! Cheers!!

@smilingtoad
Copy link
Author

Okay, one step closer. The CMD approach worked and I have one sbx file. Now......in order for me to make tiffs from the sbx file I need the associated mat files which I also don't know how to combine into a single file. Again any advice is appreciated.

@generalciao
Copy link

generalciao commented Oct 12, 2021

Just pick any of the original .mat files, rename it to match the filename of the single concatenated .sbx, and go for it.

This should be fine because (a) all the acquisition conditions should be identical (else you would not want to combine them all in the first place), and (b) even if the number of frames acquired per acquisition varies across the original files, the .mat files don't contain a parameter for the actual number of frames recorded (this can change, for example if you click ABORT during acq). As far as I know, suite2p will read in the .sbx contents just fine. Have you tried it? Or why do you want to combine multiple .mat files?

For what it's worth, you can really just test this stuff in your existing Matlab scanbox analysis environment, i.e. using sbxread or any of Dario's GUI tools like sbxaligntool. Once the concatenated files work there, then switch over to using it with suite2p.

@smilingtoad
Copy link
Author

got it to work, really appreciate your help my friend!!

@smilingtoad
Copy link
Author

also the wildcard works as well!!

@carsen-stringer
Copy link
Member

thanks @generalciao !

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

No branches or pull requests

3 participants