Skip to content

Commit

Permalink
Update bioimageio-colab.imjoy.html
Browse files Browse the repository at this point in the history
  • Loading branch information
oeway authored May 10, 2024
1 parent a28e75c commit 844c287
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions plugins/bioimageio-colab.imjoy.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,25 @@
// Define image reading and displaying function
const getImage = async () => {
if (this.image !== null) {
await viewer.removeLayer({id: this.imageLayer.id});
await viewer.removeLayer({id: this.annotationLayer.id});
await viewer.remove_layer({id: this.imageLayer.id});
await viewer.remove_layer({id: this.annotationLayer.id});
}

[this.image, this.filename, this.newname] = await this.biocolab.getRandomImage();
this.imageLayer = await viewer.viewImage(this.image, {name: "image"});
[this.image, this.filename, this.newname] = await this.biocolab.get_random_image();
this.imageLayer = await viewer.view_image(this.image, {name: "image"});
// Add the annotation functionality to the interface
this.annotationLayer = await viewer.addShapes([], {
this.annotationLayer = await viewer.add_shapes([], {
shape_tpe: "polygon",
draw_edge_color: "magenta",
name: "annotation",
});
};

const saveAnnotation = async () => {
const annotation = await this.annotationLayer.getFeatures();
if(annotation.features.length > 0){
await this.biocolab.saveAnnotation(this.filename, this.newname, features, [this.image.shape[0], this.image.shape[1]]);
if(!this.annotationLayer) return;
const annotation = await this.annotationLayer.get_features();
if(annotation.features.length > 0){
await this.biocolab.save_annotation(this.filename, this.newname, annotation, [this.image._rshape[0], this.image._rshape[1]]);
await api.showMessage("Annotation Saved to " + this.filename);
}
else{
Expand All @@ -75,8 +76,8 @@
};

const nextImage = async (option) => {
await getImage();
await saveAnnotation();
await getImage();
};

await viewer.add_widget({
Expand Down

0 comments on commit 844c287

Please sign in to comment.