MouseLand / suite2p

cell detection in calcium imaging recordings
http://www.suite2p.org
GNU General Public License v3.0
334 stars 239 forks source link

FEATURE: Calculate dead columns from unidirectional sbx files or manually crop sbx files #1025

Closed tkmymgc closed 11 months ago

tkmymgc commented 11 months ago

Feature you'd like to see:

I did see suite2p calculates dead columns from bidirectional sbx files, but it does not do for unidirectional. If the signal from tissue is not so strong, ROIs tend to be near the edge of imaging window, but not on cells. I realized removing dead columns helps for detecting cells (ROIs) significantly. That is a reason why I want to remove dead columns. Alternatively, it would be great if I could crop sbx file before running with jupyter notebook. So far I need to convert sbx file to tiff and then crop on MATLAB, which is additional time-consuming stuff for large size of imaging data.

Attempted alternative approaches:

I added "sbxinfo.scanmode != 1" in the condition to calculate dead columns for unidirectional files as shown below. Even with this change, ndeadcolumns was calculated as 0 when running suite2p.

    if sbxinfo.scanmode != 1 or sbxinfo.scanmode != 0:
        # compute dead cols from the first file
        tmpsbx = sbx_memmap(sbxlist[0])
        colprofile = np.mean(tmpsbx[0][0][0],axis = 0)
        ndeadcols = np.argmax(np.diff(colprofile)) + 1
        del tmpsbx
        print('Removing {0} dead columns while loading sbx data.'.format(ndeadcols))
        ndeadcols = 0

Additional Context

No response