forked from evodevosys/AroSpotFindingSuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_mask_directory.m
executable file
·51 lines (46 loc) · 1.47 KB
/
auto_mask_directory.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
function [] = auto_mask_directory()
run('Aro_parameters.m');
dye = dyesUsed{1};
if ~exist([ImageDir filesep dye], 'dir')
disp('[ERROR] The images have not been trimmed/placed in the proper folders! Please trim first.');
return;
end
current_files = dir([ImageDir filesep dye filesep '*.tif']);
tif_files = {current_files.name};
disp(tif_files);
if isempty(tif_files)
disp('[ERROR] There appear to be no images in the directory for this dye! Please check your image files.');
return;
end
ParSegmentationMaskDir = [SegmentationMaskDir];
ParImageDir = [ImageDir];
PardyesUsed = dyesUsed;
ParBadMaskList = [BadMaskList];
parfor i = 1:numel(tif_files)
name = tif_files{i};
SegmentationMaskDir = ParSegmentationMaskDir;
ImageDir = ParImageDir;
dyesUsed = PardyesUsed;
BadMaskList = ParBadMaskList;
dye = '';
for d = 1:length(dyesUsed)
k = strfind(name, dyesUsed{d});
if ~isempty(k)
dye = dyesUsed{d};
d = length(dyesUsed);
end
end
dye_name_length = length(dye);
mask_name = strcat('Mask_', name(dye_name_length+1:length(name)-4));
isbad = auto_mask([ImageDir filesep dye filesep name], [SegmentationMaskDir filesep mask_name]);
for b = 1:numel(isbad)
if isbad(b)
fileID = fopen(BadMaskList, 'a');
fprintf(fileID, [mask_name '_' num2str(b) '.tif\n']);
fclose(fileID);
disp(['[WARNING] Possible bad mask produced at ' mask_name]);
end
end
end
clear;
return;