Undocumented
| Function | autogain |
Automatically set pixels around the background mean to maximum white. |
| Function | colourmap |
Linear map an array of 1d floats between two tristimulus values. |
| Function | colourmap |
Linear map an array of 1d floats between to the veridis colour map |
| Function | create |
Create a colourised, spatially filtered density image, with overlayed map |
| Function | generate |
Produces density maps for a given decomposed image, and areas above a signal and classification threshold |
| Function | hitbox |
Draw a hit-box around the edge of an image or image segment |
| Function | hitbox |
For a given image and set of coordinates, draw the hitox for those coordinates |
| Function | normalise |
Normalise an array, centreing it on 0.5 |
| Function | process |
Process an SVS file, loading, decomposing and producing density maps |
| Function | process |
Main routine for running this module as a command line function. This routine produces density maps, segmentation images and structured json output for a folder or single SVS file. |
| Function | return |
Spectral Estimation Image of Stains from Aperio Microscope |
| Function | spatial |
Apply a spatial convolutional kernel to im |
| Function | write |
Dump ROIs to disk |
Automatically set pixels around the background mean to maximum white.
| Parameters | |
| image | NxMx3 loaded image (3d np.array) |
| xin | the x coordinates to estimate the background |
| yin | the y coordinates to estimate the background |
| threshold | the lower bound around the mean for which pixels will be treated as background (default .95/95%) |
| channel | the channel to test, by default 0 (RED) as this is not a signal channel |
| value | the value to set the R, G and B components to, by default max white (255, 255, 255) |
| Returns | |
| NxM image with gain adjustment. | |
Linear map an array of 1d floats between two tristimulus values.
| Parameters | |
| colour1 | 1x3 RGB Value (np.array) |
| colour2 | 1x3 RGB Value (np.array) |
| one | array of floats between 0 and 1 (np.array) |
| Returns | |
| transformed values (NX3 => colour1 < Im < colour2) | |
Linear map an array of 1d floats between to the veridis colour map
| Parameters | |
| one | array of floats between 0 and 1 (np.array) |
| Returns | |
| transformed values (NX3 => veridis(0) < Im < veridis(1)) | |
Create a colourised, spatially filtered density image, with overlayed map
| Parameters | |
| raw | raw decomposed image |
| raw | density map threshold |
| densities | densities array produced by generate_densities_and_map_coordinates |
| stride | stride over which to tumble |
| class | classification threshold for ROIs |
| identify | Overlay ROI's of significant density |
| Returns | |
| reduced_brightness_density_map, density_mapp_array | |
Produces density maps for a given decomposed image, and areas above a signal and classification threshold
Definitions
Definitions of terms used in procedure below:
I : [DAB Image], i : [rows of image], j: [columns of image]
D : [Density Map], s: [Stride], si: [i / stride], sj: [j / stride]
B : [Binary map], T : [Signal Threshold], C: [Classification Threshold]
mu : [Array mean], R : [ROI Array], O: [Coordinates array], Om: [Map Coordinates Array]
Procedure
Pseudocode for procedure generating density maps:
B(i,j) = I(i,j) < T
D(si, sj) = mu(I(i:i+s, j:j+s))
R(si, sj) = D > C
Om = (si, sj) for si and sj if R(si, sj)
O = (i, j) for i and j if R(i / stride, j / stride)
| Parameters | |
| raw | NxMxF spectral image, where F is the number of channels (Fd np.array) |
| stride | The window size over which we will tumble |
| raw | The value per pixel to be considered a 'vote' for that pixel containing significant signal |
| class | The mean density required for that region to be considered an ROI |
| Returns | |
| NxM densities array, coordinates in the image of ROIs, coordinates in the map of ROIs (np.arrays) | |
Draw a hit-box around the edge of an image or image segment
| Parameters | |
| im | array or array slice (3d np.array) |
| Returns | |
| None, inplace | |
For a given image and set of coordinates, draw the hitox for those coordinates
| Parameters | |
| image | array or array slice (3d np.array) |
| coordinates | coordinates array referencing y, x location in image |
| stride | size of hitbox in px |
| Returns | |
| image (although it is applied in place) | |
Normalise an array, centreing it on 0.5
| Parameters | |
| a | Array in (np.array NxM) |
| Returns | |
| transformed values (NxM => 0 < F < 1) | |
Process an SVS file, loading, decomposing and producing density maps
| Parameters | |
| file | fullpath to SVS file |
| stride | The window size over which we will tumble |
| raw | The value per pixel to be considered a 'vote' for that pixel containing significant signal |
| class | The mean density required for that region to be considered an ROI |
| apply | attempt to remove the slide background |
| microns | Slide resolution in um per pixel, default 2.0um |
| verbose | provide printed output |
| Returns | |
| image, raw_image (decomposed), densities, coordinates, map_coordinates | |
Main routine for running this module as a command line function. This routine produces density maps, segmentation images and structured json output for a folder or single SVS file.
| Parameters | |
| input | Full path to SVS file, or folder filled with SVS files |
| output | Full path of the folder to output results {json, jpegs} |
| stride | Stride over which to tumble |
| raw | Density difference under which we will consider the signal a valid signal |
| class | Mean density identification threshold required to specify an ROI |
| output | Should density images be saved to disk {jpegs} |
| output | Should json metadata/density maps be saved to disk {json} |
| skip | Skip saving the ROI hit-boxed images to disk |
| auto | Should we apply automatic background identification and removal |
| include | Filter filenames for string, (e.g. "17_A") when not None |
| output | Output each ROI as an image {jpegs} |
| verbose | printf feedback |
| synthetic | Should we look for JPG files |
| Returns | |
| None | |
Spectral Estimation Image of Stains from Aperio Microscope
| Parameters | |
| image | NxMx3 loaded image (3d np.array) |
| Returns | |
| NxM DAB response image | |
Apply a spatial convolutional kernel to im
| Parameters | |
| im | NxM image (2d or 3d np.array) |
| Returns | |
| filter image by convolutional kernel | |
Dump ROIs to disk
| Parameters | |
| parent | root folder of images |
| filename | name of the collection of images (e.g. slide name) |
| coordinates | coordinates of the start x,y of the regions |
| image | image to traverse |
| stride | stride over which to tumble |
| Returns | |
| None | |