forked from evodevosys/AroSpotFindingSuite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoEvalFISHStacksForAll.m
executable file
·75 lines (66 loc) · 3.63 KB
/
doEvalFISHStacksForAll.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
64
65
66
67
68
69
70
71
72
73
74
75
function doEvalFISHStacksForAll(varargin)
%% ========================================================================
% Name: doEvalFISHStacksForAll.m
% Version: 2.0, 5th July 2012
% Author: Allison Wu
% Command: doEvalFISHStacksForAll(toOverWrite*) *Optional Input
% Description:
% - a wrapper function that do evalFISHStacks on all the segStacks.mat files on the directory.
% - toOverWrite=0 (by default), will skip the SegStacks.mat files
% that already have corresponding wormGassianFit.mat files
% - toOverWrite=1, it will not detect the existence of
% wormGaussianFit.mat files and therefore, overwrites all the
% wormGausianFit.mat files that exist.
%% ========================================================================
if isempty(varargin)
toOverWrite=0;
else
toOverWrite=varargin{1};
end;
WormGaussianFitDir='';% need this here so that the parfor can run. it is overwritten by Aro_parameters but the parfor needs to see it here to know about it
run('Aro_parameters.m');
switch nestedOrFlatDirectoryStructure
case 'flat'
d=dir('**_SegStacks.mat');
for k=1:length(d)
[dye, stackSuffix, wormFitName, ~,~]=parseStackNames(regexprep(d(k).name,'_SegStacks.mat',''));
if ~any(strcmp(dye,{'dapi','trans'}))
if toOverWrite % Will overwrite all the wormGaussianFit.mat files
fprintf('Evaluating the image stack %s ....\n', d(k).name)
evalFISHStacks(d(k).name);
else % detects the existence of wormGaussianFit.mat files and skip the ones already done
if exist(wormFitName,'file')
fprintf('Position %s in %s channel is already evaluated.\n', stackSuffix,dye)
else
fprintf('Evaluating the image stack %s ....\n', d(k).name)
evalFISHStacks(d(k).name);
end
end
end
end
case 'nested'
for iD=1:length(dyesUsed)
d=dir(fullfile(SegStacksDir,dyesUsed{iD},'*_SegStacks.mat'));
parfor k=1:length(d)
[dye, stackSuffix, wormFitName, ~,~]=parseStackNames(regexprep(d(k).name,'_SegStacks.mat',''));
disp(dye);
disp(stackSuffix);
disp(wormFitName);
disp(d(k).name);
if ~any(strcmp(dye,{'dapi','trans'}))
if toOverWrite % Will overwrite all the wormGaussianFit.mat files
fprintf('Evaluating the image stack %s ....\n', d(k).name)
evalFISHStacks(d(k).name);
else % detects the existence of wormGaussianFit.mat files and skip the ones already done
if exist(fullfile(WormGaussianFitDir,dye,wormFitName),'file')
fprintf('Position %s in %s channel is already evaluated.\n', stackSuffix,dye)
else
fprintf('Evaluating the image stack %s ....\n', d(k).name)
evalFISHStacks(d(k).name);
end
end
end
end
end;
end;
end