Annotation Writer

Hello everyone,
I am trying to create a ROI (region of interest) in Orbit using Groovy script. There is a script available on Orbit’s Github i.e. AnnotationWriter.groovy. I tried to run the script but am unable to see any output. Can you please guide me where the output is stored?

the link to script:
https://github.com/mstritt/orbit-image-analysis/blob/53e25de84199d77b99a46eda0e7b2a3dc76aceaf/src/main/groovy/com/actelion/research/orbit/imageAnalysis/scripts/AnnotationWriter.groovy

Dear @zsalam,

the selected image provider defines how annotations are stored. If you use the “ImageproviderLocal” (orbit standalone, no image server), the annotations are stored in a sqllite file in your user home (orbit.db).
You have to reload your image to see them visually on the image.

Regards,
Manuel

1 Like

Dear @mstritt,

Thankyou for your response. I added the following code with related imports but still unable to see any polygon on the image.

RawDataFile rdf = ((ImageProviderLocal)DALConfig.imageProvider).registerFile(new File(“C:/…/myImage.svs”),0)

Dear @zsalam,
actually, there is a mistake in the code: you have to add

rawAnnotation.setRawDataFileId(ID);

and set the image ID.
I recommend to first open your image in he UI, then check tab “file” on the right side to get the registered id.

Hope that helps!

Manuel

2 Likes

Dear @mstritt,

Thankyou for your reply. I added the code but still when I open the image again there is no annotated region. This is the code I am running.

Regards

import com.actelion.research.orbit.beans.RawAnnotation
import com.actelion.research.orbit.imageAnalysis.dal.DALConfig
import com.actelion.research.orbit.imageAnalysis.models.ImageAnnotation
import com.actelion.research.orbit.imageAnalysis.models.PolygonExt

import java.awt.Color

import com.actelion.research.orbit.beans.RawDataFile

import com.actelion.research.orbit.imageAnalysis.dal.ImageProviderLocal
/*
 *     Orbit, a versatile image analysis software for biological image-based quantification.
 *     Copyright (C) 2009 - 2017 Actelion Pharmaceuticals Ltd., Gewerbestrasse 16, CH-4123 Allschwil, Switzerland.
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
// this example stores an Orbit ROI

String user = "omero";
String pw = "password";

DALConfig.getImageProvider().authenticateUser(user,pw);
RawDataFile rdf = ((ImageProviderLocal)DALConfig.imageProvider).registerFile(new File("C:/.../myImage.svs"),0);

// create a dummy polygon ROI
PolygonExt polygon = new PolygonExt();
polygon.addPoint(10,10);
polygon.addPoint(20,10);
polygon.addPoint(20,20);
polygon.setClosed(true);

ImageAnnotation annotation = new ImageAnnotation("ROI",polygon,ImageAnnotation.SUBTYPE_ROI, Color.yellow);
// you might add further shapes like SUBTYPE_EXCLUSION to exclude parts inside a ROI or SUBTYPE_INCLUSION to include a part in an exclusion
// or just use SUBTYPE_NORMAL to add an informative annotation which does not influence the ROI at all

RawAnnotation rawAnnotation = new RawAnnotation();
rawAnnotation.setRawDataFileId(4);//image id
rawAnnotation.setData(annotation.getData());
rawAnnotation.setDescription(annotation.getDescription());
rawAnnotation.setUserId(user);
rawAnnotation.setModifyDate(new Date());


// store in DB
DALConfig.getImageProvider().InsertRawAnnotation(rawAnnotation);

// insert further annotations...
DALConfig.getImageProvider().close();

Dear @zsalam,

looks all fine so far. I guess your DALConfig.getImageProvider() returns something else that the ImageProviderLocal.

Can you please log
DALConfig.isLocalImageProvider();
and check if it’s true?
And if not, call
DALConfig.switchLocalRemoteImageProvider();
to enable the local image provider? (call it before storing the annotation).

Regards,
Manuel

1 Like

Dear @mstritt,

Thankyou for the reply. I checked and DALConfig.getImageProvider() returns true, But still there is no annotation.

The log for ImageAnnotation object is

ImageAnnotation [hash=-1047088631, shape=Class: ROI Color:(255,0,255) IncExclMode:0, color=-256, subType=ROI, group=1, rawAnnotationId=0, rawDataFileId=0, rawAnnotationType=0, description=ROI, userId=, modifyDate=Mon Nov 30 18:43:16 2020]

The log for RawAnnotation object is

RDF:4 | Type:2 | Description:ROI | ModifyDate:Mon Nov 30 18:43:16  2020 | User:omero

Regards,
zsalam