-
Notifications
You must be signed in to change notification settings - Fork 9
/
getColourIdx.m
44 lines (38 loc) · 1.07 KB
/
getColourIdx.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
function chIdx = getColourIdx(session, theImage, colour)
%Get the index of the channel that is colour 'blue', 'green', 'red',
%'farred'
%Example: chIdx = getColourIdx(imageObj, 'green')
% chIdx = 0
pixServ = session.getPixelsService;
pixels = theImage.getPrimaryPixels;
numC = pixels.getSizeC.getValue;
pixDesc = pixServ.retrievePixDescription(pixels.getId.getValue);
for thisC = 1:numC
ch = pixDesc.getChannel(thisC-1);
chLog = ch.getLogicalChannel;
emWave = chLog.getEmissionWave.getValue;
if strcmpi(colour, 'blue')
if (300 < emWave) && (emWave < 460)
chIdx = thisC-1;
return;
end
end
if strcmpi(colour, 'green')
if (460 < emWave) && (emWave < 570)
chIdx = thisC-1;
return;
end
end
if strcmpi(colour, 'red')
if (570 < emWave) && (emWave < 640)
chIdx = thisC-1;
return;
end
end
if strcmpi(colour, 'farred')
if emWave > 640
chIdx = thisC-1;
return;
end
end
end