the recent development of whole slide imaging ( wsi ) is rapidly making many advances in pathology and enabling the creation of novel tools and applications for the pathology community , including virtual microscopy , and computer - aided quantification and diagnosis . in contrast to conventional light microscopy that allows only a view of a fraction of a specimen at a time , wsi offers a digital replica of an entire histopathology slide . the data can be processed with a pattern recognition algorithm to identify features of interest . this technique , called whole slide pattern recognition , can provide more information than traditional pathology slide analysis , minimizes tedious visual inspection by trained pathologists and has the potential to improve clinical diagnosis . first of all , a typical wsi dataset can contain a number of pixels at tera - scale ( 10 ) and previous computational methods used to identify targets on traditional histopathology images , including texture - analysis , nuclei pattern classification , and edge detection , are impractical for wsi due to computational time requirements . parallel processing strategies have been developed to handle wsi ; however , boundary artifacts can jeopardize the integration of the analysis results and introduce a substantial amount of re - processing time . in addition , the abundant information provided by the whole slide analysis also requires a method to provide a quantitative assessment and to present meaningful results in a manner that is easy to interpret . in this paper , we report a wsi analysis method that conducts automatic stain recognition to estimate the density distribution of the recognized stains across an entire pathology slide . the whole slide images were tessellated into smaller image blocks with overlapping regions at the image boundary to enable parallel processing . pixel - based stain recognition with morphological smoothing was applied to identify stains in the tessellated images . the density distribution of the identified stains was calculated by the kernel density estimator , yielding a distribution image of a feature or a particular cell type labeled by the stains . to validate our method , we applied it to specimen slides from an ongoing study using a rat cardiac allograft rejection model and also another study using a rat heart ischemia / reperfusion injury model . in both studies , the macrophage infiltration was revealed by immunohistochemistry ( ihc ) with anti - rat ed1 antibody . the accuracy of the stain recognition algorithm was first validated by comparing its results with manual counting without involving the wsi technique . the pathology images were obtained with a standard light microscope and the results of our stain recognition algorithm were compared with those obtained from manual counting . then , our method was further validated / correlated with the results obtained from in - vivo cellular magnetic resonance imaging ( mri ) , an imaging technique that can detect macrophage infiltration when labeled with ultrasmall superparamagnetic iron - oxide ( uspio ) or micron - sized iron - oxide ( mpio ) particles . our method was also validated / correlated with the results obtained from ex - vivo cellular mri , which were conducted using magnetic resonance microscopy ( mrm ) to achieve a much higher resolution for our final examination . to demonstrate the potential utilities of our method , we trained the algorithm to recognize different targets under hematoxylin and eosin ( h and e ) stain and to present their distribution across the tissue sections . we further calculated the diameter of the recognized targets and estimated the spatial distribution of cell nuclear diameter , which may have potential application in characterizing tissue in histopathology slides . the rat cardiac allograft rejection model , as described in a study , was established using dark agouti and brown norway rats ( harlan , indianapolis , in ) as the donor - recipient transplantation pairs . the superior vena cava of the graft heart was anastomosed to the recipient inferior vena cava ( ivc ) and the aorta of the graft heart was anastomosed to the recipient abdominal aorta , with the recipient proximal ivc partially obstructed to increase the pre - load . the graft , with intact pulmonary circulation , received proper pressure and volume loading without detectable atrophy over time . on day 7 after the transplantation , the graft hearts were scanned using in - vivo cellular mri and then harvested for pathology inspections . a suture was tied around the left anterior descending artery for 45 min and then was cut to allow reperfusion . after 2 days , the heart was harvested and scanned by ex - vivo mrm . cellular mri experiments were conducted by using dextran - coated uspio particles or polystyrene - coated mpio particles ( bangs laboratories , fishers , in ) as an mri contrast agent to image macrophage distribution . the iron - oxide particles are taken up by macrophages in circulation and create signal - voids in t2 * -weighted images to reveal the macrophage infiltration in - vivo , offering a unique way to correlated the ihc stain distribution obtained from our method . in our study , the iron - oxide particles were given to the animals before surgery . the rats , undergoing heterotopic heart transplantation , received uspio particles and were scanned by in - vivo cellular mri . the in - vivo mri scan was conducted on a bruker 7-t scanner ( bruker , billerica ma ) . the rats were intubated and ventilated during the mri scan and electrocardiogram ( ecg ) leads were placed on the abdomen using a gating and monitoring system ( sa instruments , stony brook , ny ) . t2 * -weighted magnetic resonance ( mr ) images , an imaging modality known to be sensitive to the signal void artifact created by iron - oxide particles , were acquired using a flash sequence with ecg and respiratory gating . tr = the respiration cycle ( ~1 s ) , te = 5 ms , field of view ( fov ) = 4 cm , slice thickness = 1.5 mm , in - plane resolution = 156 m . the ex - vivo mri scans were conducted using a bruker 11.7-tesla scanner ( bruker , billerica ma ) . t2 * -weighted mr images were also acquired using a flash sequence with te = 5.8 ms , fov = 1.2 cm , and isotropic resolution = 23 m . the hearts were fixed in 4% paraformaldehyde for 1 - 2 weeks and embedded in paraffin . # dc2002 ) , which streamed slides in preheated high ph target retrieval solution ( dako # s3308 , carpinteria , ca , usa ) for 15 min . this was followed by cooling of the slides at room temperature for 20 min and rinsing the slides in distilled water before commencing the staining steps . to stain the slides , the tissue sections were incubated with 10% horse serum for 10 min at room temperature to block non - specific binding . the slides were then incubated with 1:200 anti - rat ed1 monoclonal purified immunoglobulin g ( abd serotec , oxford , uk ) for 2 h. after pbs wash , the slides were incubated with biotinylated secondary antibodies ( lsab kit , dako , carpinteria , ca , usa ) for 30 min and labeled with the streptavidin - horseradish peroxidase ( dako , carpinteria , ca , usa ) for 30 min . then the slides were stained with aminoethyl carbazole chromogen ( skytek laboratories , inc . , a rat spleen tissue section was used as a positive control section , whereas a normal rat cardiac tissue was used as a negative control section . the stained slides were scanned on a whole slide scanner ( nanozoomer 2.0-ht , hamamatsu , japan ) to acquire wsi at 20 magnification . the resulting pathology images were then processed by our whole slide pattern recognition method , as detailed in the following section . the whole slide image was tessellated to enable the whole slide pattern recognition , as shown in figure 1 . the tessellation lines divide the whole slide image into several n - by - n sized blocks and the choice of n depends on the application scenario and the applied recognition algorithm . a higher value offers a larger field of view , but it may exceed the maximum allowable image size for the algorithm . after tessellation , each block was padded with an additional margin , m - pixel wide , to the neighboring block . the padding setting was devised for accurate accounting of stains near the block boundary , since a strict boundary could bisect a stain , incorrectly assigning it to both neighboring blocks . the choice of m considers the span of individual stain and requires prior information about their morphology . an m - pixel - wide margin allows stains with a maximum span of m to be fully recognized within the tessellated image . in our study , we used n = 1000 and the value of m was set to 100 . the tessellation scheme for the whole slide pattern recognition . the whole slide image is tessellated into n - by - n sized blocks to enable parallel recognition . each block is patched with additional m - width margin to consider stains bisected by the tessellation boundary the center of each recognized stain can be used to determine whether it should be counted or ignored to avoid double counting of stains , as illustrated by the example scenario in figure 2 . one should note that the tessellation borders are present at all sides of the tessellated image and figure 2 shows only the border between two adjacent images blocks to simplify the illustration . as shown in figure 2a , our stain recognition algorithm is applied to the image block to the left and the recognized stains with center points inside the tessellation line ( annotated by yellow ) are counted , whereas those outside the line ( annotated by red ) are ignored . similarly , in figure 2b , our stain recognition algorithm is applied to the image block to the right . the recognized stains with center points inside the tessellation line ( annotated by yellow ) are counted , whereas the rest are ignored ( annotated by red ) . ( a ) the stain recognition is applied to the image block to the left to recognize the stains . the center locations of the stains ( marked by dot points ) are used to determine whether a recognized stain should be counted ( annotated by yellow ) or ignored ( annotated by red ) . ( b ) the stain recognition is applied to the image block to the right , showing how double counting is avoided . the counted stains ( annotated by yellow ) have center points located inside the tessellation line the flow chart of our stain recognition algorithm is shown in figure 3 . the method is composed of three modules , including a classification module that performs pixel - wise color classification , a morphology smoothing module that eliminates the fragments considered to be false positives and an analysis module that identifies each isolated stain region . it is noteworthy that a variety of stain recognition algorithms can be applied to this problem , and in this study , we have used the simplest pixel - wise color recognition approach for its low computation time and stable performance . the red - green - blue color channels were used as the classification features and the output ( classification result ) was either 0 ( background ) or 1 ( foreground ) . the stain classification was conducted using nearest neighbor method , a popular method in data mining . nearest neighbor method required a training dataset of background and foreground stain image . in this study , we manually cropped the background and foreground stain from the wsi data as the training dataset . alternatively , one may also get training data from the positive and negative controls . the nearest neighbor method classified each image pixel based on its color difference with the pixels in the training images . if the minimum difference was from the foreground stain , then the pixel was classified as foreground ; otherwise , it was classified as background . this classification was applied to each pixel in the input image [ figure 3b ] to obtain the binary recognition output [ figure 3c ] . this output image might have small fragments due to error classification or the partial slice coverage of the stained cells . to eliminate fragments in the binary images and to facilitate analysis , morphological opening and closing were applied 3 times using a 3-by-3 square structuring element to smooth the contours of the recognized stains , as shown in figure 3d . finally , the connected component analysis identified each isolated stain region in the image and the center location of each stain was calculated for further density estimation . the pixel - wise classification is trained by a foreground stain image and also a background stain image ( a ) . each pixel of the input image ( b ) is then classified using nearest neighbor classification to obtain a binary image ( c ) . the small fragments in the binary image are then eliminated by morphological closing and opening , resulting in a smoother output ( d ) . this image is then analyzed by connected component analysis to obtain the center locations of the recognized stains since the locations of the recognized stains were discrete points scattered across the wsi , a regression analysis method was used to calculate their density distribution . this was carried out by the kernel density estimator as shown in figure 4 , where figure 4a shows an exemplary result of the discrete stain locations and figure 4b shows their density distribution estimated by the kernel density estimator . we had a total of k stains obtained from our whole slide pattern recognition and each of them was located at coordinate xi . the kernel density estimator estimated the density distribution function by using the following formulae : the exemplary analysis result of the kernel density estimator . ( b ) their density distribution can be estimated by the kernel density estimator where h is the kernel bandwidth and is the kernel function . the scalar feature ( e.g. diameter or area ) of the k recognized stains can also be estimated using kernel regression . where yi is a scalar feature of the i stain . equation 2 can be used to estimate the spatial distribution of the feature across the entire pathology slide . the bandwidth of the kernel determines the variability of the density estimation . a higher value of the bandwidth generates a smoothing effect , leading to reduced variability . on the contrary , a lower value creates a sharper estimation , but may cause over - fitting and larger variability . in this study , we used a data - driven method to automatically determine the bandwidth . we used equation 1 to estimate the ed1 stain distribution images and equation 2 to estimate the spatial distribution of the stain feature . the source codes of our whole slide recognition program ( ws recognizer ) are publicly available at http://ws-recognizer.labsolver.org . the validation was conducted using a total of 4 rats from the acute cardiac allograft rejection study in our laboratory . for each rat , one tissue section was obtained from the mid portion of the excised heart . for each slide , 16 pathology images were acquired on a transmitted light microscope ( olympus proves ax 70 ) at 40 objective lens . the field of view covered different areas in the slide to acquire images with different macrophage density . in each pathology image , manual counting and automatic stain recognition were conducted separately to avoid a spurious correlation between the manual counting and the automated recognition . manual counting was conducted without knowing the stain recognition results and the training data for automatic recognition were selected without knowledge of the manual - counting results . the final comparison was conducted by performing regression analysis to calculate the correlation coefficient . to validate our method on wsi data , we compared the ed1 stain distribution image with both in - vivo and ex - vivo cellular mr images . to facilitate a visual comparison , the orientations of the mr images were manually rotated to match those of the pathology images . the hypointensity patches shown in the t2 * -weighted images were due to the accumulation of the iron - oxide labeled macrophages , a feature that allowed us to examine whether our ed1 stain distribution image was in good agreement with the distribution shown on cellular mri . the rat cardiac allograft rejection model , as described in a study , was established using dark agouti and brown norway rats ( harlan , indianapolis , in ) as the donor - recipient transplantation pairs . the superior vena cava of the graft heart was anastomosed to the recipient inferior vena cava ( ivc ) and the aorta of the graft heart was anastomosed to the recipient abdominal aorta , with the recipient proximal ivc partially obstructed to increase the pre - load . the graft , with intact pulmonary circulation , received proper pressure and volume loading without detectable atrophy over time . on day 7 after the transplantation , the graft hearts were scanned using in - vivo cellular mri and then harvested for pathology inspections . a suture was tied around the left anterior descending artery for 45 min and then was cut to allow reperfusion . after 2 days , the heart was harvested and scanned by ex - vivo mrm . cellular mri experiments were conducted by using dextran - coated uspio particles or polystyrene - coated mpio particles ( bangs laboratories , fishers , in ) as an mri contrast agent to image macrophage distribution . the iron - oxide particles are taken up by macrophages in circulation and create signal - voids in t2 * -weighted images to reveal the macrophage infiltration in - vivo , offering a unique way to correlated the ihc stain distribution obtained from our method . in our study , the iron - oxide particles were given to the animals before surgery . the rats , undergoing heterotopic heart transplantation , received uspio particles and were scanned by in - vivo cellular mri . the in - vivo mri scan was conducted on a bruker 7-t scanner ( bruker , billerica ma ) . the rats were intubated and ventilated during the mri scan and electrocardiogram ( ecg ) leads were placed on the abdomen using a gating and monitoring system ( sa instruments , stony brook , ny ) . t2 * -weighted magnetic resonance ( mr ) images , an imaging modality known to be sensitive to the signal void artifact created by iron - oxide particles , were acquired using a flash sequence with ecg and respiratory gating . tr = the respiration cycle ( ~1 s ) , te = 5 ms , field of view ( fov ) = 4 cm , slice thickness = 1.5 mm , in - plane resolution = 156 m . the ex - vivo mri scans were conducted using a bruker 11.7-tesla scanner ( bruker , billerica ma ) . t2 * -weighted mr images were also acquired using a flash sequence with te = 5.8 ms , fov = 1.2 cm , and isotropic resolution = 23 m . the hearts were fixed in 4% paraformaldehyde for 1 - 2 weeks and embedded in paraffin . # dc2002 ) , which streamed slides in preheated high ph target retrieval solution ( dako # s3308 , carpinteria , ca , usa ) for 15 min . this was followed by cooling of the slides at room temperature for 20 min and rinsing the slides in distilled water before commencing the staining steps . to stain the slides , the tissue sections were incubated with 10% horse serum for 10 min at room temperature to block non - specific binding . the slides were then incubated with 1:200 anti - rat ed1 monoclonal purified immunoglobulin g ( abd serotec , oxford , uk ) for 2 h. after pbs wash , the slides were incubated with biotinylated secondary antibodies ( lsab kit , dako , carpinteria , ca , usa ) for 30 min and labeled with the streptavidin - horseradish peroxidase ( dako , carpinteria , ca , usa ) for 30 min . then the slides were stained with aminoethyl carbazole chromogen ( skytek laboratories , inc . , a rat spleen tissue section was used as a positive control section , whereas a normal rat cardiac tissue was used as a negative control section . the stained slides were scanned on a whole slide scanner ( nanozoomer 2.0-ht , hamamatsu , japan ) to acquire wsi at 20 magnification . the resulting pathology images were then processed by our whole slide pattern recognition method , as detailed in the following section . the whole slide image was tessellated to enable the whole slide pattern recognition , as shown in figure 1 . the tessellation lines divide the whole slide image into several n - by - n sized blocks and the choice of n depends on the application scenario and the applied recognition algorithm . a higher value offers a larger field of view , but it may exceed the maximum allowable image size for the algorithm . after tessellation , each block was padded with an additional margin , m - pixel wide , to the neighboring block . the padding setting was devised for accurate accounting of stains near the block boundary , since a strict boundary could bisect a stain , incorrectly assigning it to both neighboring blocks . the choice of m considers the span of individual stain and requires prior information about their morphology . an m - pixel - wide margin allows stains with a maximum span of m to be fully recognized within the tessellated image . in our study , we used n = 1000 and the value of m was set to 100 . the tessellation scheme for the whole slide pattern recognition . the whole slide image is tessellated into n - by - n sized blocks to enable parallel recognition . each block is patched with additional m - width margin to consider stains bisected by the tessellation boundary the center of each recognized stain can be used to determine whether it should be counted or ignored to avoid double counting of stains , as illustrated by the example scenario in figure 2 . one should note that the tessellation borders are present at all sides of the tessellated image and figure 2 shows only the border between two adjacent images blocks to simplify the illustration . as shown in figure 2a , our stain recognition algorithm is applied to the image block to the left and the recognized stains with center points inside the tessellation line ( annotated by yellow ) are counted , whereas those outside the line ( annotated by red ) are ignored . similarly , in figure 2b , our stain recognition algorithm is applied to the image block to the right . the recognized stains with center points inside the tessellation line ( annotated by yellow ) are counted , whereas the rest are ignored ( annotated by red ) . ( a ) the stain recognition is applied to the image block to the left to recognize the stains . the center locations of the stains ( marked by dot points ) are used to determine whether a recognized stain should be counted ( annotated by yellow ) or ignored ( annotated by red ) . ( b ) the stain recognition is applied to the image block to the right , showing how double counting is avoided . the counted stains ( annotated by yellow ) have center points located inside the tessellation line the flow chart of our stain recognition algorithm is shown in figure 3 . the method is composed of three modules , including a classification module that performs pixel - wise color classification , a morphology smoothing module that eliminates the fragments considered to be false positives and an analysis module that identifies each isolated stain region . it is noteworthy that a variety of stain recognition algorithms can be applied to this problem , and in this study , we have used the simplest pixel - wise color recognition approach for its low computation time and stable performance . the red - green - blue color channels were used as the classification features and the output ( classification result ) was either 0 ( background ) or 1 ( foreground ) . the stain classification was conducted using nearest neighbor method , a popular method in data mining . nearest neighbor method required a training dataset of background and foreground stain image . in this study , we manually cropped the background and foreground stain from the wsi data as the training dataset . the nearest neighbor method classified each image pixel based on its color difference with the pixels in the training images . if the minimum difference was from the foreground stain , then the pixel was classified as foreground ; otherwise , it was classified as background . this classification was applied to each pixel in the input image [ figure 3b ] to obtain the binary recognition output [ figure 3c ] . this output image might have small fragments due to error classification or the partial slice coverage of the stained cells . to eliminate fragments in the binary images and to facilitate analysis , morphological opening and closing were applied 3 times using a 3-by-3 square structuring element to smooth the contours of the recognized stains , as shown in figure 3d . finally , the connected component analysis identified each isolated stain region in the image and the center location of each stain was calculated for further density estimation . the pixel - wise classification is trained by a foreground stain image and also a background stain image ( a ) . each pixel of the input image ( b ) is then classified using nearest neighbor classification to obtain a binary image ( c ) . the small fragments in the binary image are then eliminated by morphological closing and opening , resulting in a smoother output ( d ) . this image is then analyzed by connected component analysis to obtain the center locations of the recognized stains since the locations of the recognized stains were discrete points scattered across the wsi , a regression analysis method was used to calculate their density distribution . this was carried out by the kernel density estimator as shown in figure 4 , where figure 4a shows an exemplary result of the discrete stain locations and figure 4b shows their density distribution estimated by the kernel density estimator . we had a total of k stains obtained from our whole slide pattern recognition and each of them was located at coordinate xi . the kernel density estimator estimated the density distribution function by using the following formulae : the exemplary analysis result of the kernel density estimator . ( b ) their density distribution can be estimated by the kernel density estimator where h is the kernel bandwidth and is the kernel function . the scalar feature ( e.g. diameter or area ) of the k recognized stains can also be estimated using kernel regression . where yi is a scalar feature of the i stain . equation 2 can be used to estimate the spatial distribution of the feature across the entire pathology slide . a higher value of the bandwidth generates a smoothing effect , leading to reduced variability . on the contrary , a lower value creates a sharper estimation , but may cause over - fitting and larger variability . in this study , we used a data - driven method to automatically determine the bandwidth . we used equation 1 to estimate the ed1 stain distribution images and equation 2 to estimate the spatial distribution of the stain feature . the source codes of our whole slide recognition program ( ws recognizer ) are publicly available at http://ws-recognizer.labsolver.org . the validation was conducted using a total of 4 rats from the acute cardiac allograft rejection study in our laboratory . for each rat , one tissue section was obtained from the mid portion of the excised heart . for each slide , 16 pathology images were acquired on a transmitted light microscope ( olympus proves ax 70 ) at 40 objective lens . the field of view covered different areas in the slide to acquire images with different macrophage density . in each pathology image , manual counting and automatic stain recognition were conducted separately to avoid a spurious correlation between the manual counting and the automated recognition . manual counting was conducted without knowing the stain recognition results and the training data for automatic recognition were selected without knowledge of the manual - counting results . to validate our method on wsi data , we compared the ed1 stain distribution image with both in - vivo and ex - vivo cellular mr images . to facilitate a visual comparison , the orientations of the mr images were manually rotated to match those of the pathology images . the hypointensity patches shown in the t2 * -weighted images were due to the accumulation of the iron - oxide labeled macrophages , a feature that allowed us to examine whether our ed1 stain distribution image was in good agreement with the distribution shown on cellular mri . the sample result of the stain recognition algorithm is shown in figure 5a , where the recognized stains are annotated by the yellow contour . the training images are presented in figure 5b and c , which are the background and foreground ihc stain images , respectively . the image shows the infiltration of ed1 macrophages due to acute cardiac allograft transplant rejection and the brownish ihc stains were identified by our recognition method . the total numbers of macrophages were counted by summing up the number of annotated regions in the image and the center point of each annotated region can be calculated to facilitate further stain density estimation . the result of our stain recognition and the training images used in the stain classification . ( a ) the stain recognition is applied to a pathology image of myocardium under acute cardiac allograft rejection , where macrophage accumulation revealed by immunohistochemistry ( ihc ) stains can be recognized by our algorithm . the stain recognition algorithm is trained by using one background image ( b ) and one foreground ihc stain image ( c ) and the recognized stains are annotated by yellow to illustrate the performance of our algorithm the result of the manual validation is shown in figure 6 , where the numbers of ihc stains counted by our automated stain recognition algorithm were correlated with manual counting . the analysis shows an r = 0.8029 and a correlation coefficient of 0.8961 between the number of cells counted manually and that recognized by our algorithm , suggesting that the results obtained from our automatic recognition algorithm was in good agreement with the manual counting results . the narrow bank of the confidence interval further suggests that the high correlation result is highly reproducible . one may note that the coefficient of the regression line was 0.445 , meaning that the automatic recognition algorithm tends to count twice as many as that by the manual counting . the systematic overestimation of the algorithm could be due to the fact that the algorithm counted the ihc stains regardless of their size , whereas manual counting may have ignored small stains . a feasible approach to improve consistency is adding a size filter to the stain recognition algorithm . nonetheless , this discrepancy does not invalidate our stain distribution images , since the high correlation coefficient ensured that our recognition algorithm revealed the same distribution pattern and only differed by a scaling factor . the regression analysis shows the correlation between the number of stain recognized by our stain recognition algorithm and that by the manual counting . the analysis has included 64 observations and the regression line is presented between the 95% confidence band . the regression analysis shows an r = 0.8029 and a correlation coefficient of 0.8961 , suggesting a high correlation between manual counting and our stain recognition algorithm the in - vivo cellular mri is shown in figure 7 , where the t2 * -weighted image ( left ) was compared with the ed1 stain distribution image ( right ) . the animal from our rat heart transplantation model developed acute cardiac rejection and uspio was used as a macrophage - labeling agent in the cellular mri . as shown in figure 7a , the signal - void artifact in the t2 * -weighted mr image , as illustrated by the arrow , suggested the accumulation of uspio - labeled macrophages in the endocardium of the left ventricle . in comparison , our ed1 stain distribution image shown in figure 7b illustrated a similar pattern of accumulation of ed1 macrophages in the endocardium . one may note that the t2 * -weighted image does not match perfectly with the ed1 stain distribution image . this may be due to the fact that there could be tissue distortion during the fixation procedure and that the images may not align perfectly with the pathology slides . despite this difference , the highly similar pattern suggested that our method can be used to reveal ed1 macrophages within pathology slides . the in - vivo cellular magnetic resonance ( mr ) images correlates with the ed1 stain distribution image . ( a ) the in - vivo t2 * -weighted cellular mr image , where the macrophages labeled with ultrasmall superparamagnetic iron - oxide particles create hypo - intensity patches ( annotated by arrows ) in the myocardium that develops acute allograft rejection . ( b ) the corresponding ed1 stain distribution image shows a similar pattern of the macrophages accumulation in the endocardium . the hypo - intensity patches in ( a ) correspond to the hyper - intensity locations in ( b ) the ex - vivo mrm is shown in figure 8 , where the t2 * -weighted image of the ex - vivo tissue ( left ) was compared with the ed1 stain distribution image ( right ) . the rat was from our model of ischemia / reperfusion injury , with mpio particles used as the macrophage labeling agent in the cellular mrm . the tissue section is outlined ( black ) in the ed1 stain distribution image to facilitate comparison . as shown in figure 8a , the mpio - labeled macrophages generate dark patches and spots in the mrm images , suggesting massive macrophage infiltration in the myocardium with ischemia / reperfusion injury . similarly , our ed1 stain distribution image shown in figure 8b showed the same pattern of ed1 macrophage infiltration in the left ventricle . the high similarity of both imaging approaches confirmed that our method can reliably identify ed1 macrophages within pathology slides . the ex - vivo cellular magnetic resonance microscopy ( mrm ) correlates with the ed1 stain distribution image . ( a ) the ex - vivo t2 * -weighted cellular mrm , where the macrophages labeled with micron - sized iron - oxide particles create hypo - intensity patches in the myocardium that has ischemia / reperfusion injury ( b ) the corresponding ed1 stain distribution image shows highly similar pattern of macrophages accumulation in the myocardium , suggesting that the ed1 stain distribution image can reveal the macrophage infiltration across an entire pathology slide figure 9a shows the spatial distribution of the cell nucleus , lipofusin and red blood cell in 3 rats with heart ischemia / reperfusion injury . the stain recognition algorithm was trained to recognize cell nuclei ( n ) , lipofusin ( l ) and red blood cells ( r ) under h and e stain , as shown in figure 9b . the distribution of cell nuclei can be used to investigate the increase of immune cells during the inflammation process , whereas the distribution of lipofusin may be used to investigate oxidative stress in the myocardium . both three distribution images offer paranomic pathology information of the ischemia / reperfusion injury across tissue sections . the spatial distribution of cell nucleus , lipofusin and red blood cell in rat hearts with ischemia / reperfusion injury . ( a ) the spatial distribution of cell nucleus , lipofusin and red blood cell in 3 rats . ( b ) the stain recognition algorithm was trained to cell nuclei ( n ) , lipofusin ( l ) and red blood cells ( r ) under h and e stain . these three distribution images offer paranomic pathology information that facilitates quantitative characterization in histopathology figure 10 is an example of feature distribution image showing the spatial distribution of the cell nuclear diameter . the diameter of the recognized cell nuclei was estimated using the kernel regression formulated in equation 2 . the feature distribution image can be used to provide a quantitative evaluation of a particular feature and to assist tissue characterization in histopathology . a feature distribution image showing the spatial distribution of the cell nuclear diameter . the cell nuclei were recognized under h and e stain and the spatial distribution of their diameter can be estimated using kernel regression . in this paper , we report on an automated method that conducts whole slide pattern recognition to obtain the stain distribution . regression analysis showed a correlation coefficient of 0.8961 between manual counting and our stain recognition algorithm , suggesting that the labor intensive manual counting may be replaced by our automated recognition algorithm , which is critical for further analysis of the image data from wsi . moreover , the ed1 stain distribution image was in good agreement with both in - vivo cellular mri and ex - vivo cellular mrm . the high density areas revealed in the ed1 stain distribution images correlated well with the hypo - intensity areas generated by iron - oxide - labeled macrophages , suggesting that our method can serve as a surrogate to reveal the distribution of macrophages across tissue sections . the novelty of our approach includes the following : first , we have implemented a parallel processing approach that makes whole slide pattern recognition possible . it is possible that the same processing approach can be combined with more advanced pattern recognition algorithms to extract meaningful features from pathology / ihc digital slides . second , the stain distribution images obtained from our method offered a panorama of pathology information instead of a fraction of a view under the light microscope . this panoramic view is less susceptible to errors caused by subjective selection of the data . in contrast , traditional pathology validation often requires expert selection of the lesion site , making the process subjective and potentially biased . whole slide pattern recognition leaves no bias and presents all the information across the pathology slide to offer more objective results . third , the stain distribution images are quantitative information that can be further analyzed statistically . this unique feature is provided by the kernel density estimator , which is a widely - used regression approach in the field of statistics and has been used in a variety of real world applications . lastly , our method can be fully automated and no human intervention is needed to obtain the stain distribution mapping . this offers a highly objective and efficient method that may enable a high throughput processing of data and massive screening . despite the many advantages mentioned above , there are several possible pitfalls in our method that are noteworthy of discussion . the accuracy of our method depends on the performance of the recognition algorithm and it is possible that an algorithm may give false positive results secondary to poor slide preparation or artifacts in the preparation . similarly , the stain variability may alter the recognition results and may create a false perception of the changes in the stain distribution . both pitfalls may lead to misleading results that are hard to identify and thus , a post - processing inspection may be needed for quality control . first , we did only a qualitative comparison and did not conduct rigorous registration to compare our stain distribution imaging with mri . this limitation is due to the fact that the tissue specimen deforms substantially in the fixation process and the spatial information between mri and wsi can not be perfectly aligned . furthermore , the ex - vivo mri of the tissue - embedded paraffin block can not be acquired because the mr spectrum is dominated by the paraffin resonance . another limitation of our experiment is that we did not examine the positive and negative predicting values of our stain recognition algorithm . although the accuracy of the morphology - based stain recognition has already been examined , it is unclear whether the same performance can be achieved in counting macrophages due to their highly pleomorphic shapes . the current setting is optimized to identify stains with an oval shape , but there can be other morphological presentations in the pathology slides . to overcome this limitation , the algorithm can be customized to accommodate different morphology of the stains . moreover , although there is a positive correlation between the number of the recognized stains and manual cell counts , our stain recognition algorithm still tends to count more than that of manual counting . this may be due to the fact that macrophages have cytoplasmic projections that can lead to separated regions and result in duplicated counts . in addition , the nuclei of macrophages are often lobulated , further adding the complexity of the cell recognition in our use case scenario . counting last , the stain distribution value can be affected by several factors , including the thickness of the sections , the z - depth and the bandwidth used in the kernel density estimator . therefore , a comparison based on the stain - distribution value should be conducted in a carefully controlled manner . the obtained stain distribution image represents a panorama of the pathology information and can be used in both qualitative and quantitative analyses . this imaging approach may also assist pathologists in clinical diagnosis by offering them a toolkit for multiple applications in diagnostic pathology as well as yield newer methods to use image analysis to quantitate and analyze biomarkers , which are both diagnostic and prognostic . in addition , the algorithm described in this study may serve as a new and systematic approach to validate other imaging modalities . the ed1 stain distribution image confirms that the cellular mri technique is able to detect the macrophage infiltration of cardiac transplantation rejection or cardiac ischemic injury in our rat models .
background : whole slide imaging ( wsi ) offers a novel approach to digitize and review pathology slides , but the voluminous data generated by this technology demand new computational methods for image analysis.materials and methods : in this study , we report a method that recognizes stains in wsi data and uses kernel density estimator to calculate the stain density across the digitized pathology slides . 
 the validation study was conducted using a rat model of acute cardiac allograft rejection and another rat model of heart ischemia / reperfusion injury . 
 immunohistochemistry ( ihc ) was conducted to label ed1 + macrophages in the tissue sections and the stained slides were digitized by a whole slide scanner . 
 the whole slide images were tessellated to enable parallel processing . 
 pixel - wise stain classification was conducted to classify the ihc stains from those of the background and the density distribution of the identified ihc stains was then calculated by the kernel density estimator.results:the regression analysis showed a correlation coefficient of 0.8961 between the number of ihc stains counted by our stain recognition algorithm and that by the manual counting , suggesting that our stain recognition algorithm was in good agreement with the manual counting . 
 the density distribution of the ihc stains showed a consistent pattern with those of the cellular magnetic resonance ( mr ) images that detected macrophages labeled by ultrasmall superparamagnetic iron - oxide or micron - sized iron - oxide particles.conclusions:our method provides a new imaging modality to facilitate clinical diagnosis . 
 it also provides a way to validate / correlate cellular mri data used for tracking immune - cell infiltration in cardiac transplant rejection and cardiac ischemic injury .