29
Count Plaques Toolset for ImageJ (Vers. 1.0) - 1 Count Plaques Toolset for ImageJ (Vers. 1.0) Frank Seeber, Robert Koch Institute Berlin, Germany Changing the locations of source (In) and results (Out) folders Concept : images to be processed go into a dedicated In-folder; they are not changed and remeain in this folder. ALL images in the In-folder will be batch-processed with the same settings. In the Out-folder for each image a time-stamped results folder with all intermediates, settings and result table will be created. Running the same macro on the same image(s) will thus NOT override the previous results, allowing comparisons of different settings for the same image(s). Open the file Count_Plaques_Toolbox.txt and edit the loaction of two folders that you create wherever it is convenient and are called "in" and "out" (1). When using a different OS, inactivate the other part using /* and */, as shown ( arrows). Save as text only. Do the same in the files Segmenting_Plaques.txt and plaques_via_wand.txt.

Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 1

Count Plaques Toolset for ImageJ (Vers. 1.0)

Frank Seeber, Robert Koch Institute Berlin, Germany

Changing the locations of source (In) and results (Out)

folders

Concept: images to be processed go into a dedicated In-folder; they

are not changed and remeain in this folder. ALL images in the In-folder

will be batch-processed with the same settings. In the Out-folder for

each image a time-stamped results folder with all intermediates,

settings and result table will be created. Running the same macro on

the same image(s) will thus NOT override the previous results,

allowing comparisons of different settings for the same image(s).

Open the file Count_Plaques_Toolbox.txt and edit the loaction of

two folders that you create wherever it is convenient and are called

"in" and "out" (1). When using a different OS, inactivate the other part

using /* and */, as shown (arrows). Save as text only. Do the same in

the files Segmenting_Plaques.txt and plaques_via_wand.txt.

Page 2: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 2

Installation of CP toolset and related plugins/macros

In order to have the CP toolset being installed in the ImageJ menu bar

place the files "Count_Plaques_Toolbox.txt" and

"WandAutoMeasureTool.txt" into the folder >> macros >> toolsets.

Change the respective location in the "StartupMacros.txt" file

according to your setting so that they start-up at program start.

Example: run("Install...", "install=[C:\\Program Files

(x86)\\ImageJ\\macros\\toolsets\\Count_Plaques_Toolbox.txt]");

The following files need to go into the macros folder:

- Segmenting_Plaques.txt

- plaques_via_wand.txt

- StartupMacros.txt

- Library.txt

Furthermore, the following files need to go into the plugins folder or

subfolders (if not already present):

- action_bar202.jar

