IMOD - segmenting tubes

From NoskeWiki
Jump to navigation Jump to search


NOTE: This page is a daughter page of: IMOD

This page is copy of a guide I wrote for "" at this URL:

I recommend you click the link above for the most recent information, but I have made this copy here as my own record. The page itself explains how IMOD can be used to trace tube like compartments.

Segmenting Tubes

Many organelles within a cell form tubes like shapes. Some of these structures, including microtubules, represent fixed diameter tubes, while others, like mitochondria, represent tube with varying diameter and often branches. This page explains how best to segment tubes in IMOD using open contours. In addition to being much faster than tracing closed contours, the big advantage of this method is an ability to accurately measure the length and even diameter of such structures.

Analyzing and Segmenting Microtubules and other Filaments Using Open Contours with a Fixed Diameter

Cytoskeletal structures including microtubules, actin filaments and intermediate filaments form a network of tiny tubes with constant diameter throughout most cells. In the case of microtubules, the diameter is about 24 nm (Freeman; 2000), although you may also be quoted anywhere between 20 and 25 depending on what scientist you talk to. To segment these bendy but fixed-diameter structures people have designed filament finding algorithms, but since electron tomography images are often noisy, most groups will still opt to segment these tubes by hand.

Before segmenting filaments by hand in 3dmod make sure you have setup the correct pixel size for your model and use this value to determine the radius of your filament in pixels. To do this go: Menubar > Edit > Model > Header. Make sure this contains the correct Z scale (eg "1.4") and pixel size (eg: "2.1 nm") to match your MRC image. You can now work out the radius for your tubes using this very simple formula:

  • DIAMETER_IN_PIXELS = filament_diameter / pixel_size

As an example, lets say our pixel size is "2.1 nm" and we are segmenting microtubules (24 nm diameter):

  • DIAMETER_IN_PIXELS = 24 / 2.1 = 11.43 pixels

To segment filaments by hand the steps are as follows:

  1. Click: Menubar > Object > New.
  2. Give the object an appropriate name (eg: "Microtubule"), and check the object as type "open contour" (most important).
  3. Give the object a "sphere size" which roughly approximates the radius (half the diameter) of your microtubules. This sphere size is mostly just to help you see where you've put points, so don't worry if the spheres are too large. Another thing which is helpful is if you set a symbol to "triangle" with size 3 and tick "mark ends" - this will project a triangle over each point and also marks the first and last point in the contour with a red and green cross (respectively).
    Fig 1: Creating an open object for microtubules
  4. Switch to "model" mode in the main 3dmod window, then zoom in with [+] then use [PgUp] and [PgDown] to find the end of a microtubule in the ZAP window. Starting at one end, use the mouse and [PgUp] / [PgDown] keys to carefully add points through the center of the filament middle until you read the end. Microtubules will usually appear as little dots which move from one section to the next, so you'll typically want to place just a single point per section. In cases where the microtubule is lying flat in XY, then you can draw several points. Click [n] to start a new contour, use the other mouse button to select a point and [DEL] to delete a point if badly placed.
  5. Open the Model View Window by pressing [v]. This window show the 3D profile of your microtubules and you can right click to select any bad points. Notice at this stage it looks like a line and spheres instead of a tube.
  6. To create a tube mesh, select the Model View Window then click "Menubar > Edit > Objects ...". In this objects window, click the "Meshing" option tick "Tubes" and enter the value of "DIAMETER_IN_PIXELS" you calculated earlier. With the correct diameter entered, click "Mesh One" and you will see your tubes generate as mesh. Note that you will have to click "Mesh One" to regenerate this mesh each time, and can switch back to the normal view changing between "Draw Data Type" between "Mesh" and "Contour". You will also want to hide spheres, which you can do by clicking "Points" and then tick "Skip if drawing mesh".
    Fig 2: Meshing microtubules as tubes of fixed diameter
  7. After all microtubules are segmented you can output length using the command line tool "imodinfo". Save the model in 3dmod, then open a terminal window and enter "imodinfo -l youinputmodel.mod" and this will output the length of all your contours - both opened and closed for all objects.


  • When tracing open contours over multiple slices it's very easy to accidentally place points in the wrong order. Note that points are always placed AFTER the selected point, and thus you must make sure you know the direction of your contour and add points in the correct place otherwise you'll see zigzag patterns. To find these bad contours open the Model View Window [v] and use the mouse keys to move around and jump to bad points in the ZAP window. If a contour is a mess you can delete the whole contour with [shift]+[d] and start over.
  • If you place points too close together it's likely your line will contain jagged edge and not look smooth, and this is especially true if the distance between sections / tomogram slices is very small (eg: <20 nm). If this is the case, you should place contour points only on every second/third or forth section. If desired you can fill in the points in missing slices using "Edit > Contour > Fill in Z".

