Measuring angles in Avizo

I've spent a good portion of my PhD working with 3D images in the program Avizo, which is essentially the same as the program Amira. This involved a steep learning curve and a lot of problem solving in the beginning. I've decided to write about the problems I've encountered and how I dealt with them in the hope that this may help the next person learning to use Avizo or Amira do so a bit faster, and with less frustration along the way. These problems will look trivial to the regular or advanced Amira/Avizo user, but they were quite frustrating at the time! These posts assume the reader's familiar with sections 2.1-2.5 of the Amira user's guide, which cover how to load, view and segment an image. My introductory post on this topic is here and the rest of my posts are here.

Recently, a lizard-brain-expert who's been helping me identify the brain regions visible in my lizard brain MRI images came to me with a strange problem: she was having a hard time identifying the different brain regions because the brain was not oriented correctly! I was embarrassed not to have noticed previously, but I had to agree: the brain was rotated in the sagittal plane. I quickly e-mailed some MRI experts to ask for help rotating the image into the correct orientation, and I received an odd, but obvious response: what angle do you want your brain rotation to?

Well, I had no idea. It's easy to rotate something in Avizo, but not so easy to figure out at what angle you've rotated it. It's also not something I was able to figure out by looking in the Avizo (or Amira) manuals nor by Googling. Eventually, I figured out a solution. It's not elegant, but it works. Here's what I did.

1. View your image

First, I loaded up my image in using Orthoslice, viewing the plane in which I wanted to rotate the image (in this case, the sagittal plane).

2. View your axes

Second, I wanted to display the axes of my original image. This is easy enough. Just go to the "View" menu and selected "Global Axes".

3. Rotate your image to the correct angle

I use the slower, but more idiot-proof "rotate" button.

4. Measure the angle.

This is the annoying part. There's no way to just say "how much did I just rotate my image?" as far as I can tell. However, you can use the measurement tool to measure a 2D angle, and you can trace over the x-axis of your Global Axis and then at the apex draw a horizontal line, as I've illustrated below. That is the angle you've rotated your image.

Postscript

Even though there's no way that I can see to measure how much you've rotated an image directly, you can do the reverse, that is rotate your image at a desired angle. The rotate module allows you to type in the angle of rotation you want, and it will rotate the image that amount. It's real purpose is to make cool videos, but it does this too.

Now, if only I could figure out how to export my rotated image as a NIFTI file, I would be all set! If you know how to do that, please please please tell me!

The basics of using the Pool to open and view images and label fields

I've spent a good portion of my PhD working with 3D images in the program Avizo, which is essentially the same as the program Amira. This involved a steep learning curve and a lot of problem solving in the beginning. I've decided to write about the problems I've encountered and how I dealt with them in the hope that this may help the next person learning to use Avizo or Amira do so a bit faster, and with less frustration along the way. These problems will look trivial to the regular or advanced Amira/Avizo user, but they were quite frustrating at the time! These posts assume the reader's familiar with sections 2.1-2.5 of the Amira user's guide, which cover how to load, view and segment an image. My introductory post on this topic is here.

Figuring out how the basics of how the "Pool" (in Amira) or the "Project View" (in Avizo) works can be a bit tricky, and it's one of the first things you have to figure out to use these programs. The Pool is where all the data and modules you're working with are visualised. Here's how the Amira User Manual describes the Pool and its contents:

"Amira is a modular and object-oriented software system. Its basic system components are modules and data objects. Modules are used to visualize data objects or to perform some computational operations on them. The components are represented by little icons in the Pool. Icons are connected by lines indicating processing dependencies between the components, i.e., which modules are to be applied to which data objects." - Amira User Manual, page 4

This is basic stuff, but if you're new to Amira/Avizo, confusion arises because nowhere does the manual tell you what any of this stuff looks like. Here's what it looks like in Avizo, and it looks pretty much the same as this in Amira:

Screen Shot 2015-01-07 at 3.08.25 pm.png

So data objects and modules are colourful blobs, connections between data objects and modules are blue lines, and if you look closely, you can see that the data object-end of the blue line is a diamond while the module-end of the blue line is a square. 

