-
Notifications
You must be signed in to change notification settings - Fork 5
/
macroWorkshop.html
419 lines (347 loc) · 27.1 KB
/
macroWorkshop.html
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>ImageJ macro workshop</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/cci.css">
<link href="https://fonts.googleapis.com/css?family=Poppins" rel="stylesheet">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<!-- Header logo -->
<!--img style="position:fixed;top:1em;right:1em;" src="img/logo_cci.png" width="15%"-->
<!-- Slide Title -->
<header style="position: absolute;top: 1em; left: 1em; z-index:10;"></header>
<div class="slides">
<section data-menu-title="Title">
<h2>Assembling a ImageJ macro</h2>
<h4>Erick Martins Ratamero (he/him)</h4>
</section>
<section data-menu-title="Intro" class="future" style="top: 224px; display: block;" hidden="" aria-hidden="true">
<h2>
<b>Acknowledgements</b>
</h2>
<ul>
<li>Some material from <a href="https://imagej.net/Introduction_into_Macro_Programming">https://imagej.net/Introduction_into_Macro_Programming</a></li>
</ul>
</section>
<section data-state="python" class="future" style="top: 194px; display: block;" hidden="" aria-hidden="true">
<h2>Why macros?</h2>
<ul>
<li>Automation: do the same thing many times over</li>
<li>Reproducibility: do exactly the same thing every time, show the world what you've done</li>
<li>Sharing: let someone else do exactly the same analysis as you</li>
<li>Extension: do things Fiji cannot do by default</li>
</ul>
</section>
<section data-menu-title="Objective" class="future" style="top: 149.5px; display: none;" hidden="" aria-hidden="true">
<h2>"My first proper macro"</h2>
<h3>Objective: apply a simple analysis pipeline over a set of images</h3>
<ul>
<li>Download our <a href="./material/data_session6.zip">test data</a> to your desktop.</li>
<li>Unzip (right click and "Extract All") and rename the folder to <code>Input</code></li>
<li>Make another folder on the desktop called <code>Output</code></li>
<li>Find the ImageJ macro template "Process_Folder"<br><code>[File > New > Script...]</code><br><code>[Templates > ImageJ 1.x > Batch > Process Folder (IJ1 macro)]</code></li>
</ul>
</section>
<section data-state="python" class="future" style="top: 60px; display: none;" hidden="" aria-hidden="true">
<h2>Process_Folder</h2>
<p><code>[Templates > ImageJ 1.x > Batch > Process Folder (IJ1 macro)]</code> </p>
<pre><code data-trim="" data-noescape="" class="hljs stata"><span class="hljs-comment">/*
* Macro template to process multiple images in a folder
*/</span>
#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Input directory"</span>, style = <span class="hljs-string">"directory"</span>) <span class="hljs-keyword">input</span>
#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Output directory"</span>, style = <span class="hljs-string">"directory"</span>) output
#@ String (<span class="hljs-keyword">label</span> = <span class="hljs-string">"File suffix"</span>, value = <span class="hljs-string">".tif"</span>) suffix
<span class="hljs-comment">// See also Process_Folder.py for a version of this code</span>
<span class="hljs-comment">// in the Python scripting language.</span>
processFolder(<span class="hljs-keyword">input</span>);
<span class="hljs-comment">// function to scan folders/subfolders/files to find files with correct suffix</span>
function processFolder(<span class="hljs-keyword">input</span>) {
<span class="hljs-keyword">list</span> = getFileList(<span class="hljs-keyword">input</span>);
<span class="hljs-keyword">list</span> = Array.<span class="hljs-keyword">sort</span>(<span class="hljs-keyword">list</span>);
<span class="hljs-keyword">for</span> (i = 0; i < <span class="hljs-keyword">list</span>.length; i++) {
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">File</span>.isDirectory(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]))
processFolder(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]);
<span class="hljs-keyword">if</span>(endsWith(<span class="hljs-keyword">list</span>[i], suffix))
processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">list</span>[i]);
}
}
function processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">file</span>) {
<span class="hljs-comment">// Do the processing here by adding your own code.</span>
<span class="hljs-comment">// Leave the print statements until things work, then remove them.</span>
<span class="hljs-keyword">print</span>(<span class="hljs-string">"Processing: "</span> + <span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">file</span>);
<span class="hljs-keyword">print</span>(<span class="hljs-string">"Saving to: "</span> + output);
}</code></pre>
</section>
<section data-state="python" class="future" style="top: 86px; display: none;" hidden="" aria-hidden="true">
<h2>Hints</h2>
<ul>
<li>Use each macro to make the next one.</li>
<li>Remember the macro recorder.</li>
<li>The list of <a href="https://imagej.nih.gov/ij/developer/macro/functions.html">all built-in functions</a> is EXTREMELY useful!</li>
</ul>
</section>
<section data-menu-title="Task 1" class="future" style="top: 250px; display: none;" hidden="" aria-hidden="true">
<h2>Task 1- Create a macro that:</h2>
<ol>
<li>Prints the image name of every image to a log window.</li>
</ol>
<p>
(Hint: What do the variables input, output, file and file.separator mean?)
</p>
</section>
<section data-menu-title="Task 2" class="future" style="top: 234px; display: none;" hidden="" aria-hidden="true">
<h2>Task 2- Create a macro that:</h2>
<ol>
<li>Opens every image, prints how many slices there are in the image and then closes the image.</li>
</ol>
<p>i.e. you shouldn't have all of the image open at the end</p>
</section>
<section data-menu-title="Task 3" class="future" style="top: 239px; display: none;" hidden="" aria-hidden="true">
<h2>Task 3- Create a macro that:</h2>
<ol>
<li>Opens every image, prints how many slices there are in the image...</li>
<li>duplicates the first slice</li>
<li>then saves this as a separate image (with a suitable filename).</li>
<li>Closes all the images.</li>
</ol>
</section>
<section data-menu-title="Task 4" class="future" style="top: 223.5px; display: none;" hidden="" aria-hidden="true">
<h2>Task 4- Create a macro that:</h2>
<ol>
<li>Opens every image, prints how many slices there are in the image, then...</li>
<li>Sets the slice to 5, duplicates this frame, </li>
<li>performs background subtraction then saves this as a separate image (with a suitable filename).</li>
<li>Closes all the images.</li>
</ol>
</section>
<section data-menu-title="Task 5" class="future" style="top: 239px; display: none;" hidden="" aria-hidden="true">
<h2>Task 5- Create a macro that:</h2>
<ol>
<li>Opens every image, prints how many slices there are in the image, then...</li>
<li>Loops through every individual slice of the image, subtracts the background and saves each as new image.</li>
<li>Closes all the images.</li>
</ol>
</section>
<section data-menu-title="Extension task 6" class="future" style="top: 208.5px; display: none;" hidden="" aria-hidden="true">
<h2>Extension task 6- Create a macro that:</h2>
<ol>
<li>Opens every image, prints how many slices there are in the image, then...</li>
<li>Loops through every individual slice of the image and saves each as new image.</li>
<li>Does a Z projection between slices 3 and 7 and measures the "mean gray value" of this projection.</li>
<li>Closes all the images and then saves the results table as a .csv file.</li>
</ol>
</section>
<section data-menu-title="Solution 1" class="future" style="top: 112px; display: none;" hidden="" aria-hidden="true">
<h2>Solution 1:</h2>
<pre><code data-trim="" data-noescape="" class="hljs stata">#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Input directory"</span>, style = <span class="hljs-string">"directory"</span>) <span class="hljs-keyword">input</span>
#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Output directory"</span>, style = <span class="hljs-string">"directory"</span>) output
#@ String (<span class="hljs-keyword">label</span> = <span class="hljs-string">"File suffix"</span>, value = <span class="hljs-string">".tif"</span>) suffix
processFolder(<span class="hljs-keyword">input</span>);
<span class="hljs-comment">// function to scan folders/subfolders/files to find files with correct suffix</span>
function processFolder(<span class="hljs-keyword">input</span>) {
<span class="hljs-keyword">list</span> = getFileList(<span class="hljs-keyword">input</span>);
<span class="hljs-keyword">list</span> = Array.<span class="hljs-keyword">sort</span>(<span class="hljs-keyword">list</span>);
<span class="hljs-keyword">for</span> (i = 0; i < <span class="hljs-keyword">list</span>.length; i++) {
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">File</span>.isDirectory(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]))
processFolder(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]);
<span class="hljs-keyword">if</span>(endsWith(<span class="hljs-keyword">list</span>[i], suffix))
processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">list</span>[i]);
}
}
function processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">file</span>) {
<span class="hljs-keyword">print</span>(<span class="hljs-keyword">file</span>);
<span class="hljs-comment">// or print(input+ File.separator + file);</span>
}</code></pre>
</section>
<section data-menu-title="Solution 2" class="future" style="top: 97px; display: none;" hidden="" aria-hidden="true">
<h2>Solution 2:</h2>
<pre><code data-trim="" data-noescape="" class="hljs stata">#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Input directory"</span>, style = <span class="hljs-string">"directory"</span>) <span class="hljs-keyword">input</span>
#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Output directory"</span>, style = <span class="hljs-string">"directory"</span>) output
#@ String (<span class="hljs-keyword">label</span> = <span class="hljs-string">"File suffix"</span>, value = <span class="hljs-string">".tif"</span>) suffix
processFolder(<span class="hljs-keyword">input</span>);
<span class="hljs-comment">// function to scan folders/subfolders/files to find files with correct suffix</span>
function processFolder(<span class="hljs-keyword">input</span>) {
<span class="hljs-keyword">list</span> = getFileList(<span class="hljs-keyword">input</span>);
<span class="hljs-keyword">list</span> = Array.<span class="hljs-keyword">sort</span>(<span class="hljs-keyword">list</span>);
<span class="hljs-keyword">for</span> (i = 0; i < <span class="hljs-keyword">list</span>.length; i++) {
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">File</span>.isDirectory(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]))
processFolder(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]);
<span class="hljs-keyword">if</span>(endsWith(<span class="hljs-keyword">list</span>[i], suffix))
processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">list</span>[i]);
}
}
function processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">file</span>) {
<span class="hljs-keyword">open</span>(<span class="hljs-keyword">input</span>+<span class="hljs-keyword">File</span>.separator+<span class="hljs-keyword">file</span>);
<span class="hljs-keyword">print</span>(nSlices);
<span class="hljs-keyword">close</span>();
}</code></pre>
</section>
<section data-menu-title="Solution 3" class="future" style="top: 85.5px; display: none;" hidden="" aria-hidden="true">
<h2>Solution 3:</h2>
<pre><code data-trim="" data-noescape="" class="hljs stata">#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Input directory"</span>, style = <span class="hljs-string">"directory"</span>) <span class="hljs-keyword">input</span>
#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Output directory"</span>, style = <span class="hljs-string">"directory"</span>) output
#@ String (<span class="hljs-keyword">label</span> = <span class="hljs-string">"File suffix"</span>, value = <span class="hljs-string">".tif"</span>) suffix
processFolder(<span class="hljs-keyword">input</span>);
<span class="hljs-comment">// function to scan folders/subfolders/files to find files with correct suffix</span>
function processFolder(<span class="hljs-keyword">input</span>) {
<span class="hljs-keyword">list</span> = getFileList(<span class="hljs-keyword">input</span>);
<span class="hljs-keyword">list</span> = Array.<span class="hljs-keyword">sort</span>(<span class="hljs-keyword">list</span>);
<span class="hljs-keyword">for</span> (i = 0; i < <span class="hljs-keyword">list</span>.length; i++) {
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">File</span>.isDirectory(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]))
processFolder(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]);
<span class="hljs-keyword">if</span>(endsWith(<span class="hljs-keyword">list</span>[i], suffix))
processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">list</span>[i]);
}
}
function processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">file</span>) {
<span class="hljs-keyword">open</span>(<span class="hljs-keyword">input</span>+<span class="hljs-string">"/"</span>+<span class="hljs-keyword">file</span>);
<span class="hljs-keyword">print</span>(nSlices);
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Duplicate..."</span>, <span class="hljs-string">" "</span>);
saveAs(<span class="hljs-string">"Tiff"</span>, output+<span class="hljs-keyword">File</span>.separator+<span class="hljs-keyword">File</span>.nameWithoutExtension+<span class="hljs-string">"_slice1.tiff"</span>);
<span class="hljs-keyword">close</span>();
<span class="hljs-keyword">close</span>();
<span class="hljs-comment">//or close("*")</span>
}</code></pre>
</section>
<section data-menu-title="Solution 4" class="future" style="top: 85.5px; display: none;" hidden="" aria-hidden="true">
<h2>Solution 4:</h2>
<pre><code data-trim="" data-noescape="" class="hljs stata">#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Input directory"</span>, style = <span class="hljs-string">"directory"</span>) <span class="hljs-keyword">input</span>
#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Output directory"</span>, style = <span class="hljs-string">"directory"</span>) output
#@ String (<span class="hljs-keyword">label</span> = <span class="hljs-string">"File suffix"</span>, value = <span class="hljs-string">".tif"</span>) suffix
processFolder(<span class="hljs-keyword">input</span>);
<span class="hljs-comment">// function to scan folders/subfolders/files to find files with correct suffix</span>
function processFolder(<span class="hljs-keyword">input</span>) {
<span class="hljs-keyword">list</span> = getFileList(<span class="hljs-keyword">input</span>);
<span class="hljs-keyword">list</span> = Array.<span class="hljs-keyword">sort</span>(<span class="hljs-keyword">list</span>);
<span class="hljs-keyword">for</span> (i = 0; i < <span class="hljs-keyword">list</span>.length; i++) {
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">File</span>.isDirectory(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]))
processFolder(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]);
<span class="hljs-keyword">if</span>(endsWith(<span class="hljs-keyword">list</span>[i], suffix))
processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">list</span>[i]);
}
}
function processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">file</span>) {
<span class="hljs-keyword">open</span>(<span class="hljs-keyword">input</span>+<span class="hljs-string">"/"</span>+<span class="hljs-keyword">file</span>);
<span class="hljs-keyword">print</span>(nSlices);
setSlice(5);
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Duplicate..."</span>, <span class="hljs-string">" "</span>);
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Subtract Background..."</span>, <span class="hljs-string">"rolling=20"</span>);
saveAs(<span class="hljs-string">"tiff"</span>, output+<span class="hljs-keyword">File</span>.separator+<span class="hljs-keyword">File</span>.nameWithoutExtension+<span class="hljs-string">"_slice5"</span>+<span class="hljs-string">".tiff"</span>);
<span class="hljs-keyword">close</span>();
<span class="hljs-keyword">close</span>();
}</code></pre>
</section>
<section data-menu-title="Solution 5" class="future" style="top: 85.5px; display: none;" hidden="" aria-hidden="true">
<h2>Solution 5:</h2>
<pre><code data-trim="" data-noescape="" class="hljs stata">#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Input directory"</span>, style = <span class="hljs-string">"directory"</span>) <span class="hljs-keyword">input</span>
#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Output directory"</span>, style = <span class="hljs-string">"directory"</span>) output
#@ String (<span class="hljs-keyword">label</span> = <span class="hljs-string">"File suffix"</span>, value = <span class="hljs-string">".tif"</span>) suffix
processFolder(<span class="hljs-keyword">input</span>);
<span class="hljs-comment">// function to scan folders/subfolders/files to find files with correct suffix</span>
function processFolder(<span class="hljs-keyword">input</span>) {
<span class="hljs-keyword">list</span> = getFileList(<span class="hljs-keyword">input</span>);
<span class="hljs-keyword">list</span> = Array.<span class="hljs-keyword">sort</span>(<span class="hljs-keyword">list</span>);
<span class="hljs-keyword">for</span> (i = 0; i < <span class="hljs-keyword">list</span>.length; i++) {
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">File</span>.isDirectory(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]))
processFolder(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]);
<span class="hljs-keyword">if</span>(endsWith(<span class="hljs-keyword">list</span>[i], suffix))
processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">list</span>[i]);
}
}
function processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">file</span>) {
<span class="hljs-keyword">open</span>(<span class="hljs-keyword">input</span>+<span class="hljs-string">"/"</span>+<span class="hljs-keyword">file</span>);
<span class="hljs-keyword">print</span>(nSlices);
<span class="hljs-keyword">for</span> (i=1; i<=nSlices; i++){
setSlice(i);
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Duplicate..."</span>, <span class="hljs-string">" "</span>);
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Subtract Background..."</span>, <span class="hljs-string">"rolling=20"</span>);
saveAs(<span class="hljs-string">"tiff"</span>, output+<span class="hljs-keyword">File</span>.separator+<span class="hljs-keyword">File</span>.nameWithoutExtension+<span class="hljs-string">"_slice"</span>+i+<span class="hljs-string">".tiff"</span>);
<span class="hljs-keyword">close</span>();
}
<span class="hljs-keyword">close</span>();
}</code></pre>
</section>
<section data-menu-title="Solution 6" class="future" style="top: 85.5px; display: none;" hidden="" aria-hidden="true">
<h2>Solution 6:</h2>
<pre><code data-trim="" data-noescape="" class="hljs stata">#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Input directory"</span>, style = <span class="hljs-string">"directory"</span>) <span class="hljs-keyword">input</span>
#@ <span class="hljs-keyword">File</span> (<span class="hljs-keyword">label</span> = <span class="hljs-string">"Output directory"</span>, style = <span class="hljs-string">"directory"</span>) output
#@ String (<span class="hljs-keyword">label</span> = <span class="hljs-string">"File suffix"</span>, value = <span class="hljs-string">".tif"</span>) suffix
processFolder(<span class="hljs-keyword">input</span>);
<span class="hljs-comment">// function to scan folders/subfolders/files to find files with correct suffix</span>
function processFolder(<span class="hljs-keyword">input</span>) {
<span class="hljs-keyword">list</span> = getFileList(<span class="hljs-keyword">input</span>);
<span class="hljs-keyword">list</span> = Array.<span class="hljs-keyword">sort</span>(<span class="hljs-keyword">list</span>);
<span class="hljs-keyword">for</span> (i = 0; i < <span class="hljs-keyword">list</span>.length; i++) {
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">File</span>.isDirectory(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]))
processFolder(<span class="hljs-keyword">input</span> + <span class="hljs-keyword">File</span>.separator + <span class="hljs-keyword">list</span>[i]);
<span class="hljs-keyword">if</span>(endsWith(<span class="hljs-keyword">list</span>[i], suffix))
processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">list</span>[i]);
}
}
function processFile(<span class="hljs-keyword">input</span>, output, <span class="hljs-keyword">file</span>) {
<span class="hljs-keyword">open</span>(<span class="hljs-keyword">input</span>+<span class="hljs-string">"/"</span>+<span class="hljs-keyword">file</span>);
<span class="hljs-keyword">print</span>(nSlices);
<span class="hljs-keyword">for</span> (i=1; i<=nSlices; i++){
setSlice(i);
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Duplicate..."</span>, <span class="hljs-string">" "</span>);
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Subtract Background..."</span>, <span class="hljs-string">"rolling=20"</span>);
saveAs(<span class="hljs-string">"tiff"</span>, output+<span class="hljs-keyword">File</span>.separator+<span class="hljs-keyword">File</span>.nameWithoutExtension+<span class="hljs-string">"_slice"</span>+i+<span class="hljs-string">".tiff"</span>);
<span class="hljs-keyword">close</span>();
}
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Z Project..."</span>, <span class="hljs-string">"start=3 stop=7 projection=[Average Intensity]"</span>);
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Set Measurements..."</span>, <span class="hljs-string">"mean redirect=None decimal=7"</span>);
<span class="hljs-keyword">run</span>(<span class="hljs-string">"Measure"</span>);
saveAs(<span class="hljs-string">"tiff"</span>, output+<span class="hljs-keyword">File</span>.separator+<span class="hljs-keyword">File</span>.nameWithoutExtension+<span class="hljs-string">"_projection_BackSubtract.tiff"</span>);
<span class="hljs-keyword">close</span>(<span class="hljs-string">"*"</span>);
}
<span class="hljs-comment">// Note this is outside the processFile function </span>
saveAs(<span class="hljs-string">"Results"</span>, output+<span class="hljs-keyword">File</span>.separator+<span class="hljs-string">"MeanIntensity.csv"</span>);</code></pre>
</section>
</div>
<!-- Footer -->
<img style="position:fixed;bottom:1em;right:1em;" src="img/jax.jpg" width="20%">
<!--img style="position:fixed;bottom:1em;left:1em;" src="img/logo_tw.png" width="20%"-->
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
controls: false,
slideNumber: true, //-- Added for development
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/menu/menu.js' }
],
menu: {
hideMissingTitles: true,
themes: false,
transitions: false,
//markers: true,
numbers: true,
openButton: false,
titleSelector: 'span.menu-title'
}
});
</script>
</body>
</html>