Patent Publication Number: US-2022237810-A1

Title: Systems and methods for slide image alignment

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
     This application claims the benefit of U.S. provisional patent application No. 62/845,585, filed on May 9, 2019, and entitled “SYSTEMS AND METHODS FOR SLIDE IMAGE REGISTRATION,” the disclosure of which is expressly incorporated herein by reference in its entirety. 
    
    
     STATEMENT REGARDING FEDERALLY FUNDED RESEARCH 
     This invention was made with government support under Grant no. CA143970 and CA193489 awarded by the National Cancer Institute. The government has certain rights in the invention. 
    
    
     BACKGROUND 
     Aligning immunohistochemistry (IHC) is challenging for one or more of the following reasons: (1) the intensity of each pixel is different across slide images due to varying spatial distributions of the cells that carry the markers stained for; (2) the shape of the tissue changes as one moves “through” the sample; (3) samples may be distorted due to tearing or folding; and/or (4) the order of slices may not be known. Conventional methods tend to focus on small regions of interest (ROI), single stains, or a limited number of slides. 
     SUMMARY 
     Systems and methods for slide image alignment are described herein. An example computer-implemented method for slide image registration is described herein. The method includes receiving a plurality of slide images, detecting a plurality of features contained in the slide images, and comparing a plurality of pairs of the slide images. The comparison uses the detected features. The method also includes creating a distance matrix that reflects a respective difference between each of the pairs of the slide images, creating a graph by connecting each of the slide images to its most similar slide image, and detecting a plurality of graph components. Each of the graph components includes one or more of the slide images. The method further includes aligning the slide images within each of the graph components, and aligning the graph components to form a composite image. 
     Optionally, the detected features are KAZE features. 
     Alternatively or additionally, the step of comparing a plurality of pairs of the slide images includes comparing each one of the slide images to each of the other slide images. The comparison is used to create the distance matrix. 
     Optionally, the method further includes sorting the distance matrix by performing hierarchical clustering, for example, to yield a dendrogram. The dendrogram includes a plurality of leaves, each leaf corresponding to one of the slide images. Optionally, the method further includes performing optimal leaf ordering on the dendrogram. 
     Alternatively or additionally, the step of aligning the slide images within each of the graph components includes aligning two or more slide images within a graph component using at least one feature shared by the two or more slide images within the graph component. 
     Alternatively or additionally, the step of aligning the graph components to form a composite image includes pooling a respective set of features belonging to each of the graph components, and aligning two or more of the graph components using the respective sets of features belonging to the two or more of the graph components. 
     Alternatively or additionally, the method optionally further includes refining the alignment of the slide images. 
     Alternatively or additionally, the method further includes determining a transformation matrix for aligning the slide images. The step of determining the transformation matrix optionally includes selecting the transformation matrix from a plurality of transformation matrices, the selected transformation matrix having the lowest alignment error. The method can further include aligning one or more of the slide images using the transformation matrix. 
     Alternatively or additionally, the method further includes pre-processing the slide images. In some implementations, the step of pre-processing the slide images can include normalizing an RGB slide image, and converting the RGB slide image to greyscale. In other implementations, the step of pre-processing the slide images can include converting an RGB slide image into a YUV colorspace. 
     Optionally, the slide images are whole slide images of tissue slices. Alternatively or additionally, the whole slide images include images of tissue slices immunostained for different markers. Alternatively or additionally, the slide images are images of tissue stained with hematoxylin and eosin (H&amp;E) stain. Alternatively or additionally, the slide images are images of tissue stained with multiple colors. Alternatively or additionally, the slide images are images of tissue that has undergone a plurality of stain and wash cycles. 
     Optionally, the slide images are an unordered set of slide images. 
     It should be understood that the above-described subject matter may also be implemented as a computer-controlled apparatus, a computer process, a computing system, or an article of manufacture, such as a computer-readable storage medium. 
     Other systems, methods, features and/or advantages will be or may become apparent to one with skill in the art upon examination of the following drawings and detailed description. It is intended that all such additional systems, methods, features and/or advantages be included within this description and be protected by the accompanying claims. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
       The components in the drawings are not necessarily to scale relative to each other. Like reference numerals designate corresponding parts throughout the several views. 
         FIG. 1A  is a flowchart illustrating a method for aligning slide images according to an implementation described herein.  FIG. 1B  is a flowchart illustrating another method for aligning slide images according to an implementation described herein. 
         FIG. 2  is an example computing device. 
         FIG. 3  is a table including the alignment accuracy of a slide alignment method (i.e., VALIS) according to an implementation described herein. 
         FIG. 4A  is a graph illustrating the comparison of the accuracy of VALIS (auto) versus aligning by hand (manual).  FIG. 4B  is are graphs illustrating the alignment accuracy of different data sets. 
         FIG. 5  is a table including definitions for variables used in the description of an example method (i.e., VALIS) according to an implementation described herein. 
     
    
    
     DETAILED DESCRIPTION 
     Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art. Methods and materials similar or equivalent to those described herein can be used in the practice or testing of the present disclosure. As used in the specification, and in the appended claims, the singular forms “a,” “an,” “the” include plural referents unless the context clearly dictates otherwise. The term “comprising” and variations thereof as used herein is used synonymously with the term “including” and variations thereof and are open, non-limiting terms. The terms “optional” or “optionally” used herein mean that the subsequently described feature, event or circumstance may or may not occur, and that the description includes instances where said feature, event or circumstance occurs and instances where it does not. Ranges may be expressed herein as from “about” one particular value, and/or to “about” another particular value. When such a range is expressed, an aspect includes from the one particular value and/or to the other particular value. Similarly, when values are expressed as approximations, by use of the antecedent “about,” it will be understood that the particular value forms another aspect. It will be further understood that the endpoints of each of the ranges are significant both in relation to the other endpoint, and independently of the other endpoint. 
     Tumor biopsies are often cut into a series of very thin slices, each of which is placed upon a slide. Stains may be applied to each slice, revealing the different cell types within the slice. Knowledge of the spatial location of cell types can be highly informative, as the location reveals how cells are interacting with one another, and/or if cells are isolated to certain regions of the tumor. Unfortunately, the location and orientation of the slices often varies across the slides upon which the slices are placed. As such, conducting a spatial analysis is only possible if the slices have been aligned in space. This would be extremely tedious to do manually. The technique described herein provides a solution that overcomes one or more of the difficulties noted above. The technique described herein provides an automated way in which to align the slices. The technique can be used align images of any size, from small pieces of tissue to the whole slice. The technique is also able to align a large number of serial slices, potentially allowing for three-dimensional (3D) reconstruction of the tumor. Further, the technique is able to align slices which have been stained for different cell types, allowing one to get a better picture of the cellular composition of the tumor. Given these features, the technique enables one to conduct a spatial analysis and/or reconstruct the tumor in 3D. 
     An example method for performing whole slide image registration (WISR) for immunohistochemistry (IHC) is described herein. An example method for analyzing slide images is also described herein. The method can include aligning a plurality of slide images to form a composite image. Alternatively or additionally, the method can further include slicing the composite image into a plurality of quadrats, analyzing each of the quadrats, and estimating spatial interactions between cell types within the slide images. Alternatively or additionally, the method can further include creating a distance matrix using ecological distances to compare a region of interest (ROI) across tumors. Alternatively or additionally, the method can further include clustering on the distance matrix to identify a hidden structure in the composite image. Alternatively or additionally, the method can further include performing a multidimensional analysis on the distance matrix. 
     Referring now to  FIG. 1A , an example method for aligning slide images is shown. This disclosure contemplates that the method can be performed using a computing device, for example, computing device  200  of  FIG. 2 . An automated software tool that aligns a series of whole slide tissue image slices, immunostained for different markers is described below. The algorithm can include the following series of sequential steps: 
     Step  101 —Feature Detection and Matching: The features of each image are detected. Using these features, each image compared to all other images in the series by feature matching. 
     Step  102 —Slide Ordering: Comparisons are used to build a distance matrix, D, reflecting the differences between each pair of images. Hierarchical clustering is performed on D, yielding a dendrogram. The leaves of the dendrogram, each corresponding to an image, are then optimally ordered. This order determines the position of the image in aligned image stack. 
     Step  103 —Community Alignment: A graph with images as vertices, and edges connecting the most similar images, is created to perform the alignment. Communities are detected, and then images in each community are aligned to one another. This is followed by stitching the communities together. Community Stitching: The features of each community are pooled, and then images in each community are aligned to the images in the previous community by matching pooled features. Positions of matching features are then used find that transformation matrix that will warp images to those in the previous community. 
     Step  104 —Registration: Images are now stacked and aligned. Dense optical flow is used to refine the alignment of each image to the previous image in the stack. 
     Step  105 —Result: The transformation matrices found during this process can be used to align the original, unprocessed, versions of the images. The transformation matrices can also be scaled to work on resized (smaller or larger) versions of these images. 
     Referring now to  FIG. 1B , another example method for slide image registration is shown. This disclosure contemplates that the method can be performed automatically using a computing device such as computing device  200  of  FIG. 2 . This process is also described below in Example 2 (i.e., the VALIS technique). At step  122 , a plurality of slide images are received, for example at a computing device. In some implementations, the slide images are whole slide images of tissue slices, for example, whole slide images that include images of tissue slices immunostained for different markers. Alternatively or additionally, the slide images are images of tissue stained with hematoxylin and eosin (H&amp;E) stain. Alternatively or additionally, the slide images are images of tissue stained with multiple colors. Alternatively or additionally, the slide images are images of tissue that has undergone a plurality of stain and wash cycles. Optionally, in some implementations, the slide images are pre-processed so that the slide images look as similar as possible. The slide images can be processed to have a black background and lighter foreground highlighting tissue features. For example, in some implementations, the step of pre-processing the slide images can include normalizing an RGB slide image, and converting the RGB slide image to greyscale. In other implementations, the step of pre-processing the slide images can include converting an RGB slide image into a YUV colorspace. Alternatively or additionally, the slide images are optionally an unordered set. It should be understood that the pre-processing techniques described above are provided only as examples and that other techniques can be used. 
     At step  124 , a plurality of features contained in the slide images are detected. Optionally, the detected features are KAZE features (e.g., F i  in the VALIS technique described below). KAZE features are detected using a two-dimensional feature detection and description algorithm known in the art. Although KAZE features are provided as an example, this disclosure contemplates that the detected features can be other than KAZE features. At step  126 , a plurality of pairs of the slide images are compared. The comparison uses the detected features. For example, the step of comparing a plurality of pairs of the slide images includes comparing each one of the slide images to each of the other slide images. At step  128 , a distance matrix (e.g., n×n distance matrix, D in the VALIS technique described below) that reflects a respective difference between each of the pairs of the slide images is created. Optionally, if the slide images are an unorder set (i.e., slide series is unknown), the method further includes sorting the distance matrix by performing hierarchical clustering, for example, to yield a dendrogram. The dendrogram includes a plurality of leaves, each leaf corresponding to one of the slide images. Optionally, the method further includes performing optimal leaf ordering on the dendrogram. 
     At step  130 , a graph (e.g., undirected graph G(V,E) in the VALIS technique described below) is created by connecting each of the slide images to its most similar slide image. At step  132 , a plurality of graph components (e.g., community C m  in the VALIS technique described below) is detected. This disclosure contemplates using community detection techniques known in the art. Such techniques are well known in the art and not described in further detail herein. Additionally, at step  134 , the slide images within each of the graph components are aligned. The step of aligning the slide images within each of the graph components includes aligning two or more slide images within a graph component using at least one feature shared by the two or more slide images within the graph component. Further, at step  136 , the graph components are aligned to form a composite image. The step of aligning the graph components to form a composite image includes pooling a respective set of features belonging to each of the graph components (e.g., composite feature set composed of all features in the community, F m =F 1   m ∪F 2   m ∪F 3   m  . . . for each community C m  in the VALIS technique described below), and aligning two or more of the graph components using the respective sets of features belonging to the two or more of the graph components. Alternatively or additionally, a final alignment can be performed, for example by aligning each slide images to its previous slide image, to form the composite image. Alternatively or additionally, the alignment of the slide images can optionally be refined. The alignment can be refined using dense optical flow. This disclosure contemplates using optical flow techniques known in the art. Such techniques are well known in the art and not described in further detail herein. It should be understood that this disclosure contemplates using other refinement algorithms including, but not limited to, deformable registration methods. 
     As discussed below, the slide images can be aligned using a transformation matrix (e.g., transformation matrix, M in the VALIS technique described below). For example, a transformation matrix for aligning the slide images can be determined. The step of determining the transformation matrix optionally includes selecting the transformation matrix from a plurality of transformation matrices, the selected transformation matrix having the lowest alignment error. 
     The techniques described above have successfully been used to align serial slices of multi-color immunohistochemistry, images of the same tissue that have undergone serval stain/wash cycles, and tumor microarrays with low error. This disclosure contemplates that the techniques can be used clinically, for example, as a pathologists&#39; tool for diagnostic purposes. In other words, this disclosure contemplates that the composite image (e.g., the aligned slide images) can optionally be further analyzed, for example, for diagnostic purposes. As an example, the composite image (e.g., the aligned slide images) may be used to assess the amount, and composition of, immune infiltrate into at tumor. Further, this digital pathology tool can also be used to compare tumor ecologies and spatial associations across groups, such as primary versus metastases, responders versus non-responders, grade, subtype, etc. Techniques and/or algorithms for digital pathology are known in the art and are therefore not described in further detail herein. 
     Example Computing Device 
     It should be appreciated that the logical operations described herein with respect to the various figures may be implemented (1) as a sequence of computer implemented acts or program modules (i.e., software) running on a computing device (e.g., the computing device described in  FIG. 2 ), (2) as interconnected machine logic circuits or circuit modules (i.e., hardware) within the computing device and/or (3) a combination of software and hardware of the computing device. Thus, the logical operations discussed herein are not limited to any specific combination of hardware and software. The implementation is a matter of choice dependent on the performance and other requirements of the computing device. Accordingly, the logical operations described herein are referred to variously as operations, structural devices, acts, or modules. These operations, structural devices, acts and modules may be implemented in software, in firmware, in special purpose digital logic, and any combination thereof. It should also be appreciated that more or fewer operations may be performed than shown in the figures and described herein. These operations may also be performed in a different order than those described herein. 
     Referring to  FIG. 2 , an example computing device  200  upon which embodiments of the invention may be implemented is illustrated. It should be understood that the example computing device  200  is only one example of a suitable computing environment upon which embodiments of the invention may be implemented. Optionally, the computing device  200  can be a well-known computing system including, but not limited to, personal computers, servers, handheld or laptop devices, multiprocessor systems, microprocessor-based systems, network personal computers (PCs), minicomputers, mainframe computers, embedded systems, and/or distributed computing environments including a plurality of any of the above systems or devices. Distributed computing environments enable remote computing devices, which are connected to a communication network or other data transmission medium, to perform various tasks. In the distributed computing environment, the program modules, applications, and other data may be stored on local and/or remote computer storage media. 
     In its most basic configuration, computing device  200  typically includes at least one processing unit  206  and system memory  204 . Depending on the exact configuration and type of computing device, system memory  204  may be volatile (such as random access memory (RAM)), non-volatile (such as read-only memory (ROM), flash memory, etc.), or some combination of the two. This most basic configuration is illustrated in  FIG. 2  by dashed line  202 . The processing unit  206  may be a standard programmable processor that performs arithmetic and logic operations necessary for operation of the computing device  200 . The computing device  200  may also include a bus or other communication mechanism for communicating information among various components of the computing device  200 . 
     Computing device  200  may have additional features/functionality. For example, computing device  200  may include additional storage such as removable storage  208  and non-removable storage  210  including, but not limited to, magnetic or optical disks or tapes. Computing device  200  may also contain network connection(s)  216  that allow the device to communicate with other devices. Computing device  200  may also have input device(s)  214  such as a keyboard, mouse, touch screen, etc. Output device(s)  212  such as a display, speakers, printer, etc. may also be included. The additional devices may be connected to the bus in order to facilitate communication of data among the components of the computing device  200 . All these devices are well known in the art and need not be discussed at length here. 
     The processing unit  206  may be configured to execute program code encoded in tangible, computer-readable media. Tangible, computer-readable media refers to any media that is capable of providing data that causes the computing device  200  (i.e., a machine) to operate in a particular fashion. Various computer-readable media may be utilized to provide instructions to the processing unit  206  for execution. Example tangible, computer-readable media may include, but is not limited to, volatile media, non-volatile media, removable media and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. System memory  204 , removable storage  208 , and non-removable storage  210  are all examples of tangible, computer storage media. Example tangible, computer-readable recording media include, but are not limited to, an integrated circuit (e.g., field-programmable gate array or application-specific IC), a hard disk, an optical disk, a magneto-optical disk, a floppy disk, a magnetic tape, a holographic storage medium, a solid-state device, RAM, ROM, electrically erasable program read-only memory (EEPROM), flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices. 
     In an example implementation, the processing unit  206  may execute program code stored in the system memory  204 . For example, the bus may carry data to the system memory  204 , from which the processing unit  206  receives and executes instructions. The data received by the system memory  204  may optionally be stored on the removable storage  208  or the non-removable storage  210  before or after execution by the processing unit  206 . 
     It should be understood that the various techniques described herein may be implemented in connection with hardware or software or, where appropriate, with a combination thereof. Thus, the methods and apparatuses of the presently disclosed subject matter, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as floppy diskettes, CD-ROMs, hard drives, or any other machine-readable storage medium wherein, when the program code is loaded into and executed by a machine, such as a computing device, the machine becomes an apparatus for practicing the presently disclosed subject matter. In the case of program code execution on programmable computers, the computing device generally includes a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. One or more programs may implement or utilize the processes described in connection with the presently disclosed subject matter, e.g., through the use of an application programming interface (API), reusable controls, or the like. Such programs may be implemented in a high level procedural or object-oriented programming language to communicate with a computer system. However, the program(s) can be implemented in assembly or machine language, if desired. In any case, the language may be a compiled or interpreted language and it may be combined with hardware implementations. 
     EXAMPLES 
     Example 1 
     The method (e.g., algorithm) described above with regard to  FIG. 1A  has successfully been used to align serial slices for several data sets with low error. This disclosure contemplates using the algorithm clinically as a pathologists&#39; tool for diagnostic purposes. Further, this digital pathology tool can also be used to compare tumor ecologies and spatial cell-cell interactions across groups, such as primary vs metastases, responders vs non-responders, grade, subtype, etc. 
     For example, the method described above has successfully been used to align serial slices for several data sets with low error, where error is distance between matched features in the current slide and the previous slide (if alignment was perfect, these feature positions would be in exactly the same spots): 
     1a) 30 colorectal adenoma whole mount biopsies, each with 7 dual-stained slides, each approximately 2 um in thickness. The width and height of the images is 914 px and 408 px, with a median error of 2.1 pixels. The results were used to align larger versions of the images with widths and heights of 104568 px and 234042 px. 
     1b) 15 colorectal adenoma whole mount biopsies, each with 7 dual-stained slides, each approximately 2 um in thickness. The width and height of the images is 914 px and 408 px, with a median error of 2.5 pixels. The results were used to align larger versions of the images with widths and heights of 104568 px and 234042 px. 
     1c) 48 ductal carcinoma in situ (DCIS) whole mount biopsies, each with 7 dual-stained slides, each approximately 2 um in thickness. The width and height of the images is 914 px and 408 px, with a median error of 2.3 pixels. The results were used to align larger versions of the images with widths and heights of 104568 px and 234042 px. 
     1c) 48 DCIS whole mount biopsies, each with 7 dual-stained slides, each approximately 2 um in thickness. The width and height of the images is 914 px and 408 px, with a median error of 2.3 pixels. The results were used to align larger versions of the images with widths and heights of 104568 px and 234042 px. 
     1d) 3 oral cancer tumor microarrays (TMA), each with 9 single-stained slides. The width and height of the images is 632 px and 837 px, with a median error of 5 pixels. 
     1e) 1 breast cancer tumor microarrays (TMA), with 2 single-stained slides. The width and height of the images is 632 px and 837 px, with a median error of 0.8 pixels. 
     1f) 1 region of interest within a renal tissue sample that had 39 single-stained slides of different sizes. The median width and height of the images is 300 px and 194 px, with a median error of 1.8 pixels. The results were used to align larger versions of the images with widths and heights of 505 px and 300 px. 
     1g) 1 DCIS whole mount biopsy that had 13 single stained slides, each slice being approximately 20 um apart. The median width and height of the images is 651 px and 483 px, with a median error of 4.3 pixels. The results were used to align larger versions of the images with widths and heights of 26033 px and 19334 px. 
     2) For the DCIS whole mount biopsy, with 13 slides, the method has been shown to be more accurate than aligning images by hand. The median error rate for aligning by hand is 5.1 px, while with a median error using this automated method is 4.3 pixels. 
     3) The method has successfully determined the correct order of the renal tissue sample set that had 38 slides. It has also determined the correct order of a DCIS dataset that has 72 serial slices. 
     4) The method has been used to use isolate region of interests across all slices in the series. This is accomplished by drawing a mask on 1 image, and using information for the alignment to apply the mask to each original image. 
     Example 2 
     A method, Virtual Alignment of pathology Image Series (VALIS), is described in the example below. VALIS is able to align not only ROI, but whole mount biopsies, and tumor microarrays (TMA), all at full resolution. VALIS is also capable of not only aligning images stained with H+E, but also samples stained for multiple, spatially varying, markers. Furthermore, for large series of images, VALIS does not require that the images be ordered, as the technique is able to optimally order the slides, often times in the same order they were sliced from the sample. VALIS is also a totally automated and adaptive pipeline. All that is required is a set of pre-processed images, and the results are aligned images and collection of transformation matrices that can be used to align the image sets. 
     One application of VALIS is in the 3D reconstruction of samples. Additionally, the ability to align a series of slices stained for different markers, which is another application for VALIS, is even more powerful, as it creates the opportunity to describe the tumor ecology while maintaining spatial structure. Once aligned, established spatial statistics commonly used in other fields, such as ecology and demography, can be used to describe and better understand the tumor microenvironment. Thus, VALIS facilitates novel analyses of the tumor ecology that potentially identify crucial interactions involved in oncogenesis. 
     Mass cytometry is an exciting method that makes it possible to study the spatial distribution of different cell types and their interactions. While more accurate, mass cytometry does have its drawbacks: it is currently very expensive and thus potentially has a limited user base; it is typically used for small regions of tumors, such as a core from a TMA. VALIS, on the other hand, does not have these limitations, as it can be used to align the whole tumor. Perhaps even more importantly, VALIS can applied to existing datasets, which is useful because it may be that the samples of interest no longer exist, and thus cannot be multiplexed with mass cytometry. Further, VALIS can be used to define the whole tumor, not only small regions. 
     VALIS overcomes the challenges of working with large unordered image sets that have a wide variety of stains by performing the alignments on small groups of similar images, and then stitching those groups together in an optimal order. Given a set of greyscale preprocessed images (made to look as similar as possible), VALIS first detects the KAZE features of each image, and then determines the similarity/difference between each pair of images by matching their features, creating a distance matrix, D. If the order of slicing is unknown, hierarchical clustering is then performed on D, generating a dendrogram T. The order of slices is then be inferred by optimally ordering the leaves of T such that most similar images are adjacent to one another in the series. 
     The image series is broken up into small groups of similar image by performing community detection on the nearest neighbor graph G, where each image (i.e. a vertex in G) has an edge between it and its most similar image. Within each community, images are aligned to the subset of features shared by all images in that community. Next, each community is stitched to the previous community using the full set of features in each community. At this point the images are roughly aligned, and optical flow is used to refine the alignment between each image and the previous image in the series. 
     The output of VALIS is a transformation matrix for each image that aligns it to the previous image in the series. Such matrices can be scaled to work on images of different sizes, meaning that VALIS can quickly find the matrices using small versions of the images, and the resulting matrices scaled to align much larger, higher resolution, copies of the images. Given a set of reference coordinates, it is also possible to use the transformation matrices to slice out aligned regions from the very large (e.g., 8 gigabyte (GB) size or more) images produced by microscopes. Thus, VALIS gives one the ability to align and analyze the tumor at whatever the desired resolution. 
     VALIS was tested on datasets representing several common scenarios: series of H+E, multi-color IHC, whole mount biopsies, small ROI, sets where the slices are thin and close together, sets where the slides are thick and far apart, sets where different individuals conducted the staining on different slices in the same image series. The accuracy of VALIS was assessed by calculating the Euclidean distance between matching features in each image and its previous image in the series. If the images are perfectly aligned, this distance, i.e. error, would be 0. Errors can be calculated using the median distance between the 25 best matching features the across the two images (taking the top number avoids including outliers that may have minimal impact on the alignment), or the average displacement between the overlapping areas of the two images, as measured by dense optical flow. The ability of VALIS to optimally order slides was tested by taking an image set in which the slice order is known, shuffling the images, and the comparing the order estimated by VALIS to the known order. 
     The error rate of VALIS is low, often being well below 5 pixels (see the table in  FIG. 3  and  FIGS. 4A and 4B ), and has been shown to be more accurate than aligning by hand (see  FIG. 4A ). 
       FIG. 4A  illustrates the comparison of the accuracy of VALIS (auto) versus aligning by hand (manual). The distance between matching features and the previous image in the series. In this image set, VALIS has lower error than when the same set of images are aligned by hand.  FIG. 4A  illustrates the alignment accuracy for different datasets. Y is the distance between matching features in each image and its previous image in the series. If alignments are perfect this value would be 0. 30 colorectal adenoma (CRA) whole mount biopsies, each with 7 dual-stained slides, each approximately 2 um in thickness. The dimensions of the images used to calculate error is 408×914 pixels. 15 colorectal carcinoma (CRC) whole mount biopsies, each with 7 dual-stained slides, each approximately 2 um in thickness. The dimensions of the images used to calculate error is 408×914 pixels. 48 ductal carcinoma in situ (DCIS) whole mount biopsies, each with 7 dual-stained slides, each approximately 2 um in thickness. The dimensions of the images used to calculate error is 408×914 pixels. 3 oral cancer tumor microarrays (TMA), each with 9 single-stained slides. The dimensions of the images used to calculate error is 632×837. 
     Ecological analysis. Distance matrix may reveal hidden structure, including, but not limited to, separating responders versus non-responders or how the tumors as wholes are different across tumor types. 
     Preprocessing: 
     The input to VALIS is a set of processed images. As KAZE features are used, these images should be greyscale, but may need to have additional modifications. The exact preprocessing steps will likely depend on the set of images, but two methods that have worked well with the test datasets are described below. However, the goal of the pre-processing step should be take make the images look as similar as possible and have a black background and lighter foreground highlighting tissue features. 
     The first method is to normalize each channel of the RGB image (truecolor image). This disclosure contemplates using RGB normalization techniques known in the art. Such techniques are well known in the art and not described in further detail herein. An example RGB normalization method is described in Wang et al., Robust image registration of biological microscopic images, Scientific Reports, 4:6050 EP, 2014. The normalized channels can then be recombined to create a normalized RGB image. This normalized RGB image is then converted to greyscale and optionally subjected to histogram equalization. 
     A second method is the convert the RGB image (truecolor image) to YUV colorspace, and then add the absolute values of the U and V channels. This disclosure contemplates using RGB to YUV conversion techniques known in the art. Such techniques are well known in the art and not described in further detail herein. The reasoning behind this method is to bring all pixels with color to the foreground, and push all greyscale pixels (e.g., those associated with empty areas of the slide or dust, dirt, etc. . . . ) to the background. 
     No matter the preprocessing method, the images provided to VALIS should not be too large. However, the transformation matrices found using the smaller images can be scaled to work on the full size images. Since this is based on feature matching, many motion models can be estimated, including, but not limited to, Euclidean, similarity, affine, or perspective. 
     Feature Detection: 
     The first step of the alignment pipeline is to detect the KAZE features of each image I i , denoted by F i . Each feature in the image has an original location of F i (x,y), but these positions change throughout the alignment processes. More specifically, the positions will change a total of four times: first when padding the image, moving the features {dot over (F)} i (x,y); next when aligning the features in each community, moving the features to {umlaut over (F)} i (x,y); they are then again moved when the communities are stitched together, being warped to  (x,y); arriving at their final location after refining the alignment. Note that the dot decorators indicate how many transformations the image and its features have undergone. 
     Build Distance Matrix: 
     The next step is to create a symmetric, hollow, n×n distance matrix, D, based on matching KAZE features between each pair of images. These distances, and associated similarities, are then used to optimally order the images and to build a graph of similar images. Brute force matching with crosschecking and random sample consensus (RANSAC) is used to match each feature F i  to the other feature F j . Information from these matches is then used to fill in D and quantify the similarity between images. Multiple distance/similarity metrics exist, but the best success has been had using either the number of matches, a, or Euclidean distance between F i  and F j . If using the number of matches, then s ij =a similarly between the two images, is just the number of matches, while distance 
     
       
         
           
             
               d 
               ij 
             
             = 
             
               
                 1 
                 a 
               
               . 
             
           
         
       
     
     If using Euclidean distances, then d ij =Σ k=1   a (f k,i −f k,j ) where k is the index of matching features, and 
     
       
         
           
             
               s 
               ij 
             
             = 
             
               
                 1 
                 
                   1 
                   + 
                   
                     d 
                     ij 
                   
                 
               
               . 
             
           
         
       
     
     Optimally Order Images: 
     For datasets where the order of the series is known, then this step (i.e., image ordering) can be skipped. Otherwise, for datasets where the order of the series is unknown, or not particularly important, then the following steps are used to optimally order the images based on their similarity. Hierarchical clustering using single linkage is performed on the distance matrix, yielding a dendrogram, T. The leaves of T each correspond to an image in I and can be ordered such that similarity of adjacent leaves is maximized. Assuming that each tissue slice is more similar to the slice immediately above/below than to slices further away, this process recovers the same order in which the serial slices were taken. Thus, given ϕ, the optimal order of the leaves of T, the images can be ordered such that the similarity of adjacent images is maximized, yielding the sorted collection of images. 
     Construct Graph and Detect Communities: 
     Next, an undirected graph G(V,E) is constructed by connecting each image to its nearest neighbor in feature space. That is, each vertex in V(G) corresponds to an image and its feature set, with an edge between each image and its most similar image. In other words, there is an edge between image I i  and the image I j  associated with the maximum s ij . The edge weights of this graph are equal to the similarity of the two images. 
     Community detection is then performed on G(V,E). This disclosure contemplates using community detection techniques known in the art. Such techniques are well known in the art and not described in further detail herein. An example community detection method is described in Blondel et al., Fast Unfolding of Communities in Large Networks, 2008. This disclosure contemplates using other methods of community detection, and the method does not seem to be too sensitive to the exact method chosen. Following community detection, each V i (G), and the associated I i  and F i , is assigned to its community, m. These communities are used to perform subsets of alignments, and then all communities stitched together in series. 
     Pad Images: 
     By this point, the order of images and their communities assignments have been determined. Given this structure, the process of finding the transformation matrices can begin. To avoid cropping, the first step is to estimate the dimensions of an image that can accommodate all warped images, and find the translation matrix that will pad each image to fit within those dimensions. This can be estimated by finding the maximum width and height of each image if it had been rotated 45 degrees, the amount of rotation that would most increase either dimension. For each image, its width and height after 45 degree rotation is w i  cos(45)+h i  sin(45) and w i  sin(45)+h i  cos(45), where w i  and h i  are the width and height of the un-rotated image, respectively. Therefore, w max  and h max  are the maximum width and height given these possible rotations. The translation that pads each image is then shown as: 
     
       
         
           
             
               P 
               i 
             
             = 
             
               
                 [ 
                 
                   
                     
                       1 
                     
                     
                       0 
                     
                     
                       
                         
                           0 
                           . 
                           5 
                         
                         ⁢ 
                         
                           ( 
                           
                             
                               w 
                               
                                 ma 
                                 ⁢ 
                                 
                                     
                                 
                                 ⁢ 
                                 x 
                               
                             
                             - 
                             
                               w 
                               i 
                             
                           
                           ) 
                         
                       
                     
                   
                   
                     
                       0 
                     
                     
                       1 
                     
                     
                       
                         
                           0 
                           . 
                           5 
                         
                         ⁢ 
                         
                           ( 
                           
                             
                               h 
                               
                                 ma 
                                 ⁢ 
                                 
                                     
                                 
                                 ⁢ 
                                 x 
                               
                             
                             - 
                             
                               h 
                               i 
                             
                           
                           ) 
                         
                       
                     
                   
                   
                     
                       0 
                     
                     
                       0 
                     
                     
                       1 
                     
                   
                 
                 ] 
               
               . 
             
           
         
       
     
     After padding the image, the features have been shifted, which can be expressed as Ψ(F i (x,y),P i )→{dot over (F)} i (x,y), where Ψ((x,y),M) indicates warping points (x,y) using some transformation matrix, M. For simplicity, Ψ will be used to indicate warping of feature points F i (x,y) or the I i  itself. 
     Community Alignment: 
     The alignments can be performed in small batches using the communities detected as described above. The goal of this step is find features common to all images in community C m , and then align all community members to those shared features. Doing this ensures that all images are aligned to the same set of points while also removing spurious matches by finding only those features common to all community members. 
     For each community C m , all images are aligned to features in the single image that has the greatest median similarity to all other images in the community. This image may be considered the community&#39;s training image, and is denoted as I k   m . The training features used for alignments are the subset of features associated with I k   m  that all other images have matches with. In other words, the common feature set of the community is F k   m =F k,1   m ∩F k,2   m ∩F k,3   m  . . . . The matches between each F i  and F k   m  can then be used to find the transformation matrix, Â i   m , that aligns image I i   m  to the community training image, I k   m . However, when finding Â i   m  it is necessary to use the shifted positions of the features, {dot over (F)} i (x,y). 
     This transformation can be combined with the translation matrix found earlier, so that transformation aligns the images within an image with dimensions large enough to avoid cropping. This creates the transformation matrix A i   m =Â i   m P i , which has the same effect of padding the image and then applying the rigid affine transformation to align the images in the community. The position of each image&#39;s features after padding and community alignment is thus Ψ(F(x,y),A i   m )→{umlaut over (F)} i (x,y). 
     Community Stitching: 
     Given the order of slides, ϕ, determined as described above, it is possible to stitch each community to the previous community in the series. This is accomplished by building a composite feature set composed of all features in the community, F m =F 1   m ∪F 2   m ∪F 3   m  . . . for each community C m . Next, the composite feature set F m  is matched to F m-1 , using RANSAC and cross-checking to remove poor matches. 
     At this point, the images in each community are aligned to one another, and thus the features are all be in similar positions. Therefore, the matrix Â m  that warps features in F m  to align with those in F m-1  can be found using the positions of all features that match across the two communities. A special case is C 1 , which is essentially being aligned to itself, and so Â m-1  is the identity matrix. Am is then applied to every member of the community, aligning each feature in C m  to the features in C m-1 . 
     The position of the warped features after community stitching is denoted by  (x,y). Following stitching, the previous image&#39;s features have moved from where they were after community alignment, and so Â m  is estimated using {umlaut over (F)} m (x,y) and  (x,y). 
     As before, the transformation matrices can be combined to have the same effect of padding the image, aligning it within its community, and then aligning it to the previous community. This is accomplished with A i   c =Â c A i   m . Therefore, Ψ(F(x,y),A i   c )→ (x,y) warps the original features to align  with the images in its community and the previous aligned community. 
     Refining the Alignment: 
     When following the order of images defined by # as described above, warping each image I i  with its A i   c  yields Ψ(I i ,A i   c )= , and thus a series of roughly aligned images. The alignment of each image to the previous image in the series can be refined using dense optical flow, which estimates the displacement, (dx,dy), from the previous image,  , to the current image,  . This disclosure contemplates using optical flow techniques known in the art. Such techniques are well known in the art and not described in further detail herein. An example technique is DeepFlow. It should be understood that this disclosure contemplates using dense optical flow algorithms other than DeepFlow. The transformation matrix A i   f  can then be estimated by finding the transformation that maps (x,y)→(x−dx,y−dy). After being warped, the final aligned image is denoted as J i , i.e, φ( ,A i   f )→J i . As each previous image in the series has been warped, A i   f  is found by determining the displacement between   to J i-1 , not   and  . The final transformation matrix that aligns I i  is thus A i =A i   f A i   c , which is equivalent to padding the image, aligning it within its community, stitching it to the images in the previous community, and then refining its alignment to the previous image in the series. 
     Warping: 
     The transformation matrices estimated by VALIS can be scaled to work on resized copies of the images. For example, it is useful to find the matrices using smaller versions of the images, and then scale the transformation matrices to work on the larger image that needs to be aligned. This scaled transformation matrix can be found as S i A i S t   −1 , where 
     
       
         
           
             
               S 
               i 
             
             = 
             
               [ 
               
                 
                   
                     
                       s 
                       x 
                     
                   
                   
                     0 
                   
                   
                     0 
                   
                 
                 
                   
                     0 
                   
                   
                     
                       s 
                       y 
                     
                   
                   
                     0 
                   
                 
                 
                   
                     0 
                   
                   
                     0 
                   
                   
                     1 
                   
                 
               
               ] 
             
           
         
       
     
     and s x  and s y  are the scaling factors between I i  and the resized copy of the image. 
     Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.