Skip to content

Conversation

@alessandrofelder
Copy link
Member

@alessandrofelder alessandrofelder commented Apr 30, 2025

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

What does this PR do?

Makes check_training_data_exists more strict, by requiring both non-empty training data layers to return True.
For check_training_data_exists, this PR

  • Improves the user messages and UI
  • makes the code more explicit
  • adds tests and docstring for this function.

References

Closes #527

How has this PR been tested?

Local pytest

Is this a breaking change?

Yes - users can't get away with a non-existent training data layer anymore.

Does this PR require an update to the documentation?

Our tutorial still works the same, so no change needed there. This change enforces good practice with users.
Have added a docstring to a function that didn't have one.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@alessandrofelder alessandrofelder marked this pull request as ready for review April 30, 2025 16:47
@alessandrofelder alessandrofelder requested a review from a team April 30, 2025 16:47
Copy link
Member

@IgorTatarnikov IgorTatarnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I found the toast at the bottom of the screen hard to catch, since this interrupts the workflow should it use display_info from qt-niu to show a pop up? I don't think it's required so I'll approve and let you decide!

@alessandrofelder
Copy link
Member Author

As discussed internally, we should loosen the strictness on the layer emptiness as per @adamltyson's suggestion, to allow users to iteratively add points to a single training data layer, but probably warn users that their final retraining data should be a balanced mix of cells/non-cells

Copy link
Member

@IgorTatarnikov IgorTatarnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Just a few small comments.

Comment on lines +228 to +229
def test_valid_widget_has_valid_training_data(valid_curation_widget):
assert valid_curation_widget.check_training_data_exists()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a duplicate of test_valid_widget_has_extractable_data?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_data_extractable is a slightly different function to check_training_data_exists so I think not (we should maybe refactor, but that should be a separate issue/PR?

valid_curation_widget.viewer.layers["Training data (non cells)"].data = (
None
)
valid_curation_widget.check_training_data_exists()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assert not valid_curation_widget.check_training_data_exists() just to make sure False is also returned?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes (but it it should be assert not assert not - this case will still return True just also call show_info?)

@IgorTatarnikov
Copy link
Member

Test failures are unrelated and fixed by #577

@alessandrofelder alessandrofelder merged commit 63f45e2 into main Jan 22, 2026
17 of 18 checks passed
@alessandrofelder alessandrofelder deleted the improve-save-curation branch January 22, 2026 18:27
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.

Improve curation.py::check_training_data_exists()

3 participants