How to edit LineData ROIs in OMERO from Java/MATLAB?
Posted: Thu Jan 24, 2019 5:28 pm
Hello again,
I'm trying to edit LineData ROIs in 33 images programmatically using MATLAB. I want to add text and turn them yellow.
Using Java Gateway, I've come close to the end, but could not use saveAndRrturnObject successfully.
rois is ArrayList of many omero.gateway.model.ROIdata objects. In the snippet below, I'm trying to obtain Shape of that LineData ROIs.
bregma =
omero.gateway.model.LineData (id=102625)
roidata =
omero.gateway.model.ROIData (id=102625)
Java error message (excerpt)
Can anybody show me a way forward, please?
Thank you,
Kouichi
I'm trying to edit LineData ROIs in 33 images programmatically using MATLAB. I want to add text and turn them yellow.
Using Java Gateway, I've come close to the end, but could not use saveAndRrturnObject successfully.
rois is ArrayList of many omero.gateway.model.ROIdata objects. In the snippet below, I'm trying to obtain Shape of that LineData ROIs.
- Code: Select all
j = rois.iterator();
k = 0;
ind = zeros(1,2);
while j.hasNext()
k = k + 1;
roi = j.next();
alist = roi.getShapes(0,0);
% Do something
shape = alist.get(0);
if isa(shape,'omero.gateway.model.LineData')
% disp(methods(shape) )
switch shape.getX1()
case 15000
assert(shape.getX2() == 15000)
shape.setText('Bregma') % set new text
disp(k)
ind(1) = k - 1;
end
end
end
bregma = rois.get(ind(1)).getShapes(0,0).get(0)
bregma =
omero.gateway.model.LineData (id=102625)
- Code: Select all
ss1 = bregma.getShapeSettings;
ss1.setStroke(java.awt.Color.YELLOW) % set new stroke color
dm = getGatewayFacility(gateway,'DataManagerFacility'); % https://gist.github.com/kouichi-c-nakamura/1fee6b8b33a227d47854224fa185bb94
ctx = omero.gateway.SecurityContext(user.getGroupId());
roidata = rois.get(ind(1));
roidata =
omero.gateway.model.ROIData (id=102625)
- Code: Select all
dm.saveAndReturnObject(ctx, roidata ) % does not work
Java error message (excerpt)
- Code: Select all
Cannot update the object.omero.OptimisticLockException
serverStackTrace = "ome.conditions.OptimisticLockException: You are not authorized to change the update event for ome.model.roi.Line:Id_102625 from ome.model.meta.Event:Id_26965 to ome.model.meta.Event:Id_22508
You may need to reload the object before continuing.
at ome.security.basic.OmeroInterceptor.managedEvent(OmeroInterceptor.java:1195)
Can anybody show me a way forward, please?
Thank you,
Kouichi