BactImAS is a Java-based program that incorporates the latest ImageJ version (currently 1.49a) [20] and a relational database (SQLite3) (Figure 1A). The interaction between the program and the user is facilitated through a graphical user interface loosely inspired by movie editing tools (Figure 1B). We incorporated ImageJ, a tool well known to the biological community, in our GUI for various image processing tasks. We also used ImageJ data structures and functionalities in the implementation of our algorithm. The program is distributed, with identical features, in two ways: as an Icy [22] plugin and as standalone software. If used as a plugin, BactImAs is installed (and kept up to date) through Icy. Installation of the standalone version consists of downloading and extracting the application files from [23]. In both cases, the SQLite database has to be installed for the program to work. In Windows OS, SQLite installation is a simple task, whereas in Mac OS X and many distributions of Linux OS it is already pre-installed.
Analyzing time-lapse movies with BactImAS consists of preprocessing the images, followed by computer-assisted segmentation and tracking, and finally measurement of features of the segmented cells for further analysis. All regions of interest (ROIs) and extracted measurements are automatically and continuously saved in the database, thereby reducing the chance of error and data loss. This feature also allows image processing to be a collaborative effort between multiple users.
Preparation of images
Individual images from up to three recorded channels must be stored as image sequences. Alongside the set of original images, the user has to provide the 8-bit PNG versions (selected because of their small file size) that the software uses internally for displaying and tracking tasks. Both these sets are easily prepared using, for instance, the attached ImageJ program. This does not limit the format of the original images, as measurements can be taken on any image format supported by ImageJ.
Due to the imprecision of the motorized stage, there is often a translational shift between two successive frames in an image sequence. This must be corrected before cell segmentation. To this end, BactImAS has a simple and robust built-in registration algorithm (see Additional file 1) to identify and correct this. If this algorithm fails, images can be registered using external software.
Apart from these mandatory steps, the user may opt to define parameters such as pixel-to-micron ratio, specify frames that should be ignored (e.g. out-of-focus frames), and associate experimental information with the corresponding frame (e.g. change of growth medium).
Cell segmentation and tracking
Once the images are loaded, the user must delineate contours of the cell(s) of interest in the first frame. For easier tracking of cell poles, generations, and lineages in general, initial cells are named in an alphabetical manner and their progenies in binomial fashion (e.g. cell A divides to AA and AB, cell AB then divides into ABA and ABB etc). The user then selects an algorithm that segments and tracks each cell for the assigned number of frames on a selected channel.The user can easily inspect the segmentation results throughout the movie processing step. Upon selecting a frame of interest, the program produces a new image stack with ROI selections superimposed on the images from each channel (e.g. blue, green, and red) and of merged combinations of channels (B+G, B+R, G+R, B+G+R) (Figure 1B). In addition, BactImAS can generate an image sequence of all processed frames composed of ROI selections superimposed on phase-contrast images. If errors are observed, the segmentation can be repeated with different algorithm parameters or by using images from a different channel (if available). Alternatively, any erroneously segmented cells can be manually corrected. This not only corrects the ROI selection of the selected frame, but also facilitates the correct segmentation for the subsequent frames.
In addition to manual selection of cells, it is possible to set a specific cell to be ignored (e.g. if a tracked cell partially exits the image borders), to be defined as “dead”, or to be assigned any other property from a certain frame onwards.In many cell types, a division event is easily defined by a membrane constriction between two adjacent cells, visible on phase-contrast images. In contrast, in mycobacteria a division event often precedes any identifiable membrane constrictions. This mycobacterial feature makes it challenging for an algorithm to define the exact frame and intracellular position of the division event. BactImAS therefore relies on the user to define the division events throughout movie processing. The user is assisted in this decision-making process in two ways: image sequences of each channel are separately displayed in the GUI and the aforementioned image stack, displaying a combination of channels for a selected frame (Figure 1B). After recognizing a division event, the user has to define which specific cell divided (this automatically generates a name for each daughter cell and allows the program to keep track of cell lineages) and then to delineate the contours of the two daughter cells.
Mycobacterial segmentation algorithm
Previously developed algorithms cannot deal with typical M. smegmatis time-lapse movie due to challenges illustrated in Figure 2. To segment mycobacteria-like cells we developed an algorithm (for detailed description see Additional file 1) based on the following assumptions: cells change only slightly from frame to frame thus making tracking straightforward; cells are sometimes in close juxtaposition to neighboring cells but most juxtaposed cells have at least some segments of visible edge; cells are worm-shaped with a relatively fixed width but varying length; and almost all growth happens along the length of the cell.
The algorithm requires three parameters to be defined, corresponding to cell width, maximum pole elongation, and the maximal area increase (see Additional file 1for the precise definition of these parameters and details on how to use them). For any given frame, the algorithm consist of the following steps:
-
Thresholding is performed using the IsoData algorithm [25] (Figure 3C). Optionally, the user can choose between various other auto threshold algorithms implemented in ImageJ. To assist the user in choosing, BactImAS generates an image stack consisting of the same image frame with the different threshold algorithms applied.
-
Edges are thinned using the Zhang and Suen algorithm [26] (Figure 3D).
-
The resulting image provides information about cell edges used in subsequent steps.
-
Cell selection from the previous frame is copied and thinned to the skeleton [26] (Figure 3E). The skeleton is expended into area by probing whether the previous skeleton pixels and neighboring pixels fit within the configured distance from the cell edge (parameter corresponding to cell width) (Figure 3F). The skeleton is expanded lengthwise at the poles by probing the half disc area oriented away from the skeleton endpoints (Figure 3G). The radius of those discs is determined by the algorithm’s maximum pole elongation parameter. Also, in this step the algorithm is constrained by the configured maximal area increase parameter. Pixel sets obtained in two previous steps form an area used to reconstruct the cell by smearing along it the disk of configured radius (parameter corresponding to cell width) (Figure 3H).
Selections are calculated in a round robin fashion, which is a drawback of this algorithm, as it makes it order dependent. However, this feature comes into play only in situations where there are no detectable borders and it is not clear to which cell to initially assign the joint area.
Extraction and visualization of quantitative data
The user can extract quantitative data for the annotated cells in a configurable and fully-automated way. Measurements can be taken from images in any file format, as long as they are of the same resolution and alignment as those used in segmentation and tracking (such that ROIs would delineate the same image areas). Additionally, it is possible to define whether to morphologically erode the shape before taking measurement (e.g. for the membrane region to be excluded from the cytoplasmic fluorescence measurements). Furthermore, BactImAS can acquire measurements from a user-defined background area on all channels for each frame. This information is utilized to provide an additional set of background-corrected values for each cell.
Many additional pre-defined variables are provided in the SQLite database to simplify subsequent data analysis, such as interdivision time and growth rate (see Additional file 1: Table S1–S3). The user can export all or a subset of data as a CSV file and then analyze them externally. We provided a built-in SQL editor to query the database and perform basic time-lapse analysis but the user can also use other specialized software such as SQuirreL SQL [27].
BactImAS enables visualization of the cell lineage according to user-defined graphic parameters. In such a lineage tree, the branch length corresponds to the time between divisions and branching points represent division events. If there is more than one cell at the beginning of the experiment, a separate lineage tree is plotted for each cell. Optionally, the designated name of each progeny cell is plotted. The user can select any two variables and visualize them on the lineage tree, one as the branch width and the other as branch color.