Fiji Macros and ActionBar

Course 4 –
Advanced Image Analysis & Processing
April 2015
1
From Survey Results
• Heterogenous audience
• Day 1 : ImageJ -Macro : language, batch, use of
ActionBar.
• Day2 : ImageJ - Plugins : install, writing, use of
Eclipse.
• Day 3 : Matlab & CellProfiler, how to use them for
image analysis, comparison to ImageJ
2
Fiji
3
Fiji
Plugins
http://fiji.sc/Fiji
4
Get Action Bar Plugin
5
Add Action Bar Plugin
Fiji.app\plugins
Paste :
6
Add Action Bar Plugin
Fiji.app\plugins
Paste :
7
My first Action Bar
8
My first Action Bar
Fiji.app\plugins\ActionBar
9
My first Action Bar
Refresh Menus
10
My first Action Bar
Fiji.app\plugins\ActionBar
11
My first Action Bar
Create
12
My first Action Bar
Paste
13
Change
File
Format
Colored text
easier to debug
14
Not Saved
15
Save Your Action Bar
My_Action_Bar.ijm
16
Action Bar
basic functions
…
17
Action Bar
basic functions
…
18
Action Bar
change Icon
New icon file name
19
Action Bar
change Icon
20
Action Bar
change Label
label
21
Action Bar
change Label
label
22
Action when clic on button
Clic
Action
to perform
//using macro functions
23
Macro Functions
Website
Recorder
OR
24
Macro Functions
Website
Recorder
OR
25
Record Functions
26
Record Functions
Macro language
RGB
27
Record Functions
Action
to perform
// start of : line
//using macro functions
28
end
start
of the button line
29
Use a macro :
on an image
DAPI
EdU-488
H2B-RFP
Create a macro to
analyse Red and Green
staining.
Create a nuclei mask from DAPI
Get for each nuclei :
- the «Area»
and
- the «Intensitiy» of the Red and
Green Channel
You have 30min!
30
How to write a macro
Template: tiny.cc\adip-1stStepMacro_blank
31
How to write a macro
Solution : tiny.cc\adip-1stStepMacro
32
Use a macro :
on a folder
33
Use a macro :
on a folder
Process>Batch>Macro
34
Use a macro
on a folder
Process>Batch>Macro
Necessary to handle the processing of several images
Solution : tiny.cc\adip-2ndStepMacro
35
Use a macro
on a folder
Process>Batch>Macro + GUI for parameters
36
Use a macro
on a folder
Process>Batch>Macro + GUI for parameters
• How to ask user to set/select parameters
Starts with : Dialog.create();
Website
37
Use a macro
on a folder
Process>Batch>Macro + GUI for parameters
Solution : tiny.cc\adip-3rdStepMacro
38
Use a macro
on a folder
Process>Batch>Macro + GUI for parameters
39
Use a macro
on a folder
Process>Batch>Macro + GUI for parameters
How to specify the parameters once and use them for all images ?
40
Use a macro
on a folder
Macro: process image of a folder
• Keep the same Macro
• Modify it so it can process every file in a folder!
• You will need:
– The path of the folder containing images.
– The list of the files.
• You will have to :
– Create a new folder to save images (mask)
– Process every file.
– Save the created mask of every image.
41
Use a macro
on a folder
Macro: process image of a folder
• Keep the same Macro
• Modify it so it can process every file in a folder!
• You will need:
– The path of the folder containing images. getDirectory
– The list of the files. getFileList
• You will have to :
– Create a new folder to save images (mask) …
– Process every file …
– Save the created mask of every image …
42
Use a macro
on a folder
Macro: process image of a folder
…
…
43
Use a macro
on a folder
Macro: process image of a folder
…
What happens if :
there is non-image File within the folder?
…
To prevent issue, we’ll use a function
to control that files are images.
Solution : tiny.cc\adip-4thStepMacro
44
Use a macro
in a Action Bar!
Macro: process image of a folder
We can use our own <macro> code
//using macro functions
45
Use a macro
in a Action Bar!
on 1 image
We can use our own <macro> code adip-1stStepMacro.ijm
Solution : tiny.cc\MyImproved_action_bar_step1.ijm
46
Use a macro
in a Action Bar!
on 1 folder
We can use our own <macro> code adip-4thStepMacro.ijm
…
Solution : tiny.cc\MyImproved_action_bar_step2.ijm
47
Use a macro
in a Action Bar!
on 1 folder
We can use our own <macro> code adip-4thStepMacro.ijm
…
This function can be necessary
for other buttons of the Action Bar
48
Use a macro
in a Action Bar!
codelibrary
<codeLibrary> contains functions that every <button> can access
Which other functions can we add to the <codeLibrary> ?
Solution : tiny.cc\MyImproved_action_bar_step3.ijm
49
Use a macro
in a Action Bar!
codelibrary
the common part when processing
1 image and 1 folder
50
Use a macro
in a Action Bar!
codelibrary
51
Use a macro
in a Action Bar!
codelibrary
Solution : tiny.cc\MyImproved_action_bar_step4.ijm
52
Use a macro
in a Action Bar!
Parameters Windows : function
• We need to:
– Store data (text, numbers…)
– Retrieve these data
53
Use a macro
in a Action Bar!
Parameters Windows : function
Container will be an ImageJ text window
54
Use a macro
in a Action Bar!
Parameters Windows : function
55
Use a macro
in a Action Bar!
Parameters Windows : function
56
Use a macro
in a Action Bar!
Parameters Windows : modify action bar
Retrieve data
Set them first !
Solution : tiny.cc\MyImproved_action_bar_step5-0.ijm
57
Use a macro
in a Action Bar!
Parameters Windows : setData
Set Parameters <button>
Solution : tiny.cc\MyImproved_action_bar_step5-1.ijm
58
Use a macro
in a Action Bar!
Parameters Windows : setData
Use it for the Folder <button>
Solution : tiny.cc\MyImproved_action_bar_step5.ijm
59
That’s all Folks!
Tomorrow : JaaavvaaaAAAArrrgggghhh
60