MouseLand / suite2p

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

Fixing bug in checking whether the ROIs_on checkbox is checked #1029

Closed landoskape closed 10 months ago

landoskape commented 1 year ago

Main Request:

There was a bug in the code in the ROIs_on method in which the state of the checkbox was always evaulated to False. Specifically, state is returned as an integer (0 for unchecked, 2 for checked). However, the if statement compared state to QtCore.Qt.Checked, which is an enum. Therefore, pressing spacebar or clicking the ROIs_on checkbox always tried to remove the self.color items, generating a warning and preventing the user from toggling ROIs on and off.

I fixed this by processing state through a Qt method that converts it to an enum, allowing successful comparison between the "checked" state with the following line:

if QtCore.Qt.CheckState(state) == QtCore.Qt.Checked:
    # rest of function

EDIT: I realized that the same issue shows up in the roi_text and zoom_cell method, so fixed it there too.

Fixes #1028

Minor request:

The conda create statement for developers unnecessarily included the "env" argument and didn't specify the python version. When the most recent python version is downloaded (3.11), then an update to dataclasses prevents the ROI class in detection/stats.py from working properly because a np.ndarray field is not hashable (see their update).

The fix to this issue was identified in this issue (from a different repository - huggingface/datasets#5230).

landoskape commented 11 months ago

As for the other PR, I created a new one without excess commit history. Can be found here: #1057