ImageAnalysisWorksheets

Measuring, Stitching and Batch Processing

This worksheet is not assessed. Please work through it at your own pace. You may work on your own, with a partner or in a small group.

There are different sections in the worksheet:

Please donโ€™t skip the Investigate sections and just rush through the Step-by-Step Instructions! The Investigate sections will help you to develop your own image analysis skills. Please ask if anything is unclear, you are unsure about the purpose of anything you are doing or you canโ€™t work out how to do something.

๐Ÿ“ Preparation

Download the associated Data folder

โžก๏ธ Download the Data folder (ZIP)

Download the data before continuing:

  1. Click the link above to grab the ZIP archive.
  2. Unzip it and launch Fiji as described below.

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Open Fiji Find the executable in the downloaded Fiji folder and double-click to launch it.
2 Open the Macro Recorder Navigate to Plugins > Macro > Record.

You may want to save the output of the Recorder are restart it at the end of each section.

Learning Objectives

๐Ÿ“ Making Measurements

In the previous worksheet, we used Analyze Particles to identify and measure objects. There are more ways to make measurements in Fiji.

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Open any image in Fiji Navigate to File > Open and select a file or click and drag an image file into the Fiji toolbar or select an image from File > Open Samples...
2 Select the Line Selection tool Click the Line Selection tool on the Fiji toolbar
Fiji toolbar with line tool button highlighted, fifth tool from left
3 Draw a line anywhere on the image Click anywhere on the image, then move the mouse and click somewhere else on the image. You should see a yellow line stretch between the two points.
4 Plot the intensity profile along the line Go to Analyze > Plot Profile

A plot will appear with Grey Value on the y-axis and Distance on the x-axis. The Distance is the distance along the drawn line. The Grey Value is the intensity of the pixels along the line.

๐Ÿค” Investigate

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Select the Rectangle Selection tool Click the Rectangle Selection tool on the Fiji toolbar
Fiji toolbar with rectangle tool button highlighted, first tool on left
2 Draw a rectangle anywhere on the image Click anywhere on the image, then move the mouse and click somewhere else on the image. You should see a yellow rectangle stretch between the two points.
3 Measure the properties of the rectangle Go to Analyze > Measure or press the m key

A Results window will appear with measurements made based on the rectangular selection. The measurements can be selected by changing the settings in Analyze > Set Measurements (see the CountingAndMeasuringObjects worksheet for more details).

๐Ÿค” Investigate

๐Ÿ—ƒ๏ธ ROI Manager

