Type: | Package |
Title: | Quantify the Contractile Nature of Vessels Monitored under an Operating Microscope |
Version: | 0.1.4 |
Maintainer: | James JW Hucklesby <jhuc964@aucklanduni.ac.nz> |
Description: | A variety of tools to allow the quantification of videos of the lymphatic vasculature taken under an operating microscope. Lymphatic vessels that have been injected with a variety of blue dyes can be tracked throughout the video to determine their width over time. Code is optimised for efficient processing of multiple large video files. Functions to calculate physiologically relevant parameters and generate graphs from these values are also included. |
License: | CC BY-NC-SA 4.0 |
Imports: | ggplot2, readr, stringr, tidyr, purrr, ggpubr, imager, av, tools, dplyr, rlang, foreach, magrittr, graphics, stats, utils, pracma, crayon, svDialogs, pdftools, doFuture, progressr, future, scales, tcltk |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.1.1 |
Depends: | R (≥ 2.10) |
NeedsCompilation: | no |
Packaged: | 2021-11-11 02:37:47 UTC; jhuc964 |
Author: | James JW Hucklesby
|
Repository: | CRAN |
Date/Publication: | 2021-11-11 19:00:02 UTC |
Calibrate the pixel size using a test image
Description
In order to calculate absolute densities from pixel sizes, the size of the field captured by an operating microscope must be determined. This function allows the user to select an image of a ruler captured under a microscope, before automatically determining the scale.
Usage
calibrate_pixel_size(file_path = tk_file.choose())
Arguments
file_path |
The path to the image of a ruler to use for calibration. If left blank, the user will be prompted to select the file. |
Value
A graphical representation of the ruler and calibration process. The number of pixels per mm will also be displayed.
Examples
## Not run:
file = paste(system.file(package = "vmeasur"), "extdata/mm_scale.jpg", sep = "/")
calibrate_pixel_size(file)
## End(Not run)
Example lymphatic width dataset
Description
A data set containing the widths of a test vessel in each frame of a video. Identical in format to that produced by select_roi and threshold_vessel
Usage
example_vessel
Format
A data frame with 245,230 rows and 5 variables:
- X.1
identification number of each row
- y
y position in the image
- p_width
width of the vessel at that position, in pixels
- excluded
was that row excluded due to an air bubble
- filename
which frame was the pixel row acquired from
...
Source
Collected for this package by Peter Russell (2021)
Set the output directory
Description
Set the output directory
Usage
output_dir(set = NULL, use_default = FALSE, set_default = FALSE)
Arguments
set |
The directory to set to |
use_default |
Should the default value be used, or the system value |
set_default |
Should the system value be updated |
Value
The file path to export to
Quantify the content of an entire directory of sub-directories at once
Description
Quantify the content of an entire directory of sub-directories at once
Usage
quantify_directory(target_folder)
Arguments
target_folder |
The folder to quantify the readings in |
Value
A PDF file for each directory quantified, showing the quantification
Quantify the vessel width over an entire ROI
Description
This function calculates the overall widths and contraction parameters for the vessel as a whole.
Usage
quantify_mean_width(widths_file, pixel_scale = 73)
Arguments
widths_file |
A CSV file created by select_roi or threshold_vessel |
pixel_scale |
The number of pixels per mm, can be calculated with calibrate_pixel_size if unknown |
Value
A list containing: A graph showing the detected contraction events, Details of each contraction event, The mean and standard deviation of the calculated contraction physiological parameters, The raw data used in the quantification process
Examples
quantify_mean_width(vmeasur::example_vessel)
Quantify the contractility of a vessel in sections along it's length
Description
Quantify the physiological parameters in each section of the vessel along it's length.
Usage
quantify_mean_width_sections(widths_file = tk_file.choose())
Arguments
widths_file |
A csv file created by select_roi or threshold_vessel. If not specified, the user will be prompted to make a selection. |
Value
Graphs showing the contractility over time, contraction position and amplitude detected, length of contraction and a heatmap overlay for verification of the overall data.
Examples
# quantify_mean_width_sections(widths_file = vmeasur::example_vessel)
Quantify the width of a vessel continuously along it's length
Description
Generate heat maps and line plots showing the changes in vessel diameter along it's length
Usage
quantify_width_position(widths_file = tk_file.choose())
Arguments
widths_file |
A csv file created by select_roi or threshold_vessel. The user will be prompted to select a file if this is not specified. |
Value
Two plots: A heat map of the vessel diameter at each position over time and a plot showing the maximum change in diameter over time
Examples
quantify_width_position(vmeasur::example_vessel)
Set the scratch directory for vmeasur
Description
vmeasur uses av to unpack temporary image files, which are then stored for further usage. This runs better if done to a high speed storage location such as a ram drive. This function sets that directory, and provides other options for specifying the structure of this temporary data.
Usage
scratch_dir(
set = NULL,
random_subfolder = FALSE,
file_name = FALSE,
wipe_scratch = FALSE
)
Arguments
set |
new directory to set. If left blank, no directory change will occur |
random_subfolder |
Should a random sub folder be created |
file_name |
Specify the name of the directory |
wipe_scratch |
Should the folder be cleared before use |
Details
If not specified, the default R tempdir is used
Value
the current location of the scratch directory
Examples
scratch_dir()
scratch_dir("R:")
Select a ROI from a video file
Description
This function provides a graphical tool to walk the user through selecting a ROI from an AVI video.
Usage
select_roi()
Value
Saves an annotated AVI and CSV file in the same directory as the video. Will also output and copy the parameters used to create the video.
Examples
## Not run:
select_roi()
## End(Not run)
Threshold a video with pre-determined parameters
Description
Using pre-determined values this function generates ROI from a video. If parameters are not known, use select_roi() This function is optimized to run in parallel, so should be relatively rapid. If running slowly, check the scratch disk is set correctly.
Usage
threshold_apply(
threshold = 0.5,
roi_name = "test",
video_path = "image826.avi",
radians = 0.217604550320612,
xlength = 60,
ylength = 242,
xstart = 696,
ystart = 323,
image_list = NULL,
fps = NULL
)
Arguments
threshold |
The threshold for the red channel. Range 0-1. |
roi_name |
Name assigned to the region of interest |
video_path |
Location of the video file to process |
radians |
Degrees to rotate the image, in radians |
xlength |
Number of x pixels in the ROI |
ylength |
Number of y pixels in the ROI |
xstart |
ROI starting x co-ordinate |
ystart |
ROI starting y co-ordinate |
image_list |
If pre-computed, a list of images to use rather than a video |
fps |
Number of fps to process, this can be set lower for validation |
Value
Saves the quantified CSV and overlaid video in the same directory as the video
Apply a threshold to a single frame
Description
Apply a threshold to a single frame
Usage
threshold_vessel(file_path = tk_file.choose(), threshold, min_area = 100)
Arguments
file_path |
path to the file to be used. If left blank, the user will be prompted to make a selection |
threshold |
The threshold to use |
min_area |
Minimum area to recognize as a vessel. Any smaller items will be ignored |
Value
a data frame containing the widths of the vessel in each row of the image, and if any rows were excluded due to overexposure