Analyzing and Segmenting Mitochondria and other Tubular Organelles with a Variable Diameter

Above we have explained how to draw tubes with a fixed diameter, but here we explain how to use open contours to draw contours with variable thickness. Mitochondria are a very good candidate for this technique - others candidates may included vesicles (which sometimes form long tubes) and even certain substructures in the Nucleus. Since mitochondria are fairly thick (usually >300 nm thick, depending on cell type) most groups will overlook the idea of segmenting each as a single open contour and instead trace them using closed contours on each section.

An advantage of using closed contours is that this can lead to a slightly better surface estimate, and account for the often irregular bumps and/or shape of mitochondria. The big disadvantages however, is that it's not easy to take these irregular meshes and determine the length and/or diameter of mitochondria - and especially hard to quantify branches. Worse still, however, is that it takes a very long time to trace with closed contours. Each mitochondria is likely to span many slices (sometimes hundreds), and thus requires many contours. In contrast, using open contours only requires you to use a single contour for each non-branching mitochondria, and since it's traced through the middle it's very easy to output length and diameter information. By clever use of objects, you can also easily quantify branches. To summarize the pros and cons of each method:

... Closed Contours (one per section) Open Contours (with variable thickness)
Pros ... (1) Adapts to any shaped mitochondria (1) Easy to acquire length and thickness estimate**

(2) Much faster*
(3) One contour per mito -> easier to manage model
(4) Produces smooth looking surfaces
(5) Can be used to nicely quantify branching

Cons ... (1) Each mitochondria is many contours

(2) Takes up to ten times as long
(3) Can't get accurate length or thickness measures

(1) Volume and Surface Area are slightly less accurate

(2) Cannot handle variations in shape from tubes*

To segment variable length tubes follow these steps:

  1. Create a new object with "Menubar > Object > New".
  2. In the window that appears, name your object "Mitochondrion.NON_BRANCHING" to represent a non-branching mitochondria. Change its type to "open contour", and set the "sphere size" to a good default value (say 20 pixels) which matches the approximate average width of your mitochondria. Note that you can always change these values later with and/or "Menubar > Object > Edit". Before closing this window, we recommend set a symbol to "none" with size ~10 and tick "mark ends" as this helps show you which points represent the first (green cross) and last (red cross) point in each contour.
Fig 3: Creating an open object for mitochondria
  1. If you want to quantify branching, repeat steps 1 and 2 to create a total of three open contour objects. These should have the respective names:
    1. Mitochondrion.NON_BRANCHING .... - use this object to trace all mitochondria without any branches
    2. Mitochondrion.MAIN_LENGTH .... - use this object to trace the longest end-to-end length through mitochondria which branches.
    3. Mitochondrion.BRANCH ....... - use this object to trace any branches coming off a "MAIN_LENGH" mitochondria.

      .... using this system, the number of mitochondria will be equal to "NON_BRANCHING" + "MAIN_LENGTH" and the average number of branches per branching mitochondria will be equal to "BRANCH" / "MAIN_LENGTH". To help you segment, make sure you use different colors for each object (Edit > Object > Color) and feel free to copy our convention where the object colors are green (RGB = 0,0,255), light blue (70,170,255) and purple (180,130,240) for each the respective objects.
  2. Open 3dmod's "Surf/Cont/Point" window by clicking menubar: Edit > Point > Size. Within this window tick "set with mouse wheel" and feel free to leave this window open.
