forked from mporter-gre/mtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createImage.m
63 lines (55 loc) · 2.45 KB
/
createImage.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
function [newImage, newPixels] = createImage(session, sizeX, sizeY, numZ, numC, numT, pixelsType, dimensionOrder, imageName, datasetId)
iUpdate = session.getUpdateService();
dimOrder = omero.model.DimensionOrderI;
dimOrder.setValue(omero.rtypes.rstring(dimensionOrder)); %Default should be 'XYZCT'
newDate = java.util.Date;
timeStamp = omero.rtypes.rtime(newDate.getTime * .001);
newImage = omero.model.ImageI;
newPixels = omero.model.PixelsI;
newImage.setName(omero.rtypes.rstring(imageName));
newImage.setDescription(omero.rtypes.rstring('Created using omeroJava'));
newImage.setAcquisitionDate(timeStamp);
omeroPixelsType = omero.model.PixelsTypeI;
omeroPixelsType.setValue((omero.rtypes.rstring(pixelsType)));
newPixels.setPixelsType(omeroPixelsType);
newPixels.setSizeX(omero.rtypes.rint(sizeX));
newPixels.setSizeY(omero.rtypes.rint(sizeY));
newPixels.setSizeZ(omero.rtypes.rint(numZ));
newPixels.setSizeC(omero.rtypes.rint(numC));
newPixels.setSizeT(omero.rtypes.rint(numT));
newPixels.setSha1(omero.rtypes.rstring('Pending...'));
newPixels.setDimensionOrder(dimOrder);
for thisC = 1:numC
channel = omero.model.ChannelI;
logicalChannel = omero.model.LogicalChannelI;
channel.setLogicalChannel(logicalChannel);
statsInfo = omero.model.StatsInfoI;
switch pixelsType
case 'bit'
statsInfo.setGlobalMin(omero.rtypes.rdouble(0));
statsInfo.setGlobalMax(omero.rtypes.rdouble(1));
case 'uint8'
statsInfo.setGlobalMin(omero.rtypes.rdouble(0));
statsInfo.setGlobalMax(omero.rtypes.rdouble(255));
case 'uint16'
statsInfo.setGlobalMin(omero.rtypes.rdouble(0));
statsInfo.setGlobalMax(omero.rtypes.rdouble(65535));
case 'uint32'
statsInfo.setGlobalMin(omero.rtypes.rdouble(0));
statsInfo.setGlobalMax(omero.rtypes.rdouble((2^32)-1));
case 'uint64'
statsInfo.setGlobalMin(omero.rtypes.rdouble(0));
statsInfo.setGlobalMax(omero.rtypes.rdouble((2^64)-1));
end
channel.setStatsInfo(statsInfo);
newPixels.addChannel(channel);
end
newImage.addPixels(newPixels);
newImage = iUpdate.saveAndReturnObject(newImage);
newImageId = newImage.getId.getValue;
newPixels = newImage.getPrimaryPixels;
newPixelsId = newPixels.getId.getValue;
newLink = omero.model.DatasetImageLinkI();
newLink.setParent(omero.model.DatasetI(datasetId, false));
newLink.setChild(omero.model.ImageI(newImageId, false));
iUpdate.saveObject(newLink);