This is a weird behavior. Up to ~20 images,
linkAnnotation.m with multiple
parentIds works just fine, and then the error happens. All the images that had been already linked with MapAnnotation across datasets and projects ended up having the same MapAnnotation object that was linked last and its ID is 1.
This is the modification of
linkAnnotation- Code: Select all
for i = 1:numel(parent)
% Create object annotation link
context = java.util.HashMap;
group = parent(i).getDetails().getGroup().getId().getValue();
context.put('omero.group', java.lang.String(num2str(group)));
link = objectType.annotationLink();
link.setParent(parent(i))
link.setChild(annotation);
link = session.getUpdateService().saveAndReturnObject(link, context);
end
This also ended up in the same problem.
- Code: Select all
for i = 1:numel(parentId)
% Get the parent object
if isnumeric(parentId(i))
parent = getObjects(session, parentType, parentId(i));
assert(~isempty(parent), 'No %s with id %g found', parentType, parentId(i));
else
parent = parentId(i);
end
% Create object annotation link
context = java.util.HashMap;
group = parent.getDetails().getGroup().getId().getValue();
context.put('omero.group', java.lang.String(num2str(group)));
link = objectType.annotationLink();
link.setParent(parent)
link.setChild(annotation);
link = session.getUpdateService().saveAndReturnObject(link, context);
end
Using the original code (
https://github.com/openmicroscopy/openm ... tion.m#L46), even the following caused the same problem.
- Code: Select all
imgIDs = [363:370];
for i = 1:8
link1 = linkAnnotation(session,ma1,'image',imgIDs(i))
end
So
linkAnnotion.m does not seem working properly. There may be a serious problem here.
I used
unlinkAnnotations.m of mine to undo the horrible changes.
Then I thought .... why the ID being 1? It's because when I preparing MapAnnotationI object based on Excel file using
omero_xlsIHC2MapAnnotation above, I don't assign new ID. The MapAnnotationI object
ma1 probably always has ID of 1. And this can be causing a problem.
I thought it's good enough to just instantiate MapAnnotationI object, so I simply the called constructor. I assumed that the server can assign and overwrite a new ID, but maybe not. Do we need to assign unique ID before linking to an image? How do we know what ID is currently available?
public void setId(Long id)
usually unneeded. Ids are managed by the backend.
http://javadoc.scijava.org/OMERO/ome/mo ... lang.Long-- Code: Select all
ma = MapAnnotationI(int64(1),true);