The Amira User Manual explains very well how to make a new label field for an image, and how to save the whole thing (image + label field) together as a "project". But what if you have an image and a label field already, and would like to join them? The Amira User Manual, as far as I can tell, doesn't cover this. Here's how to connect two data objects, one of which is a 3D image and the other is a label field. First, open the 3D image:

Then, open the label field:

The data object for the label field appears below the data object for the 3D image, unconnected. Now, click on the white square of the label field's data object, which allows you to control what it's connected to. It gives you a drop-down list of different kinds of connections it can make, select the "ImageData" option. A blue connection line follows your cursor around, click on the 3D image's data object. The two data objects jump together, indicating that they are now connected. Notice that connections between data objects are displayed differently than connections between a data object and a module.

All this is well and good, but if you've done this, you've noticed that none of this results in you actually visualising anything. Fortunately, the Amira User Manual is very good at explaining how to visualise your data, in general. However, one thing that I think is missing from the manual is how to visualise a label field and the image it's based on at the same time. For this, there's Colorwash, section 2.8.3 in the Amira User Manual. Colorwash is described in the manual as being for the visualisation of two images at once, but it's not clear from their description that it can be used to visualise a label field on top of an image. Technically a label field is just an image dataset like any other, so Colorwash can be used like this. Attach a OrthoSlice module to the 3D image data object, then attach a Colourwash module to the OrthoSlice module. Click on the white box in the Colourwash module, select "Data" from the drop-down list, and click on the label field data object. Notice that connections between modules are displayed the same way as connections between data objects.

There! Quick and easy ways to load and visualise images and their label fields.

Some additional comments on segmentation & hot keys

I've spent a good portion of my PhD working with 3D images in the program Avizo, which is essentially the same as the program Amira. This involved a steep learning curve and a lot of problem solving in the beginning. I've decided to write about the problems I've encountered and how I dealt with them in the hope that this may help the next person learning to use Avizo or Amira do so a bit faster, and with less frustration along the way. These problems will look trivial to the regular or advanced Amira/Avizo user, but they were quite frustrating at the time! These posts assume the reader's familiar with sections 2.1-2.5 of the Amira user's guide, which cover how to load, view and segment an image. My introductory post on this topic is here.

In this post I'm going to talk about some additional issues with the hot keys and with adding and subtracting to materials in the Image Segmentation Editor.

An additional hot key.

