Title: | Shape Analysis for AI-Reconstructed Images |
---|---|
Description: | Provides functionality for image processing and shape analysis in the context of reconstructed medical images generated by deep learning-based methods or standard image processing algorithms and produced from different medical imaging types, such as X-ray, Computational Tomography (CT), Magnetic Resonance Imaging (MRI), and pathology imaging. Specifically, offers tools to segment regions of interest and to extract quantitative shape descriptors for applications in signal processing, statistical analysis and modeling, and machine learning. |
Authors: | Esteban Fernandez [aut, cre], Qiwei Li [aut] |
Maintainer: | Esteban Fernandez <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.1 |
Built: | 2025-02-14 03:56:16 UTC |
Source: | https://github.com/estfernan/safari |
The R package SAFARI provides functions for image processing and shape analysis of regions of interest (ROI) in AI-reconstructed images.
The main functions are summarized as follows:
read.image
: loads and preprocesses reconstructed binary images for segmentation;
binary.segmentation
: ROI segmentation and optional feature extraction;
compute.features
: feature extraction for an individual ROI;
rc.plot
: visualize reconstructed binary or segmented images.
See the package vignettes for more introduction and demonstration.
Identify and segment the regions of interest (ROI) in a reconstructed binary image, while having the option to extract quantitative shape-based features.
binary.segmentation( x, id, filter = NA, k = 3, categories = c("none", "geometric", "boundary", "topological") )
binary.segmentation( x, id, filter = NA, k = 3, categories = c("none", "geometric", "boundary", "topological") )
x |
a binary matrix that represents the reconstructed image. |
id |
a named character vector that contains the ID's pertaining to the sample. |
filter |
an integer vector that indicates the filtering procedure. |
k |
an integer that specifies the factor to enlarge the regions. |
categories |
a character string or vector, see |
The argument id
specifies the ID's corresponding to the sample.
A usual example that is used if the argument is an unnamed vector is composed
of the following entries:
cohort
: name of cohort the sample belongs to;
patient.id
: unique identifier for patient the sample belongs to;
slide.id
: unique identifier for sample.
The argument filter
specifies how the ROI should be filtered. There
are two ways to filter them, either by only specifying a minimum net area or
by additionally specifying the largest regions to keep in a two element
vector. The default value is
NA
which sets the minimum net area as
one-fourth the largest region.
The argument categories
specifies the shape features to compute. The
default is "none" which computes no features.
A list
object whose components are the following:
desc
: a data.frame
of the shape features
corresponding to each segmented ROI;
holes
: an integer matrix that contains the holes within
each ROI, labeled according to
the regions
;
id
: a character vector that is identical to the
id
argument passed;
k
: argument k
passed to function;
n
: an integer that indicates the number of
segmented regions;
plg.chains
: a list
where each component is the
polygonal chain of a segmented ROI;
regions
: an integer matrix that contains the segmented
ROI, labeled from largest to smallest.
To produce a reconstructed binary image, a greyscale scan or an image easily converted to binary, resulting from different modalities, is converted to a matrix representation, usually by standard image processing algorithms.
The resulting matrix is composed of two integer values that help represent the
regions of interest in the scan. Usually, as in the case of pathology
imaging, these are empty regions and tumor tissues, where we refer to the
integer values as categories. We note that the regions of interest must be
represented by 1
's and what we consider the empty regions by 0
's.
# load libraries library(SAFARI) # load sample data("rBPS") # segmentation procedure rBPS <- binary.segmentation( rBPS, id = c("NLST", "AA00474", "11030"), filter = 150, categories = c("geometric", "boundary", "topological") )
# load libraries library(SAFARI) # load sample data("rBPS") # segmentation procedure rBPS <- binary.segmentation( rBPS, id = c("NLST", "AA00474", "11030"), filter = 150, categories = c("geometric", "boundary", "topological") )
Compute the shape descriptors of the given region, represented by its binary matrix and the polygonal chain of its boundary.
compute.features( region, plg.chain, categories = c("geometric", "boundary", "topological") )
compute.features( region, plg.chain, categories = c("geometric", "boundary", "topological") )
region |
a binary matrix that represents the region. |
plg.chain |
an |
categories |
a character string or vector, specifying which features to compute. |
The shape descriptors are divided into three categories: geometric, boundary, and topological. The default will compute the features from all categories. We also note that, for the binary matrix, the ones and zeros make up the region of interest and background, respectively.
A numeric vector composed of the shape descriptors.
See Polygonal Chain for more information on the closed polygonal chain.
This reconstructed binary image was first represented as a three-class image, prepared using a tumor recognition system (ConvPath) developed by the Quantitative Biomedical Research Center. The original whole-slide image comes from a lung cancer patient in the Lung Screening Study (LSS) subcomponent of NLST. Specifically, this is an image from an H&E-stained slide that was obtained as part of a pathology specimen collection.
data(rBPS)
data(rBPS)
rBPS
is a 314-by-224 binary matrix where each entry
corresponds to a tissue or region in the H&E image. In our case the ones and
zeros indicate an empty region or tumor tissue, respectively.
Original H&E slide available at https://biometry.nci.nih.gov/cdas/nlst/.
ConvPath: A software tool for lung adenocarcinoma digital pathological image analysis aided by a convolutional neural network. (2019) EBioMedicine.
Plot a reconstructed image obtained from various types of modalities.
rc.plot(x, type = c("binary", "segments"), publication = FALSE, ...)
rc.plot(x, type = c("binary", "segments"), publication = FALSE, ...)
x |
an integer matrix that represents the reconstructed image. |
type |
a character string that specifies the image type. |
publication |
a logical value, whether to create a figure without key nor scales. |
... |
additional graphical parameters passed to |
The argument type
specifies the image type with the following options:
binary: reconstructed binary image, representing a greyscale medical image;
segments: segmented matrix, where each region is denoted by an integer value.
No return value, called for side effects i.e. plotting.
binary.segmentation
for more information on reconstructed images.
This function reads a reconstructed binary image, possibly, produced from an
X-Ray, CT scan, MRI, etc. and processed by standard image processing
algorithms. The image is then pre-processed to facilitate the procedure in
the binary.segmentation
function.
read.image(file, invert = FALSE, expand.border = 5)
read.image(file, invert = FALSE, expand.border = 5)
file |
a character string that specifies the image to read. |
invert |
a logical value that indicates if the B/W colors should be inverted. |
expand.border |
an integer value that specifies how much to expand the image's border by. |
The binary image is pre-processed as follows:
Check if image contains multiple color channels, non-binary, or empty.
Invert black and white colors (optional).
Ensure image is truly binary by converting all values greater than zero to 1
.
Expand the border around the image with 0
s.
Rotating the image, if it is not stored as an RData
file.
An integer matrix that represents the pre-processed image.
binary.segmentation
for more information on reconstructed binary images.