Fig 4: Tracing and resizing point through a mitochondrion
  1. Make sure you are in "model mode" and use [PgUp] and [PgDown] to scroll up and down slices and find the end of a mitochondrion in the ZAP window. Once you've found the bulb at one end, click the mouse to add a single point in the middle of the cross-sectional area, then use the mouse-wheel to resize the point until it fills up the approximate right size. When you scroll up and down sections, notice the sphere occupies space in three dimensions. Click your next point a few slices up (just outside the range of the previous sphere is a good guide) and resize again. Importantly, when the mitochondria appears like an ellipse, it's usually because it's on a diagonal (relative to the XY ZAP plane) and thus you should resize the point to fit the SMALLEST width in cross-section - when the points are connected together it will span diagonally (between points) and fill up the space you missed. Just like with the microtubule, the goal is to trace through the very middle, but this time you are using the mouse-wheel to set different sphere sizes for each point. Only if the mitochondria is very long in a cross section (meaning it's lying flat in XY) will you want to trace multiple point on the same section. And one final thing to note: you don't need to add a point the exact slice where the mitochondrion disappears - you should instead click a few slices up, and then check that your sphere extends down to approximate section where the surface disappears. When you have finished a contour you can click [n] to start a new one. The same mouse button you use to pan can also select a point, and the remaining button can be used to move it, or press [DEL] to delete the selected point. You'll soon see there is a real art to tracing through the middle of mitochondria, but with practice you'll get faster. It's also a good idea to mesh regularly (see the next step) to make sure you are doing a good job of approximating each mitochondria as a smooth object. If you are producing a jagged lines you are doing something wrong and/or putting points too close together.
  2. To mesh your tubes, open the Model View Window by clicking menubar: Image > ModelView [v]. At this stage your mitochondria should each look like a series of balls connected by a line. In the Model View's menubar click: "Edit > Objects ..." and click the meshing panel on the left. In this interface check "tube" to make sure you are meshing as a tube. Rather than giving a fixed size, you will enter "-1" as the "Diam" value - this special value will make sure the tube is generated using point size values. If you click "Mesh One" now, you'll notice the tubes are generated with a variable diameter but have holes at the end. This was desirable for microtubules, but since we're dealing with membrane bound organelles, you'll want to tick "cap" and "dome cap" to make sure the ends are rendered as hemispheres. As with all meshing, you will have to click "Mesh All" to update the meshes to match your current contour set and you can easily switch back to viewing the contours by selecting "Contour" from the "Draw Data Type" drop down list. While this window is open you should use the spinners on the main window to change to your other mitochondria objects and set the same values. Now when you hit "Mesh All", all three of your mitochondria should update and mesh correctly.
Fig 5: Tracing and resizing points through a mitochondria in 3D
Fig 6: Meshing mitochondrion as tubes of variable thickness
  1. Depending on your cell type, a significant number of your mitochondria will be branched. As you trace a mitochondrion, you'll often discover that it branches. When this happens fear not... continue your contour along one of these branches - preferably the longer one - until you get to an end point. Now go back to that branch point and make sure you use the object spin box (or use shortcut keys [o] and [p]) to select your "Mitochondrion.BRANCH" object. Within this object place and resize the first point so that it lines up approximately inside one of the spheres from the mitochondria's "main length"... and then trace it through to its end. You may find even more branches off this, so it's okay to create multiple branches or branches off branches so long as there is only one "main length" contour per mitochondria. After drawing branches, however you'll want to make sure your original contour is in the "Mitochondrion.MAIN_LENGTH" object. To change an contour from one object to another, select the contour and then click: "Edit > Contour > Move", use the spinner to select the object then click "Apply". This window is handy to keep open, as you may find yourself often moving contours from one object to the other.
Fig 8: Mitochondria branching events

Extra Advice

A Few Things to Beware of

  • When tracing open contours over multiple slices it's very easy to accidentally place points in the wrong order. Note that points are always placed AFTER the selected point, and thus you must make sure you know the direction of your contour and add points in the correct place otherwise you'll see zigzag patterns. To find these bad contours open the Model View Window [v] and use the mouse keys to move around and jump to bad points in the ZAP window. If a contour is a mess you can delete the whole contour with [shift]+[d] and start over.
  • Remember you should push [n] before drawing each new contour - otherwise you'll accidentally connect the end of one mitochondria to the start of another. Once again, these accidents are easy to see in the Model View as big long streaks. To split a contour into two separate parts you can use main menu: Edit > Contour > Break and then use this interface to select in the ZAP then set the first and last point of your second mitochondrion then click "Apply" to split these points into their own contour. This is a fairly tricky interface, so sometimes it's just as quick to delete the whole contour and try not to repeat the same mistake again.
  • If you place points too close together it's likely your line will contain jagged edge and not look smooth, and this is especially true if the distance between sections / tomogram slices is very small (eg: <20 nm). If this is the case, you should place contour points only on every second/third or forth section.

Final Analysis

When you have segmented all mitochondria you'll probably want to analyze their length, width, volume and surface area. To analyze their surface area and volume is just like you would do for any other mesh. First make sure you run "Mesh All" (in the Model View > Objects window) and save the model. Now run "imodinfo -h yourinputmodel.mod" and it will show the total volume and surface area for each object (where each object represents all the contours / mitochondria in that object).

