# Define Neighborhoods

Neighborhood analysis finds the local composition of cells within a circular (spherical in 3D samples, or cylindrical if the thickness is less than the radius of the neighborhoods) area in the tissue. The number of cells and the MFI of each channel summed over all cells in each neighborhood, are calculated. This information can then be used to find local cellular densities, or look at patterns, tissue architecture, and cell-cell associations across your sample.

## Raster Scan Neighborhoods

The raster-scanned neighborhoods button creates a table of neighborhoods, where the position of each neighborhood is evenly distributed across the tissue in a grid pattern. Select which samples you wish to calculate neighborhoods for using field 1. The distance between neighborhoods is r/2, where r is the user-defined radius of the neighborhoods (field 2).

On the bottom of the interface define the radius of the neighborhoods you wish to calculate, 50 is the default. The units of r are whatever units your imported data are in. Assuming your microscope software exports spatial data in micrometers, this definition of r will also be in micrometers.

In field 3 you can select to calculate neighborhoods the 'Fast Way' or the 'Slow Way'. The fast way is vectorized and will run into memory problems if the dataset is large, where 'large' depends on your available ememory. The slow way uses for loops, and can handle larger datasets.

To start the calculation click the start scan button (field 4).

Note: If you wish to define smaller features you will need to use a smaller neighborhood radius. However, the smaller the neighborhoods the longer this, and resulting calculations will take. Additionally, if the radius of the neighborhood is smaller than the distance between cells, you will effectively be doing analysis on individual cells, and no longer considering local neighborhoods of cells.

## Cell Centered Neighborhoods

For Cell Centered Neighborhoods a Table is created where the position of each neighborhood is centered on a user selected cell type. This is useful for looking at the local microenvironment of a specific cell type. The interface, in this case, is similar to one for Raster Scanned Neighborhoods, but the option of selecting only cells from certain samples is added.