It’s a Stitch up!

Scale is a funny thing. To virologists, bacteria are big. To microbiologists, cells are big. To cell biologists, tissues are big. We’ll not go as far as the cosmologists, but the point is that sometimes you have to move out of your size-based comfort zone and image something BIG. Enter imaging tiling!

2015-06-stitch-00

Once you’ve acquired all of your images (36 in the example above), it’s not always clear (even in vendor software) how to put them back together. Today’s post will deal with image stitching and also cover one of the big problems you may run into along the way.

Magnification, field of view and resolution

The first question you’re probably asking is: why not just use a lower magnification? This is a very good question and for some applications a lower magnification will serve you just fine:

The same sample imaged at 32x (left) and 5x (right) magnification.

The same sample imaged at 32x (left) and 5x (right) magnification.

The trade off here is that you’re still capturing the image on the same number of pixels so in the lower magnification, you lose resolution. This is evident if we zoom into the same area on the 5x image that is shown in the 32x image (it’s roughly in the middle):

2015-06-stitch-03The way to cheat the system and get both magnification (, resolution) and field of view is to use image tiling. The basic idea is to take multiple higher magnification images that cover your object of interest, then stitch them back together:

2015-06-stitch-05

A quick word on overlap

In the diagram above, we’ve taken images of our green blob with an overlap at the edges (the pink bits with lower opacity). This is really important for a good stitch. The reason being that the software needs to have something to compare between images to know that it’s being aligned.

2015-06-stitch-06

A very simplified example of why you need an overlap.

When you’re acquiring images, an overlap of about 10% is usually fine, but depending upon the texture of your image, you may need more or be able to get away with less. Right … back to it.

Spheroids

Spheroids are a great model of solid tumours and they make for some really interesting imaging problems. If there is such a thing, a ‘typical’ spheroid is about half a millimetre in diameter (or about 185 microdolphins for those who haven’t fallen asleep in class).

This means that you can’t see the whole thing with any magnification better than about 10x. As mentioned above though, 10x doesn’t give you a lot of information when you zoom in. For this example, we’ll go one better and use a 20x objective lens:

2015-06-stitch-27 Our spheroid is just a bit bigger than the field, so we take 4 images (top left, top right, bottom left, bottom right) to image the whole thing. Here we probably have close to 80% overlap but that’s OK.

To stitch them together we’ll use a plugin for Fiji, written by Stephen Priebich. It should come automatically installed with Fiji, so run [Plugins > Stitching > Grid/Collection Stitching]. You’ll be asked in what order the images were acquired (there are lots of options on the pull down menus):

2015-06-stitch-25

Select the right one and hit next to get the main dialog. The important bits here are the grid dimensions (2 x 2), the rough overlap (we’ll use 80%) and the path to the files. The easiest way to not make mistakes is to copy/paste the path and filename. Make a file mask by replacing the numbers in the file name with the curly braces and ‘i’ character. For zero padded numbers just add more i characters. Example:

Filename:                Mask:
spheroid4.tif            spheroid{i}.tif
spheroid04.tif           spheroid{ii}.tif
spheroid004.tif          spheroid{iii}.tif

Most of the rest of the values can be left at defaults (at least try this first). One nice feature is the ability to save the original tile locations as ROIs. We’ll come to that later.

When you have all the bits done, hit OK and watch the log to make sure nothing untoward happens. When you’re done, if you selected to display the output you’ll get something that looks like this:

2015-06-stitch-33You can see we were a bit off with out overlap estimates (it’s probably closer to 30-40% in each dimension) but in my experience an overestimate is better than an underestimate. The great thing about this new image is that it retains the resolution of the original images (you can zoom in and get detail) but gives you a larger field of view. You can expand this idea using a higher magnification but you will of course need more images to cover the same area:

2015-06-stitch-00

Epilogue: Expecting the impossible

When I was first stitching images, I had a really hard time of it. I just couldn’t get histological sections to stitch, despite the images being highly patterned. That is, until I realised that I was expecting the impossible of the software. Here’s one of the original images:

2015-06-stitch-40As it is, it doesn’t look too bad, but enhance the contrast and the problem is as clear as day:

2015-06-stitch-41Now you can see that there is an uneven illumination across the field. While this doesn’t seem like much to us, when the software comes to try to find the next slice (for instance to the left), it will be comparing a subtlety lighter right edge (in that image) with a subtlety darker left edge (in this image). That spells trouble for the software and a lot of frustration for the user. Thankfully, there’s a way to sort it out!

If you take the original image and run a Fourier Bandpass filter over the image (using [Process > FFT > Bandpass Filter]) filtering large structures down to 50 pixels and not adjusting small structures the illumination issue is corrected:

2015-06-stitch-44

Image after FFT bandpass filtering, with normal (left) and enhanced (right) contrast.

After this correction, the stitching worked like a charm.

Advertisements

Comment!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.