Package 'vmeasur'

Title: Quantify the contractile nature of vessels monitored under an operating microscope
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.
Authors: James JW Hucklesby [aut, cre] , Peter S Russell [aut] , Anthony RJ Phillips [aut] , Catherine E Angel [aut]
Maintainer: James Hucklesby <[email protected]>
License: CC BY-NC-SA 4.0
Version: 0.1.4
Built: 2024-10-29 05:02:25 UTC
Source: https://github.com/jameshucklesby/vmeasur

Help Index


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 paramaters 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