ome / omero-matlab

Toolbox for accessing OMERO from MATLAB
GNU General Public License v2.0
0 stars 6 forks source link

update map annotation #17

Closed jburel closed 5 years ago

jburel commented 5 years ago

Added updateMapAnnotation MATLAB function which allows you to change the content of a MapAnnotation object in OMERO server while keeping the ID of the object.

function ma = updateMapAnnotation(session, ma, keyvalue, varargin)
% updateMapAnnotation will update the content (key-value pairs) of
% MapAnnotation ma while maintaining its ID.
%
% SYNTAX
% ma = updateMapAnnotation(session, ma, keyvalue)
% ma = updateMapAnnotation(____,'Param',value)
%
% INPUT ARGUMENTS
% session     omero.api.ServiceFactoryPrxHelper object
%
% ma          MapAnnotationI object
%
% keyvalue    cell array of characters | string array
%             The number of columns must be 2. The first colum is for keys
%             and the second column is for values.
%
% OPTIONAL PARA<ETER/VALUE PAIRS
% 'namespace' char
%             Namespace for the MapAnnotation. If you specify this, the
%             value of 'iseditable' will be ignored.
%
% 'description'
%             char
%             Description for the MapAnnotation. 
%
% 'group'     a positive integer
%             group ID
%
% 'iseditable' 
%             false (default) | true | 0 | 1 
%             If true or 1, MapAnnotation (Key-Value Pairs) will
%             be editable via GUI (OMERO.web or OMERO.insight). If you
%             specify 'namespace', 'iseditable' will be ignored.
%
%
% OUTPUT ARGUMENTS
% ma          MapAnnotationI object
%
%
% Written by Kouichi C. Nakamura Ph.D.
% MRC Brain Network Dynamics Unit
% University of Oxford
% kouichi.c.nakamura@gmail.com
% 05-Dec-2018 18:23:13
%
% See also
% writeMapAnnotation, strToMapAnnotation, mapAnnotationToCellstr

Testing this PR

  1. required setup: You need an image with MapAnnotation on OMERO server

  2. actions to perform.

session = client.createSession(user, password);
ma1 = getObjectAnnotations(session, 'map', 'image', imageID)
s = string(mapAnnotationToCellstr(ma1))
s_ = ["New key","new value";s]
ma2 = updateMapAnnotation(session, ma1, s_, 'iseditable',true)

% check the MapAnnotation form GUI now
% Confirm that it is editable.

ma3 = getObjectAnnotations(session, 'map', 'image', imageID)
s = string(mapAnnotationToCellstr(ma3))
s_ = ["New key 2","new value 2";s]
ma4 = updateMapAnnotation(session, ma3, s_, 'iseditable',false)

% check the MapAnnotation form GUI now
% Confirm that it is editable.

You can find mapAnnotationToCellstr from here

  1. expected observations

Related reading

Link to cards, tickets, other PRs:

Originally included in https://github.com/openmicroscopy/openmicroscopy/pull/5925

dominikl commented 5 years ago

👍 Tested with Matlab 2019a, works like described.