To determine the length and width of mitochondria we will use a different approach from that used for microtubules. Instead of just measuring the length of open contours, we also need to add the radius of first and last point. To further complicate things, mitochondria in the "Mitochondrion.BRANCH" object represent an exception, whereby we we'll want to include the radius of the last point, but not the radius of the first (as shown in the graphic below).

Fig 8: Measuring the length branched mitochondria

While it's possible to extract radius values using "imodinfo -p youinputmodel.mod" (-p prints out all point sizes) - it's quite annoying to have to individually extract and add the first and last radius for each contour. To do this automatically I've added a "analyze tubes" feature to Drawing Tools. Click "Special > Drawing Tools", then click "Actions" and select "analyze tubes". If you cannot see this option, you'll have install the very latest (alpha) version of IMOD from: "". In the window that appears, make sure the right object is selected and if you are measuring "Mitochondrion.BRANCH" be sure to uncheck the "include radius of first point" option. When you click okay, it will calculate the length of tubes and thickness information for each contour, as well as averaged information down the bottom.

Fig 9: Process for analyzing tubes

If you also want surface area information, make sure you re-mesh and save the model then run "imodinfo -h youinputmodel.mod" in the Terminal. For even more sophisticated analysis you can use the IMOD command line program "mtk" to analyze the distances between different conponents. Interestingly, this program was originally designed for analyzing the pathway and "close approaches" of microtubules to other compartments, but when mastered can be used to analyze distances from just about any compartment / object to any other object.

SIDE NOTE: As an alternative to using the Drawing Tools > analyze tubes feature, you can extract a bit more information again by installing a special 3dmod "Analysis Tools" plugin. Unlike Drawing Tools, the Analysis plugin does not come with the standard release, so you will have to install it separately. To install it go to this directory "" and download the appropriate file for your operating system. Move this file into your IMOD install directory where the the plugins all live at: "/Applications/IMOD/lib/imodplug/" on Mac or "C:\cygwin\local\imod\lib\imodplug" on Windows. Now close and restart 3dmod and you should see "Analysis Tools" appear under the "Special Menu". With the Analysis Plugin open click: "Action > Analysis Tools > Analyze Tubes". This will give you a slightly longer list of information for each contour. You'll also notice another feature: "Action > Analysis Tools > Analyze Branching". With this selected you can input the object number for your "Mitochondrion.MAIN_LENGTH" and "Mitochondrion.BRANCH" and it will try to match up the first point of each branch with a main length and output a total length and branch information for each of these. IMOD does not support any true hierarchy of contours, but this function attempts to determine the hierarchy based on a close approach of points.

Getting Accurate Length Estimates

