suite2p icon indicating copy to clipboard operation
suite2p copied to clipboard

making merging permanent and fixing some bugs to the merge process

Open pwang724 opened this issue 4 years ago • 3 comments

I had a frustrating time dealing with the bugs and default behavior of the merge process so here are some proposed changes. My use case is that I am imaging dendrites, so lots of unconnected but spatially proximal segments need to be merged. The default behavior is to preserve all ROIs and append merged ROIs towards the very end. In my experience this gets very confusing very fast, especially if there are lots of merges (in my case, ~20% of all ROIs), because during the review process, ROIs must be hand-checked to see whether they have already been merged.

In addition there was a prominent display bug: component ROIs are removed via mask.remove_roi and the merged_roi is displayed via mask.add_roi. However, if I were to come across the component ROIs, by either typing in its index or by left/right arrowing through the ROI list, the display gets wacky since it would display the component ROI and the merged ROI.

I made the following changes to the workflow:

  • delete the component rois, only keeping the merged roi.
  • merged cells are treated the same as regular cells. All traces of their previous component cells are erased. The fields 'i_merge', 'in_merge' in parent and stats are gone.
  • the merged roi is not appended towards the very end but at the min index of all component rois.
  • after the merge, the selection (parent.ichosen) is kept at the merged roi.
  • after every merge, masks are recomputed and merges are saved

These changes allow me to start from roi 0, right arrow until I hit a roi X that needs to be merged with another roi Y. X and Y are then merged, and the merged cell index is at X since X < Y. I then continue right arrowing and merging until I iterate through the entire dataset.

Minor changes:

  • Line 111 throws errors later on and other stat dicts does not have the key chan2_prob
  • Lines 136-146 have no effect since np delete is not in-place. Also Lines 143-144 throws errors if not conditioned by parent.hasred

pwang724 avatar Nov 06 '21 06:11 pwang724

thanks so much for the pull request! we are happy to modify merging depending on user needs, we do not use the merging ourselves.

based on your experience, you think users prefer merges to be permanent? I was wary of overwriting the original file. is there any way to keep them from being permanently merged while fixing the bugs? or do you think this is not an issue?

carsen-stringer avatar Nov 12 '21 15:11 carsen-stringer

Apologize for the late reply and thank you for getting back! I personally think this is not an issue, I've never had to 'un-merge' cells or restart from scratch since the gui process makes this quite easy and error-proof.

pwang724 avatar Dec 01 '21 07:12 pwang724

If the merges will be permanent, would it be possible to have an undo command in the GUI, for the most recent merge? Maybe that requires too much effort, not sure ...

generalciao avatar Dec 01 '21 13:12 generalciao

This proposal has fallen behind the current suite2p version (many conflicting files) and will be closed.

marius10p avatar Oct 30 '23 14:10 marius10p