suite2p icon indicating copy to clipboard operation
suite2p copied to clipboard

Max projection in combined is all zeros if excluding flyback planes

Open asumser opened this issue 4 years ago • 2 comments

Thank you for implementing flyback plane exclusion recently, which makes my workflow more seamless. A minor bug appeared with that though: When loading combined view from a dataset with excluded flyback frame(s), max projection is just empty/zeros. If the individual planes are loaded, max projection looks normal. I assume there is some (hopefully easily resolved) issue with rescaling the max projection if one or more planes are empty while combining the images.

Thank you for the great software and continuous improvements!

asumser avatar Oct 24 '21 10:10 asumser

hmm not sure why the rescaling isn't working, this is where the combined file adds the max_proj files together: https://github.com/MouseLand/suite2p/blob/b0a7d6f403ffab32f3b0baed6412b6256dc22374/suite2p/io/save.py#L115. I'd appreciate if you can try running it and changing it for your purposes and opening a pull request. install suite2p in editable mode (git clone suite2p, change to the folder, then pip install -e .) and try modifying the function accordingly and testing in a jupyter notebook for instance

from suite2p.io.save import combined

combined(save_folder)

carsen-stringer avatar Nov 01 '21 21:11 carsen-stringer

Thanks for the pointer. I am not very familiar with github and don't actually know how to make a pull request. Nevertheless, looking into this, the issue seems that no max_projection is created in the skipped flyback frame's ops file. As any flyback frame tends to be the last plane and the last ops makes up the backbone for combined ops in suite2p/suite2p/io/save.py line 159: if 'max_proj' in ops: returns false

The simplest way to fix this I could think of was to change into: line 159: if any(['max_proj' in ops for ops in ops1]):

which works for me! alternatively one could remove flyback frames from ops1 in line 79. sorry for the extra work changing this without a pull request. you may close this issue. Thanks again!

asumser avatar Nov 04 '21 16:11 asumser

this is fixed now

carsen-stringer avatar May 14 '23 02:05 carsen-stringer