Wednesday, August 20, 2014

ICM walkthrough 1

We will illustrate the use and utility of ICM through several example walkthroughs of imaging data analysis. The first data set is calcium imaging from Akinori Mitani in Takaki Komiyama's lab.

This is ICM develop version 11, committed August 20, 2014: 8f6cb87f72cc8922564125cdaf1c29b721a61ff8


Figure 1. ICM screenshot with labeled regions. 

ICM can load data from a .tiff or .mat file using the ICM menu in the interface, or data can be loaded into ICM through matlab functions set_data or add_trial. The data for this example can be found here url:XXX. Data is loaded as a trial, and trials are managed using the trial management list (Fig 1 R2).

The data can be browsed using the ROI Editor (Fig 1 R1), which allows the user to draw manual ROIs and look through the frames of the imaging data. ROIs can be drawn by simply clicking and dragging the mouse on the image in the ROI editor. The signals from manually drawn ROIs are plotted in the Data plot (Fig 1 R6). Multiple sets of both manually and automatically generated ROIs can be managed using the ROI manager (Fig 1 R3).

Each stage of the analysis is set and controlled with a tab menu in the stage tab panel (Fig 1 R4). ICM displays different information depending on which stage of the analysis is being viewed. The current stage of the anlaysis is displayed beneath the stage tab panel (Fig 1 R5), which also indicates when ICM is busy computing for each stage.

Figure 2: ICM screenshot in pre-processing stage.

In the next step, the preprocessing tab is opened, and the smooth window and down sampling values are set. The smooth window averages all pixels within a moving MxNxT window (rows, columns, time). The down sampling only keeps every MxNxT pixels, producing a smaller imaging data set. For this example, the original image data is 512x512x1600, but this is too large for the PCA-ICA analysis to be run on a desktop computer. We used a 4x4x2 smooth window and 4x4x2 down sampling to reduce the image size to 128x128x800. When the "Pre Process" button is pressed the original data is pre-processed and the pre-processed data is displayed in the ROI Editor. The original data can still be viewed in the data tab, and the pre-processing can be removed by clicking the "Reset" button in the Data tab.

Figure 3. ICM screenshot in PCA stage.

Next the principal components are computed. Every pixel in the preprocessed imaging data set is arranged in a matrix, where the rows are each pixels, and the columns are the values of the pixels over time. When the user clicks the "Run PCA" button, the principal components of this matrix are then computed, which decomposes the imaging data into several components, each of which has a “source” and a “score”. Sources are the time series of the extracted components, and the scores indicate the coefficient of the source for each pixel. The scores are rearranged back into an image to produce a “map”, which shows the spatial locations from which the sources are produced. The principal components are typically combinations of cellular signals, and do not reveal individual cells.

The principal components can be browsed in the ROI editor with the PCA tab open. Each frame in the ROI Editor shows the map of a different principal component, and the source of each component is plotted in the Component Plot. Several more example principal components can be seen in Figure 6A. 

Figure 4. ICM screenshot in ICA stage.

To reveal individual cells, the independent components are then computed from a subset of the principal components. Typically the top N principal components are used, where N is slightly larger than the number of neurons being recorded from. This can be set using the “PCs” edit box in the ICA tab (Fig. 4). The ICA algorithm will attempt to find the same number of components as principal components included, and so there should be at least as many PCs used as cells. Typically, more PCs is needed than cells, because many components are extracted that correspond to motion, background, bleaching, or other artifacts.

Once the PCs are chosen and "Run ICA" is clicked, ICM computes the independent components using the fastica algorithm. Further changes to the fastica settings can be made through a settings struct that can be changed programatically (see Documentation), as well as choosing different ICA algorithms (infomax and stICA (Mukamel et al 2009) are also built in). Like  PCA, ICA also produces sources and scores, where the sources correspond to the independent signals and the scores describe which pixels are contributing to the source. The scores are rearranged back into an image to produce a map, and the maps show the spatial locations of the independent components. 

Several example independent components are shown in Figure 6B and C. The ICA algorithm pulls out both components that are cellular signals (Fig. 6B) as well as components that are artifacts (Fig. 6C). These must be sorted manually using the interface, and components which are artifactual can be removed from further analysis by adding them to the "Remove" edit box. Further post-processing can be performed on the ICs using the tools in the "ICA Post-Processing" box.

Figure 5. ICM screenshot in segment stage.

Regions-of-interest can then be automatically generated from the ICA maps. In the Segment tab, the threshold level and amount of down-sampling are set for the segmentation algorithm. When the "Segment ICs" button is pressed, binary masks are created for each IC, which are displayed in the ROI Editor when the Segment tab is open. Each contiguous region of the binary mask is then matched with the best fitting oval to produce the ROI. The ROIs produced are saved in the ROI manager. 

ICs can have multiple ROIs because there can be multiple spatially isolated regions for a single IC. In this data, several cell soma's are slightly misaligned with the image plane, but their dendirtic branches (or axons) are in focus (see IC 26 and 30 at bottom of Fig. 6B). Because of this, the segmentation algorithm breaks up these cells into multiple ROIs (Fig. 6B, right). 


Figure 6. Example Components  

A major advantage of the PCA-ICA extraction is that this algorithm does not depend on spatial-localization to extract component signals. Calcium signals from cells or axons that do not have a single localized spatial region would be virtually impossible to extract if onlyn ROIs were used. The ICA component decomposition does not depend on spatial localization, which allows for clear signals to be extracted from out of focus cells or long axons. This suggests that many cells may be missed entirely when relying on ROI methods and that the ICA algorithm can get much higher signal-to-noise ratio in certain imaging conditions. Further, ICA can separate components that have overlapping spatial locations. For example, IC 150 (Fig. 6C) shows clear striations due to artifacts of the imaging acquisition system. These striations cover the entire image, but ICA can separate this artifact from the cellular components because the pixels share statistical patterns caused by the artifact. It would be impossible for ROI methods to separate spatially overlapping components.

Figure 7. ICM screenshot in visualization stage.

Finally, visualizations are created in the visualization stage. Two simple visualization systems are built into ICM, and here we will illustrate the PCA visualization of the ICA data. The PCA component viewer can be opened in the visualization control tabs (Fig 1. R8), and this allows the user to select three principal components to visualize. Each independent component has coefficients in the principal component space, and the user selects which dimensions to use to set the R, G, B color channels for each component. The component maps are then colored based on the coefficients of the dimensions chosen, and these are overlayed on the image data to create a visualization. The settings of the visualization can be manipulated using the controls in the "Visualization Settings" panel.

Figure 8. ICM visualization shows IC 9 and 49 are similar.

The visualizations can be useful for rapidly highlighting the functional relationsships between neurons. For instance, in Figure 8C we show a visualization of PC 7, 9 and 10. This reveals two components, 9 and 49, which have the same color. This is reflected in the close proximity of the components in the PCA space (Fig. 8B) and is a consequence of these to components having very similar calcium activity (Fig. 8A). 


Tuesday, August 12, 2014

NS&B Lecture


My lecture at NS&B covering PCA, ICA and their application in automatically extracting signals from imaging data.