forked from smshah87/3D-Barcoding-Spots-Code-GIT
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNucleoPix.m
49 lines (30 loc) · 1.18 KB
/
NucleoPix.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
function [nucleolus]= NucleoPix(PathName, imnum, channel, regchan, regist)
fld = pwd;
Miji;
cd(fld);
path_to_fish = ['path=[' PathName '\' num2str(imnum) '.tif]'];
MIJ.run('Open...', path_to_fish);
MIJ.run('Split Channels');
its1 = uint16(MIJ.getImage(['C' num2str(channel) '-' num2str(imnum) '.tif']));
reg = uint16(MIJ.getImage(['C' num2str(regchan) '-' num2str(imnum) '.tif']));
MIJ.run('Close All')
path_to_fish = ['path=[' PathName '\' regist '.tif]'];
MIJ.run('Open...', path_to_fish);
fixed = uint16(MIJ.getCurrentImage);
MIJ.run('Close All')
MIJ.createImage('its1',its1,true)
MIJ.run('Auto Threshold', 'method=Default white stack use_stack_histogram');
its1 = uint16(MIJ.getCurrentImage) >0;
MIJ.run('Close All')
MIJ.exit
[optimizer, metric] = imregconfig('monomodal');
tform = imregtform(reg,fixed,'translation',optimizer,metric);
its1 = imwarp(its1,tform,'OutputView',imref3d(size(fixed)));
nucleomask = bwperim(its1);
fullpath = [PathName '\RoiSet'];
vertex = selfseg(fullpath);
[y,x,z] = ind2sub(size(nucleomask),find(nucleomask == 1));
for i = 1:length(vertex)
include = inpolygon(x,y,vertex(i).x,vertex(i).y);
nucleolus{i} = [x(include) y(include) z(include)];
end