-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunCreateTotalMask.m
More file actions
158 lines (111 loc) · 5.78 KB
/
Copy pathrunCreateTotalMask.m
File metadata and controls
158 lines (111 loc) · 5.78 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
%% add the neededs path for the analysis
clear all
addpath(genpath('\\phhydra\phhydraB\Analysis\users\Liora\Codes\'));
warning('off', 'MATLAB:MKDIR:DirectoryExists');% this supresses warning of existing directory
scriptDir = regexprep(mfilename('fullpath'), '\\\w*$', '');
%% Define mainDirList
topMainDir='W:\Analysis\users\Yonit\Movie_Analysis\Channels\2019_07_11_pos1\'; % main folder of original files for layer separation
mainDirList= { ... % enter in the following line all the movie dirs for cost calculation.
'Stitching\Final\C0\',...
};
for i=1:length(mainDirList),mainInDirList{i}=[topMainDir,mainDirList{i}];end
topAnalysisDir='W:\Analysis\users\Yonit\Movie_Analysis\Channels\'; % main folder for layer separation results
mainAnalysisDirList= { ... % enter in the following line all the output dirs for cost calculation.
'\2019_07_11_pos1\', ...
};
for i=1:length(mainAnalysisDirList),AnalysisDirList{i}=[topAnalysisDir,mainAnalysisDirList{i}];end
%%
toSave=1; % If zero, doesn't save images and doesn't overwrite existing images.
Is2D = 1; % If the image is a 2d projected image
IsLS=0; %1 for Lightsheet, 0 otherwise
IsEndo = 0; %1 for Endo, 0 otherwise
IsLabel = 0; %1 for tissue label, 0 otherwise
IsCaEpi = 0 ; % 1 for Ca strain
calibration = 1.28; % In um/pixel. 1.28 um/pixel for 10x air.
% Comment out the following irrelevant choice for framelist:
framesList = cell(1,length(mainAnalysisDirList));
% framesList = {1:6,1:9}; % Enter specific frame ranges in this format if you
% want to run on particular frames (in this example, 1:6 is for the first
% movie, 1:9 is for the second). If left empty, runs on all frames.
exePath = '%HOMEDRIVE%%HOMEPATH%\\Fiji.app\\ImageJ-win64.exe --headless -macro';
cd (scriptDir)
%% run over each movie folder to create total masks from the raw masks in the folder.
for i=1:length(AnalysisDirList)
% Create analysis folder, and add .txt file indicating path to raw data
mkdir(AnalysisDirList{i});
cd(AnalysisDirList{i});
writeExperimentParametersGUI(AnalysisDirList{i}, 'experiment_details.yml');
fileID = fopen('experiment_path.txt','w');
fprintf(fileID,'%s',topMainDir);
fclose(fileID);
mainAnalysisDir=[AnalysisDirList{i},'\Display'];
mkdir(mainAnalysisDir);
mainOrigDir=[mainInDirList{i}];
% Create .txt file indicating path to raw data
if (Is2D==0 && IsLS==0 && IsLabel==0 && IsEndo==0 && IsCaEpi==0)
% NEW: RUN IMAGEJ MACRO TO CREATE RAW MASKS
% Arguments for imageJ macro:
% mainAnalysisDir - string
% mainOrigDir - string
system(sprintf('%s %s/cmd_make_raw_mask_from_stack.ijm "%s %s "', exePath, scriptDir, mainAnalysisDir, mainOrigDir));
if length (framesList{i}) == 0 % run on all frames
createMaskMovie (mainAnalysisDir, toSave, calibration);
else % run on frames indicated
createMaskMovie (mainAnalysisDir, toSave, calibration, framesList{i});
end
elseif Is2D==1
% NEW: RUN IMAGEJ MACRO TO CREATE RAW MASKS
% Arguments for imageJ macro:
% mainAnalysisDir - string
% mainOrigDir - string
system(sprintf('%s %s/cmd_make_raw_mask_from_2d.ijm "%s %s "', exePath, scriptDir, mainAnalysisDir, mainOrigDir));
if length (framesList{i}) == 0 % run on all frames
createMaskMovie (mainAnalysisDir, toSave, calibration);
else % run on frames indicated
createMaskMovie (mainAnalysisDir, toSave, calibration, framesList{i});
end
elseif IsLS==1
% NEW: RUN IMAGEJ MACRO TO CREATE RAW MASKS
% Arguments for imageJ macro:
% mainAnalysisDir - string
% mainOrigDir - string
system(sprintf('%s %s/cmd_make_raw_mask_from_stack_lightsheet.ijm "%s %s "', exePath, scriptDir, mainAnalysisDir, mainOrigDir));
if length (framesList{i}) == 0 % run on all frames
createMaskMovie_lightsheet (mainAnalysisDir, toSave, calibration);
else % run on frames indicated
createMaskMovie_lightsheet (mainAnalysisDir, toSave, calibration, framesList{i});
end
elseif IsEndo==1
% NEW: RUN IMAGEJ MACRO TO CREATE RAW MASKS
% Arguments for imageJ macro:
% mainAnalysisDir - string
% mainOrigDir - string
system(sprintf('%s %s/cmd_make_raw_mask_from_stack_endo.ijm "%s %s "', exePath, scriptDir, mainAnalysisDir, mainOrigDir));
if length (framesList{i}) == 0 % run on all frames
createMaskMovie_lightsheet (mainAnalysisDir, toSave, calibration);
else % run on frames indicated
createMaskMovie_lightsheet (mainAnalysisDir, toSave, calibration, framesList{i});
end
elseif IsLabel==1
% NEW: RUN IMAGEJ MACRO TO CREATE RAW MASKS
% Arguments for imageJ macro:
% mainAnalysisDir - string
% mainOrigDir - string
system(sprintf('%s %s/cmd_make_raw_mask_tissue_label.ijm "%s %s "', exePath, scriptDir, mainAnalysisDir, mainOrigDir));
if length (framesList{i}) == 0 % run on all frames
createMaskMovie_label (mainAnalysisDir, toSave, calibration);
else % run on frames indicated
createMaskMovie_label (mainAnalysisDir, toSave, calibration, framesList{i});
end
elseif IsCaEpi==1
% NEW: RUN IMAGEJ MACRO TO CREATE RAW MASKS
% Arguments for imageJ macro:
% mainAnalysisDir - string
% mainOrigDir - string
if length (framesList{i}) == 0 % run on all frames
createMaskMovie_caEpi (mainOrigDir, mainAnalysisDir, toSave, calibration,framesList{i});
else % run on frames indicated
createMaskMovie_caEpi (mainOrigDir, mainAnalysisDir, toSave, calibration, framesList{i});
end
end
end