forked from ome/omero-user-scripts
-
Notifications
You must be signed in to change notification settings - Fork 5
/
matlab_example.m
65 lines (58 loc) · 2.21 KB
/
matlab_example.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function main
% Example MATLAB script which can be dropped into
% dist/lib/scripts in order to test multiple script
% types.
% Copyright (C) 2013 University of Dundee & Open Microscopy Environment.
% All rights reserved.
%
% 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 2 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, write to the Free Software Foundation, Inc.,
% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
[c, s] = loadOmero();
cleanup = onCleanup(@unloadOmero);
parse = c.getProperty('omero.scripts.parse');
if parse.isEmpty()
% Perform job
% =========================================
fprintf(1, 'Found in1: %s\n', c.getInput('in1'));
fprintf(1, 'Setting out1 to 0...');
c.setOutput('out1', rint(0));
else
% Parsing. See OmeroPy/src/omero/scripts.py
% for the Python implementation.
% =========================================
c.setOutput('omero.scripts.parse', getParams());
% throw(MException('Parsing')); % Return code ignored.
error('Parsing'); % Return code ignored.
end
function params = getParams
% Generate a params object with dummy data
in1 = omero.grid.Param();
in1.optional = false;
in1.prototype = omero.rtypes.rint(0);
in1.description = 'Some arbitrary integer';
out1 = omero.grid.Param();
out1.optional = true;
out1.prototype = omero.rtypes.rint(0);
out1.description = 'Always 0';
params = omero.grid.JobParams();
params.name = 'matlab_example.m';
params.version = '0.0.1';
params.description = 'An example MATLAB script';
params.inputs = java.util.HashMap;
params.inputs.put('in1', in1);
params.outputs = java.util.HashMap;
params.outputs.put('out1', out1);
params.stdoutFormat = 'text/plain';
params.stderrFormat = 'text/plain';
params = omero.rtypes.rinternal(params);