To make sure your length estimates are accurate there are a couple of things to you'll need to do:

  • (#1) Omit objects which are truncated by the boundaries of the volume from length analysis. This should be fairly obvious, but if you are segmenting a mitochondria and find that it touches the top slice, bottom slice or sides of your volume then you don't know its full length. At best you know that a "minimum length" for that mitochondria - you know that its "at least" that long. Beyond the volume your mitochondria might end immediately, continue for many microns or maybe even loop back and connect to another truncated region. Since it's impossible to tell it's usually wise to either: (a) segment/separate tubes which touch the tomogram edges in another object (eg: "Mitochondrion.TRUNCATED") or (b) avoid segmenting these altogether. While it may not matter for thickness estimation, it's important to make this distinction so you can easy omit the "truncated" tubes from length estimation - otherwise they will give you an underestimate of average length. If you are specifically trying to determine the average length of mitochondria a good strategy is to start on the middle-most slice and segment all mitochondria within a "safe" bounding box region - a region which is inset enough from all six sides (top, bottom, left, right, back, front) that it's unlikely any mitochondria which starts inside your box touches a corner of the volume. Be warned however, that this approach can introduce a bias towards longer mitochondria.
Fig 10: Object truncation by volume boundaries

  • (#2) Eliminate any bias towards longer mitochondria. Since longer mitochondria cover a greater volume, it means longer mitochondria have a better chance of overlapping any 3D box than a short or "punctuate" (very short - almost spherical) mitochondrion. The bigger your box, the less bias, but most maths savvy reviewers will see this mistake and complain. Two methods you can use to eliminate this bias are:
    • (A) Whole cells at a time. if your volume is large enough you may even find a few cells are captured in their entirety. If this is the case you can randomly select a few of these fully captured cells, and segment their mitochondria in separate sets of object for comparison. A nice advantage of this is that you can then use standard error of the mean and compare the difference in average length of different cells within the one volume. An example of this is shown in the image below.
    • (B) Physical dissector method. To avoid bias of long mitochondria in your 3D box you can use a variation on the "physical dissector method" (a technique used in "stereology"). In this method you will want to project a 3D boxes (rectangular prisms) onto your volume, but only segment / analyze the length of objects which have their lowest point in Z falling inside the 3D box. If your volume is really huge and you want to spread our your sampling you could also make multiple 3D boxes. This technique will keep reviewers happy because each mitochondria will have only one "lowest" point (yes, even the ones with branches) and since you start drawing at the lowest point, you can start your box at the lowest slice of your tomogram. When segmenting, you would then start at the lowest slice of the box and slowly make your way up slices - looking for any new mitochondria which suddenly appear, but careful to note that this is in fact their lowest point (ie: they don't loop over or branch and have their lowest point outside the box!). To generate such a box in IMOD one method is to use the IMOD Stereology plugin. With this plugin open set the grid type to none, tick "subsample rectangles", then alter the rectangle and grid limits to make sure you generate one or more good sized boxes between your first slice and ending a few hundred slices (or whatever is a safe distance) from the top slice. While this seems like a lot of work it will keep any reviewers happy that you haven't inadvertently biased your selection to longer mitochondria.
Fig 11: Techniques for reducing bias
    • For estimating the length of mitochondria and/or microtubules - the bigger and "taller" the volume, the better - as you'll have a lower ratio of "truncated" organelles within your volume. If your the length of your mitochondria is longer than the height (or width) of your volume such that any of your mitochondria touch both the top and bottom of your volume, then it's not possible to get an accurate length estimate.
    • Although rare, certain cell may contain mitochondria which deviate from the expected tubular structure. Within pancreatic beta cells, for example warped bi-concave shaped or "pancake shaped" mitochondria have been discovered (Noske, 2010) - almost like a donut but webbed in the middle. The function of such mitochondria is unclear, but may have something to do with calcium buffering. Such mitochondria cannot be done justice with tubes, so instead it makes sense to use closed contours to estimate their volume. These flat stacks do not really have any "length", but their unusual morphology makes them worth segmentation.
  • For interest, we have attached an excerpt of Noske 2010 thesis (here) showing how one can write up information obtained using these methods.

Being Realistic About How Much you can Segment

When segmenting mitochondria and/or mitochondria make sure you keep a track of how long it's taking you to segment each. Keep in mind also, that while you can get faster with practice, you will often slow down towards the end when hunting through the volume for any you have missed - especially if you are trying to find every microtubule... depending on your resolution it might be difficult to find mitochondria and almost impossible to find and trace them all. Using the method of "tubes of varying thickness" it will usually take between 20 to 200 seconds to trace each mitochondria - depending on their length and amount of branching. In our own experience, ~1 minute per mitochondria is about right - meaning that in a full day (let's say 5 hours) you can trace 300 reasonably long mitochondria.

The thing to keep in mind when segmenting is that many cells have over 300 mitochondria and a large volume of cells may contain a hundred or more cells and thus tens of thousands of mitochondria. Even though the method of variable width tubes (1 min/mito) is much faster than tracing keep in mind it might take you an entire day to segment all the mitochondria a single cell and even a moderate dataset might take you months (1 min/mito * 10,000 mito * = ~170 hours = ~4 working weeks). Three hundred mitochondria per animal (1 day) is a good number to help you obtain a decent estimate of average length - and even use Excel to turn this into a nice histogram of lengths. If you then do three wildtype mice versus three diseased mice you can then get a great comparison between the average length and thickness of mitochondria in your diseased mice versus wildtype mice. Before committing to such a detailed study of length however, it is pertinent to make sure you first have some good stereology measures to check any difference in volume first (see: stereology example using the IMOD plugin).

Fig 12: Histogram of mitochondria lengths

Citation Information

If you have used the methods above for the segmentation and/or analysis of mitochondria please reference the following paper:

  • AB Noske, AJ Costin, GP Morgan and BJ Marsh, Expedited approaches to whole cell electron tomography and organelle mark-up in situ in high-pressure frozen pancreatic islets, (2007) J Struct Biol. 161:298-313.

If you have used IMOD for any segmentation or analysis be sure to reference the original IMOD publication:

  • JR Kremer, DN Mastronarde and JR McIntosh, Computer visualization of three-dimensional image data using IMOD, (1996) J Struct Biol. 116:71-6.


Acknowledgements: The SLASH team