Here is a list I downloaded of the hot keys that you can use with the Image Segmentation Editor to really speed up segmentation. I've discussed them previously. There's one omission to the list (that I've found, anyway). Keys 1-9 cover the different tools, starting with the Brush tool, but what about the Pick & Move tool? Turns out, even though it's not on the list, "0" switches ("toggles") you to the Pick & Move tool! I've updated my list accordingly.

The add and subtract hot keys are finicky

The most straightforward and least efficient way to add a region of an image to a material is to select that region using whichever tool is most appropriate (in these examples I use the brush tool, which is the most straightforward tool, but again the least efficient) and then click on the Add button in the Selection section of the Segmentation Editor. Here's what that looks like:

There are two hot keys that are supposed to do the same thing, "A" and "Ctrl +". The trick is, neither works in exactly the same way. Once I figured out the differences between them it was quite useful, because now I can use whichever Add function best suits my needs at the time. But it was confusing to figure out.

Pressing "Ctrl +" adds the selected part of the image to the material, but leaves it selected. You must then remember to unselect the region manually using the Clear button in the Selection section of the Segmentation Editor.

That means that, if you then select a region that you want to add to a different material, say Lobe1, and then go to add your new selection to Lobe1, you will add both selections to Lobe1 unless you remember to unselect your first selection.

Using the "A" key to add a selection to a material is even more tricky. It only works if you've already added at least one selection to the material since editing any other material. So, practically, the "A" key will only add a selection to the material if the last thing you did was add (or subtract) a selection to the same material. Furthermore, where that previous selection was matters, and depends on your current settings. In the Selection section of the Segmentation Editor, if the button "Volume" is selected, then the previous selection you added could have been on any slice.

However, if the button "Current Slice" is selected in the Selection section of the Segmentation Editor, then the previous selection added to the current material (in this case, Lobe2) must have been in the current slice for the A hot key to work. 

The "-" hot key for subtracting a selection from the current material has the same sort of funny restrictions as the "A" hot key.

If you have any suggestions, feedback, or questions about Amira/Avizo, please let me know.

Trouble-shooting Avizo (and Amira by extension)

Some of my work involves dealing with 3D images, either CT scans, MRI scans, or z-stacks from a confocal microscope. To analyse these images there are a variety of tools available but the industry standard seems to be Amira. Amira is an incredibly powerful piece of software not just for analysing 3D images, but also for editing them and making them look pretty for figures and presentations. Unfortunately, it comes with the kind of price tag you'd expect. As an academic user, I'd be able to purchase Amira at half price, about $5000 AUD, before taxes and extensions. For my work, I'd probably ultimately need at least the quantification+ extension, and possibly the neuro and large data set extensions as well.

Fortunately, I've been able to avoid this insurmountable expense through collaborations. I collaborate with biologists, neuroscientists and computational wizzes at Monash University and the University of Queensland. Because I am a staff member at Monash, I've been able to access the MASSIVE remote desktop. Through this desktop I have access to Amira, almost. MASSIVE does not have a licence for Amira. Instead they have a licence for Avizo. Avizo, to my understanding, is the same program as Amira, with a different skin. Amira is geared towards the life sciences, while Avizo is geared towards the physical sciences and engineering, but they both ultimately do the same thing.

Since I have access to Avizo but not Amira, I've been using Avizo for things that Amira's really meant for. Furthermore, as far as I can tell (and I've done some sleuthing), I'm the only person at the Australian National University using Amira/Avizo (side note: if you're at ANU and use either of these programs, please let me know!) That means, though I have support from experts at the University of Queensland and Monash, I've largely been on my own in figuring out how to use Avizo/Amira. Usually, when I have problems figuring out how to use software, Google is my saviour, however I've found the online resources for troubleshooting Avizo/Amira woefully inadequate (again, if you know of good online resources for this, please let me know!)

As I've been learning to use Avizo/Amira, I've encountered quite a few challenges, which I've mostly solved through trial-and-error, with some desperate e-mails to experts. Since I haven't been able to find these solutions online, I thought I'd put them here in a series of posts, so that the next desperate person might solve these problems without wasting quite as much time banging their head against a keyboard as I have. I'd like to note that these problems are beginner problems and will look very simple to the advanced (or even just regular) Avizo/Amira user, but they were quite frustrating at the time!

First, I must say that the Amira training manual is very useful for learning both Amira and Avizo, and is very easy to use. I've done Chapters 2 and 7, which teach the basics (including segmentation, the tool I use most) and animations, respectively. The troubleshooting I describe will assume knowledge of Chapter 2, sections 2.1-2.5, which cover loading an image, viewing an image, and segmenting an image. The reason I use the Amira training manual rather than the Avizo training manual is that the Amira manual uses a neuroscience example (a bee brain) and neuroscience is what I do, so it's much easier to directly translate the examples to my work.

In addition to the steep learning curve involved in learning to use Amira/Avizo, there are two additional sources of confusion that I've found. First, there are some things that are different between Amira and Avizo which can make the Amira training manual difficult to follow in Avizo. I'll cover the issues I've found later. Second, I'm a Mac/Linux user, and I think that there are some bugs in Amira/Avizo that are particular to these two systems. Here's the first one:

Using the "hot keys" of the Image Segmentation Editor in OS X or Linux

First things first, and this might seem simple, but it was really confusing at the time. Any of the "hot key" commands (what Avizo/Amira calls keyboard shortcuts) that use the Control key on PCs STILL use the Control key on Macs. This is despite the fact that every other program I've ever encountered uses the Apple/Command key in place of the Control key for keyboard shortcuts on Macs. Get used to it, Mac users, it's the Control key in Amira/Avizo. Here is a PDF of the Segmentation Editor's hot keys.

Second, as far as I can tell, not all the hot keys actually work (at least for me, using OS X and Linux). I made this table as a guide for myself so I would know if a key command normally works or if I'm going nuts. Most of them do work for me and I recommend going through each of them one-by-one, just to see what they do. If I'd done that two years ago, I'd have saved a lot of time!

The issues I'm going to go through on this blog are similar to this one. They will be very basic to the regular or advanced Amira/Avizo user, but boy would I have been overjoyed for someone to have told me these things when I was learning! If you have a particular issue with Amira or Avizo, please let me know and I will help if I can.