(http://imagejdocu.tudor.lu/doku.php?id=plugin:utilities:action_bar:start)

- Dispose_All_Windows.jar

(http://www.neuroscience.ubc.ca/faculty/murphy_software.html)

- Stack_Sorter.jar (http://www.optinav.com/Stack-Sorter.htm)

- Color_Transformer_2.class

(http://www.russellcottrell.com/photo/colorTransformer2.htm)

- plugins >> Segmentation >> level_sets-1.0.1.jar

(http://imagej.net/Level_Sets)

Page 3: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 3

- plugins >> ActionBar >> icons >> Plaques_Tools

Then restart ImageJ. Both icons (arrow heads) should appear.

CP menu bar

(1) White Balance allows to perform some correction of the

background color when artificial light sources and camera settings did

not match and thus did not produce a neutral color.

Make ROIs for stack is used to make circular regions of interest

(ROIs) from e.g. 12-well plates. This eliminates problems when

images of a whole plate are processed in subsequent steps. It

produces single images of single wells.

(2) Count Plaques does what it says - measuring and counting

plaques of images in the In-folder. It is based on manual thresholding

of the plaques.

Segmenting Plugin uses either the "Fast Marching" or the "Level

Sets" algorithm of the Level sets plugin from Erwin Frise

(http://imagej.net/Level_Sets) to measure either the inner or inner &

outer part of positive stained plaques.

Page 4: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 4

Plaques via Wand Tool uses a modified Wand macro that requires

pointing at individual plaques for their measurements. It allows

measurements of inner or inner & outer part of positive stained

plaques.

(3) Open image in other program does what it says - currently it

allows to choose between AffinityPhoto (Mac only) and Photoshop CS

(Windows and Mac).

The other options are self-explanatory.

Open Plaques Tools opens an additional floating menu bar (requires

the ActionBar plugin) with some useful tools/macros that operate on

images upon clicking the respective icon. Mouse-over the icons to

see what they intend to do.

Page 5: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 5

Plaques Tools action bar

Action bar with some usefull tools/macros:

1 reset zoom 13 enhance contrast

2 zoom out 14 montage

3 zoom in 15 de-stack

4 move araound 16 Stack&ROI

5 pencil 17 binary options

6 fill hole 18 make binary

7 hide overlay 19 change gamma

8 show overlay 20 watershed

9 preview Fill holes 21 measure

10 subtract bgrd 22 statistics

11 del outliers 23 closes everything

12 color pixels

Most actions of the tools are self-explanatory.

del outliers: 'Remove outliers' command

color pixels: changes binary pixels to select color

de-stack: 'Stack-to-Image' command

Stack&ROI: makes stack and allows ROI drawing

measure: runs 'Analyze particles" macro

statistics: makes extended statistics on results

Page 6: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 6

White Balance macro - 1

If you don't want the processed image(s) to be transferred to the

In-folder after white-balancing then de-select the first option.

Otherwise the original image(s) will be transferred to a new date- &

time-stamped folder called e.g. WB_Originals_08_22.12.55.

If the image(s) to be processed are NOT in the In-folder then

de-select the second option.

A label can be added to processed image names.

Page 7: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 7

White Balance macro - 2

Follow the displayed message and choose a part that contains the

background color (1). Then click OK.

Page 8: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 8

White Balance macro - 3

When opening the resulting images of the operation they should have

a more neutral-looking background.

Page 9: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 9

Make ROIs for stack macro - 1

This macro is used to make circular Regions Of Interest (ROIs) from

e.g. 12-well plates.

(1) Accordingly, the diameter of an individual well in the image needs

to be specified, taken from a previous run. When future images are

always taken with the exact same camera-to-plate distance, this

needs to be entered only once. Otherwise set to zero.

(2) If only a single ROI is needed, set this option.

(3) If you have saved previous ROIs in a file you can re-use them

(>>Load previous ROI manager).

(4) If the image(s) to be processed are NOT in the In-folder then

de-select the second option.

(5) Make montage arranges all individual ROI images in a single large

image. This might be used for further analysis, potentially eliminating

the batch processing of many images.

The other options are self-explanatory.

Page 10: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 10

Make ROIs for stack macro - 2

To define a ROI follow the instructions in the message. After clicking

"OK" the diameter of the specified circle will then be displayed in the

log window. Note it for future use.

Page 11: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 11

Make ROIs for stack macro - 3

Moving the initial circle (1) around with the mouse lets one choose

more ROIs (2). Don't forget to press "t" on your keyboard or the ROI

Manager window (3) each time. This adds the ROIs to the ROI

Manager (4). Make sure 'Show labels' (5) is checked to see all circles.

When done click OK (6).

The resulting "slices" will be found in the chosen folder.

Page 12: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 12

'Count plaques' macro - 1

Concept: This is a semi-automatic macro that helps to extract

features (in this case plaques) based on manual thresholding. In

general at every step all ImageJ tools can be used as long as in the

Page 13: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 13

open message window OK is NOT clicked! In particular the Plaques

Tools action bar contains useful tools and macro operations to

improve images with a few clicks. However, if something goes wrong

you need to start all over! The original image stays untouched, though,

and you only loose some time.

In the macro version as provided, the initial settings as shown should

lead to reasonable results, so we suggest to start with it. Most settings

are remembered at the next start.

(1) Starting with an color image and depending on the staining intensity

(background) a different color space might be useful. Transformations

are as follows: BW, black-white/8-bit greyscale; RGB All, full color;

RGB Blue, only blue channel from RGB; As is, as is in terms of

previous adjustments, but 8-bit greyscale; AC1C2, HSV_B and

LSHLab, see

http://www.russellcottrell.com/photo/colorTransformer2.htm .

(2) min/max particle size that will be measured

(3) Increase min. circ. in order to prevent non-circular objects to be

measured

(4) Tick when optimal threshold values have been determined in

previous run. Insert values. Makes manual thresholding unnecessary

and speeds up macro, but requires images of similar staining intensity.

(5) Make montage ... : makes a montage from stack of images of

intermediate steps

Dark background: determines whether macro is applied to positive (=

dark background) or negative-stained plaque images

IJ W-balance ...: check when White Balance macro was used for input

image(s)

Time Stamp: remove tick when no time-stamped results folder is

desired

(6) see http://imagejdocu.tudor.lu/doku.php?id=gui:process:binary for

explanation. Just play with the numbers and check results.

(7) Just play with the numbers and check results.

(8) Affects appearance of plaque outlines and numbers in the results

image.

Page 14: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 14

image.

(9) A label can be added to processed image names.

(10) Calculates the following 'plaque statistics': # plaques; mean total

area; SD total area; % SD from mean total area; SE total area; CI95%

area; maximal total area; minimal total area.

(11) We introduced this option so that those of us that use commas

instead of periods as decimal seperator (e.g. like in Germany) will get

the correct number format upon double-clicking the results.xls file in

Excel.

(12) Basic mode: no control over thresholding but might yield useful

results faster.

(13) OK starts the macro.

Page 15: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 15

'Count plaques' macro - 2

Use the "Threshold" tool (1) to adjust the threshold - either outline it or

fill the desired structure so it appears RED. Also indicate whether the

background is dark (negative staining) or not (positive staining) (2).

When done click "APPLY" (3), then "OK" (4).

Page 16: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 16

'Count plaques' macro - 3

In the menu bar double-click the Pencil Tool (1), adjust >>2 pt and

>>color (2). Choose BLACK color to close plaques on image

'copy_to_work_on'. Then use the FILL HOLES tool to see its effect

(3). Choose WHITE color by holding down ALT to separate merged

plaques (arrow) or to delete small ones. Check results by pressing

F1 or the Hide or Show icons in the PlaquesTools bar (4). When all

done make sure you have activated the image 'copy_to_work_on' (5)

Page 17: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 17

before you Click "OK" to continue (6).

If required in the next step use the "Watershed" tool in the Plaques

Tools (7) to separate plaques. If the result is not want you want,

UNDO it with Cmd & Z and separate plaques with the pen tool. When

done click "OK".

Page 18: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 18

'Count plaques' macro - 4

Draw ROI in image 'copy_to_work_on' using the 'freehand' tool (1) or

select all by doing nothing.

To remove large unwanted patches encircle them, press <delete> on

Page 19: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 19

your keyboard, then un-select that region again by clicking in some

free space. When done, click "OK" (2).

'Count plaques' macro - 5

In the Results table check (delete) values that you don't want to be

included in the final table (1). Mark those on 'Drawing of

copy_to_work_on' with the pencil tool (2) (just for documentation

Page 20: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 20

purposes). ImageJ will adjust the line numbering automatically (3)

upon deletion, but 'object #' (1) will remain in accordance with the

drawing. Click "OK" when done (4).

'Count plaques' macro - 6

When the analysis is finished, the results images and table can be

opened by double-clicking in the log window on the respective link (1).

When several images were analyzed in batch mode, the results table

(2) containing ALL values above the image name (3) will be in the last

processed results folder. Double-clicking on the results.xls file then

opens it in Excel.

Page 21: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 21

'Count plaques' macro - 7

For each processed image a Settings file is generated in the results

file that can be used to recall the settings. In particular, the threshold

values can be useful for repeated runs.

Page 22: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 22

Segmenting plugin - 1

(1) Starting with an color image and depending on the staining intensity

(background) a different color space might be useful. Transformations

are as follows: BW, black-white/8-bit greyscale; RGB All, full color;

RGB Blue, only blue channel from RGB; As is, as is in terms of

previous adjustments, but to 8-bit greyscale; AC1C2, HSV_B and

LSHLab, see

http://www.russellcottrell.com/photo/colorTransformer2.htm .

(2) Load previous ROI manager:

Time Stamp: remove tick when no time-stamped results folder is

desired

Fixed in/out directory: uses the respective location of In- and

Page 23: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 23

Out-folder according to your setting

Make montage ... : stack of images of intermediate steps as a

combined montage.

(3) Algorithm to use: either the "Fast Marching" or the "Level Sets"

algorithm of the Level sets plugin from Erwin Frise (click (8) for

detailed description) to measure either the inner & outer (Level Sets)

or inner part only (Fast Marching) of positive-stained plaques.

(4) Calculates the following 'plaque statistics': # plaques; mean total

area; SD total area; % SD from mean total area; SE total area; CI95%

area; maximal total area; minimal total area.

(5) We introduced this option so that those of us that use commas

instead of periods as decimal seperator (e.g. like in Germany) will get

the correct number format upon double-clicking the results.xls file in

Excel.

(6) Affects appearance of plaque outlines and numbers in the results

image. Also, a label can be added to processed image names.

(7) OK starts the macro.

Page 24: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 24

Segmenting plugin - 2 (Level Sets)

Select plaques: Encircle as many plaques as wished using the

'freehand' tool (1). Hold SHIFT to encircle more than one! Press ' t' on

your keyboard or in the ROI Manager to save ROI to ROI Manager

(2). Alternatively, load ROIs from a previous run by opening the ROI

file (ending with .roi) and activating the selection (3). When done click

"OK" to continue (4).

Page 25: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 25

Segmenting plugin - 3

The Level Set Segmentation plugin window appears, asking for

settings.

In this example we haven chosen Level Sets before, so choose (1)

and set (5) to 'inside'. Experiment with the values for (2-4) since they

depend heavily on the image. Start with the intial values set by the

plugin at startup and then try adjusting them as seen here.

For details consult http://imagej.net/Level_Sets.

When done click "OK" to continue (6).

Page 26: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 26

Segmenting plugin - 4

The result should look like this. Check results in image ' Segmentation

of "xyz" ' by pressing F1 or the Hide or Show icons in the

PlaquesTools bar (see 'Count plaques' macro - 3 above, point (4)). To

cose or separate plaques see 'Count plaques' macro - 3. When all

done Click "OK" to continue (1).

The rest is similar to steps 5 & 6 in 'Count plaques' macro.

Page 27: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 27

Plaques via Wand Tool - 1

(1) Dark background: determines whether macro is applied to positive

(= dark background) or negative-stained plaque images

(2) Calculates the following 'plaque statistics': # plaques; mean total

area; SD total area; % SD from mean total area; SE total area; CI95%

area; maximal total area; minimal total area.

(3) We introduced this option so that those of us that use commas

instead of periods as decimal seperator (e.g. like in Germany) will get

the correct number format upon double-clicking the results.xls file in

Excel.

(4) Affects appearance of plaque outlines and numbers in the results

image.

(5) Affects the wand tool operation (for details see

Page 28: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 28

https://imagej.nih.gov/ij/docs/guide/146-19.html)

(6) A label can be added to processed image names.

(7) OK starts the macro.

Plaques via Wand Tool - 2

For positive-stained plaques check the integrity of the rim using the

'Preview Fill holes' tool in the Plaques Tool bar (1) to see which

plaques need work (arrows). Caution: Click only ONCE at a time!

The fill will disappear automatically.

Use the 'pencil' tool to close plaques (2). Use the 'del outliers' tool (3)

to improve image. When done click "OK" to continue (4).

This step is skipped when 'dark background' was selected in step 1.

Page 29: Count Plaques Toolset for ImageJ (Vers. 1.0) · more ROIs ( 2). Don't forget to press "t" on your keyboard or the ROI Manager window ( 3) e ach time. This adds the ROIs to the ROI

Count Plaques Toolset for ImageJ (Vers. 1.0) - 29

Plaques via Wand Tool - 3

Select plaques by pointing into interior of as many plaques as wished

(1) via the Wand Tool from the ImageJ menu bar (2). Results will

appear in the table (3). Delete values only in the next step! If you also

want to measure the total area (incl. the rim) then also point to the

black area of each plaque. Make sure you later know which value in

the results table corresponds to inner and outer area!

When done click "OK" (4).

The rest is similar to steps 5 & 6 in 'Count plaques' macro.