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

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

Closed
wants to merge 8 commits into from

Conversation

landoskape
Copy link
Contributor

@landoskape landoskape commented Aug 29, 2023

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 landoskape changed the title Fixing conda environment creation statement for developers Fixing bug in checking whether the ROIs_on checkbox is checked Aug 30, 2023
simon-ball added a commit to simon-ball/suite2p that referenced this pull request Oct 23, 2023
dataclass default values no longer permitted to be mutable in 3.11 (https://docs.python.org/3.11/whatsnew/3.11.html#dataclasses)

Two changes needed:
* Use a default_factory instead (ensures separate instances have independent values)
* use a lamba to generate the same default value used previously

reference MouseLand#1029
the conda create statement for the developer version was incorrect (it added the "env" argument unnecessarily) and didn't specify which python version to use. The newest python (3.11) has updates to the dataclasses module, which prevent the ROI class from working properly (in detection/stats.py) due to it's not being hashable.
state is returned as an integer (0 for unchecked, 2 for checked). When state is compared with `QtCore.Qt.Checked`, it always evaluates to False, because Qt.Checked is an enum, not an int. Processing state through QtCore.Qt.CheckState fixes this error and allows the user to toggle ROIs on and off
Following the discussion in issue MouseLand#709, I added an explanation to the docs that explains how to apply a new classifier.
@landoskape
Copy link
Contributor Author

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

@landoskape landoskape closed this Nov 13, 2023
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

Successfully merging this pull request may close these issues.

BUG: Toggling ROIs off and on with spacebar causes a QGraphicsScene issue
1 participant