-
Notifications
You must be signed in to change notification settings - Fork 0
/
ROIsFromCMSOTracks.m
55 lines (46 loc) · 1.86 KB
/
ROIsFromCMSOTracks.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
function ROIsFromCMSOTracks(session, imageId, objectsData, linksData)
iUpdate = session.getUpdateService();
imageObj = getImages(session, imageId);
trackSummary = CMSOTrackSummary(objectsData, linksData, imageObj);
numTracks = height(trackSummary);
for thisTrack = 1:numTracks
trackLength = trackSummary.trackLength(thisTrack);
if trackLength < 5
continue;
end
roi = omero.model.RoiI;
TVec = [];
xCoords = [];
yCoords = [];
theseCMSOobjs = linksData.cmso_object_id(linksData.cmso_link_id==thisTrack);
numObj = numel(theseCMSOobjs);
for objCounter = 1:numObj
thisObj = theseCMSOobjs(objCounter);
%nextObj = theseCMSOobjs(objCounter+1);
TVec = [TVec objectsData.cmso_frame_id(objectsData.cmso_object_id==thisObj)];
thisXCoord = round(objectsData.cmso_x_coord(objectsData.cmso_object_id==thisObj));
if isnan(thiXCoord)
thisXCoord = xCoords(end);
end
xCoords = [xCoords thisXCoord];
thisYCoord = round(objectsData.cmso_y_coord(objectsData.cmso_object_id==thisObj));
if isnan(thisYCoord)
thisYCoord = yCoords(end);
end
yCoords = [yCoords thisYCoord];
if sum(ismember(objectsData.Properties.VariableNames, 'cmso_z_coord'))
zCoord = round(objectsData.cmso_z_coord(objectsData.cmso_object_id==thisObj));
else
zCoord = 1;
end
end
for objCounter = 1:numObj
pLine = createPolyline(xCoords, yCoords);
% Indicate on which plane to attach the shape
setShapeCoordinates(pLine, zCoord-1, 0, TVec(objCounter)-1);
% Attach the shapes to the roi, several shapes can be added.
roi.addShape(pLine);
end
roi.setImage(omero.model.ImageI(imageId, false));
roi = iUpdate.saveAndReturnObject(roi);
end