The ROI (region of interest) manager is used to store and measure selections.

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Make a selection Select any of the selection tools from the Fiji toolbar and click on the image to create a selection
2 Add the selection to the ROI manager Press โ€˜tโ€™ or go to `Edit > Selection > Add to Manager
3 Add some more selections Repeat steps 1 and 2
4 Measure all the selections In the ROI manager window, click More > Multi-measure. Leave the default settings and click OK for the dialog box that appears. A results window will appear with measurements for each selection
5 Save the selections In the ROI manager window, click More > Save.... Select the save location and name the file. Click Save.

๐Ÿค” Investigate

Stitching

Uncredited images in this section are from Dave Masonโ€™s image analysis course.

Increasing the spatial resolution when imaging almost always leads to a reduced field of view. A common areas for this are histology and astronomy. The image below is made up of 690 individual frames taken with the CEERS Near Infrared Camera (NIRCam). There are more details and high resolution images in the CEERS webpage.

Ceers nircam detailed image

From: CEERS-iously wide imaging. Woods, P. Nat Astron (2022), 6, 1007; https://doi.org/10.1038/s41550-022-01790-0

On a microscope, this can be achieved with tile scanning (i.e. imaging multiple adjacent fields).

Stitching Tiles

Stitching is the method used to put them back together again. Adjacent tiles can contain some overlap, this can improve the stitching results.

Things to remember when using Grid/Collection Stitching:

Most importantly, before you start you need to know your data:

๐Ÿ’” No Overlap

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Unzip Stitching_noOverlap.zip In your file browser, navigate to the downloaded Data folder. Find Stitching_noOverlap.zip and unzip it to a known location
2 Run the Stitching plugin Run Plugins > Stitching > Grid/Collection Stitching
3 Select the stitching order to Column by Column and Up and right Match the settings
Stitching order
4 Select the appropriate settings:
Grid Size: 2x2
Tile Overlap: 0
Directory: {path to your folder}
File Names: replace the numbers with {i} zero pad with more i - noOverlap_{iii}.tif
Uncheck all the options except Add tiles as ROIs
Match the settings below except for the Directory path. Set that to where you unzipped Stitching_noOverlap.zip
Stitching options
5 Run the stitching Click OK and accept fast fusion if asked.

๐Ÿค” Investigate

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Close all the additional windows Click the window close buttons on all Fiji windows except the main toolbar and the macro recorder
2 Run the Stitching plugin Run Plugins > Stitching > Grid/Collection Stitching
3 Use previous settings and add compute overlap Check the previous settings are still selected and additionally check the compute overlap option
4 Run the stitching Click OK

๐Ÿค” Investigate

โค๏ธ With Overlap

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Unzip Stitching_Overlap.zip In your file browser, navigate to the downloaded Data folder. Find Stitching_Overlap.zip and unzip it to a known location
2 Run the Stitching plugin Run Plugins > Stitching > Grid/Collection Stitching
3 Select the stitching order to Column by Column and Up and right Match the settings
Stitching order
4 Use the previous settings except:
Tile Overlap: 10%
Directory: {path to your folder}
File Names: replace the numbers with {i} zero pad with more i - Overlap_{iii}.tif
Check Add tiles as ROIs
Set the Tile Overlap to 10%. Change the directory path to where you unzipped Stitching_Overlap.zip. In File Names, remove the no before Overlap_{iii}.tif
5 Run the stitching Click OK

๐Ÿค” Investigate

โš™๏ธ Batch Processing

Batch processing allows the same processing to be run on multiple images. The built-in [Process > Batch] menu has lots of useful functions.

Unzip BBBC008_partial.zip from the Data folder which contains a subset of data from BBBC008 from the Broad Bioimage Benchmark Collection to try it out.

Convert to a different file type

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Create an output folder Create an empty folder on your desktop called Output
2 Open the batch converter Go to Process > Batch > Convert...
2 Convert the tif files in BBBC008 to png files . Click Input... and select the unzipped BBBC008 folder. Click Output... select the folder on the desktop. Select PNG from the Output format dropdown. Click Convert.

๐Ÿค” Investigate

Write the filename onto each image in red

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Create an output folder Create an empty folder on your desktop called Output labelled
2 Open the batch macro processor Go to Process > Batch > Macro....
3 Select Input and Output folders Click Input... and select the BBBC008 folder. Click Output... select the folder on the desktop.
4 Add the Label macro code Select Label from the Add macro code: drop down.
5 Create a string variable containing the title of the image Above the drawString line in the macro box type title=getTitle();
6 Replace the string in drawString with the title variable Replace "Hello" in drawString with title
7 Test the macro Click the Test button

๐Ÿค” Investigate

๐Ÿ“‹ Step-by-Step Instructions

Step Action Details
1 Close the test image Click the close button for the image window. If asked to save the image, click no
2 Convert the image to RGB Click before setFont so the cursor is at the start of the macro. Select Convert to RGB from the Add macro code: drop down.
3 Test the macro Click the Test button
4 If happy with the result, close the test image and run the macro Click the close button for the image window. If asked to save the image, click no. Click Process in the Batch Process window.

๐Ÿค” Investigate

๐Ÿ”ง Apply Your skills

Try applying the skills you have learnt above and from the Counting and Measuring worksheet to batch process the BBBC008:

Use the Fiji toolbar search and the macro recorder Plugins > Macros > Record to find out how to write the different commands needed. Test each part of the macro separately before trying to combine them. Use batch processing to apply the macro to all the images. You can use the Script Editor to write the macro if you prefer and then either save it and open in the Batch Process window or copy and paste it into the window.

๐Ÿค” Investigate

๐Ÿšฒ More Batch Processing

There are more ways to do Batch processing in Fiji other than Process > Batch > Macro... You can also:

๐Ÿค” Investigate

๐Ÿ’พ Save your progress

If you havenโ€™t already, remember to save your the output from the Macro Recorder so you have a record of what you have done.

Please complete the learning objective survey

vevox link vevox.app Session ID: 107-492-073