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

Prototype napari plugin widget for annotator_2d #177

Conversation

GenevieveBuckley
Copy link
Collaborator

Relates to #167

Copy link
Contributor

@constantinpape constantinpape left a comment

Choose a reason for hiding this comment

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

Thanks for starting to work on this @GenevieveBuckley! I checked the high level structure and this perfectly matches what we discussed in #167. I haven't tried running it myself yet, since I am not sure if it's ready for that yet. Let me know if/once it is and then I will test it!
Besides that I just left a few minor comments with clarifications (and one minor change request).
Let me know if you need any input from my side to continue!

return v


def _update_viewer(v, raw, show_embeddings, segmentation_result):
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is needed by the image_series_annotator. I understand why you removed it (the current logic will not work any longer and we need to change it when adapting the image_series_annotator), but please leave in this function for now (without calling it), so that we have it as a reference for the series annotator.

model_type: AVAILABLE_MODELS = AVAILABLE_MODELS[_DEFAULT_MODEL],
tile_shape: Tuple[int, int] = (None, None),
halo: Tuple[int, int] = (None, None),
predictor: Optional[SamPredictor] = None, # not accessible via magicgui widget, not a recognised type
Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding the comment: that's ok. This doesn't make sense to pass via napari anyways. The predictor is currently exposed for 2 reasons:

  1. To pass the already initialized predictor in the image_series_annotator, where the logic for image embeddings is done externally.
  2. To enable passing predictors that were loaded from a custom checkpoint.

As far as I understand your comment, it doesn't hurt to leave it in for now. After we have merged this PR I can rethink a bit how this is handled because: re 1. we need to change the image_series_annotator logic anyways and re 2.: it would be good to enable loading of custom models also from the napari plugin. (Here: custom model means that we are using a url or filepath to specifiy the checkpoint rather than one of the names from AVAILABLE_MODELS).

util.set_precomputed(PREDICTOR, IMAGE_EMBEDDINGS)

# viewer is freshly initialized
if v is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Just fyi: this condition is for the image_series_annotator: in that case we pass the napari viewer object via the v argument. Hence it is not None and _update_viewer is called to replace all relevant layers.
I just wanted to clarify because it relates to my comment on _update_viewer. We can go ahead and remove the condition since the image_series_annotator needs to be redone after finalizing the 2d annotator.

@constantinpape
Copy link
Contributor

Hi @GenevieveBuckley ,
I have started with a developer documentation here to give a bit more high level overview of the intended design for the plugin, including a flow diagram that exemplifies it for the 2d annotation tool. I hope this is helpful and please let me know if you have any more questions about this.

For this PR I suggest you only focus on the 2d annotation plugin, i.e. that annotator_2d_plugin and the corresponding napari plugins work as intended. We can then take care of the CLI function (annotator_2d) and the other plugins in follow-up PRs.
From what I can see the following things are still missing for that:

  • The embedding widget, including how we handle that the name of the Image layer is not hard-coded to raw any more.
  • How we deal with the global variables? Can we move the corresponding state into attributes of the viewer and / or layers?

@constantinpape
Copy link
Contributor

Superseeded by recent changes.

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.

2 participants