Package 'tivis.r'

Title: Read Diaspective Vision TIVITA Hyperspectral Recordings
Description: Reads hyperspectral imaging data written by the Diaspective Vision TIVITA Suite, used for intraoperative tissue and perfusion imaging. Parses the binary 'SpecCube.dat' container (big-endian float32 samples in band-interleaved-by-pixel order behind a 12-byte dimension header), the German-language acquisition metadata log, and the parameter images the Suite exports alongside each recording (oxygenation, NIR perfusion, tissue haemoglobin and water indices). Requires no vendor SDK and contains no compiled code. Companion to 'cuvis.r', which covers Cubert snapshot cameras, and a data source for 'hyperspectR'.
Authors: R. Heller [aut, cre] (ORCID: <https://orcid.org/0000-0001-8006-9742>)
Maintainer: R. Heller <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-09-21 09:52:08 UTC
Source: https://github.com/CTTIR/tivis.r

Help Index


Is the TIVITA Reader Available?

Description

Present for symmetry with cuvis.r::cuvis_available(). TIVITA support is pure R with no vendor SDK, so this is always TRUE.

Usage

tivis_available()

Value

TRUE, invisibly usable in conditionals.

Examples

tivis_available()

Path to the Bundled Example Cube

Description

A small synthetic cube in genuine TIVITA layout, generated by data-raw/make-fixture.R. It ships with the package so examples, tests and vignettes run without access to clinical recordings.

Usage

tivis_example_file()

Value

Path to the bundled ⁠*_SpecCube.dat⁠ file.

Examples

tivis_example_file()

Read TIVITA Acquisition Metadata

Description

Parses a ⁠*_meta.log⁠ file written beside a TIVITA recording. The Suite writes an INI-style file with German section and key names, latin1 encoding and comma decimal separators; all three are handled here.

Usage

tivis_get_metadata(path)

Arguments

path

Path to a ⁠*_meta.log⁠ file.

Details

Numeric-looking values are converted to numbers ("7,000000" becomes 7), TRUE/FALSE become logicals, and surrounding quotes are stripped. Unrecognised values are returned as trimmed strings.

Value

A named list of sections, each a named list of entries. Returns an empty list if the file does not exist.

Examples

log_file <- system.file("extdata", "example_meta.log", package = "tivis.r")
if (nzchar(log_file)) str(tivis_get_metadata(log_file))

TIVITA Wavelength Axis

Description

The TIVITA Tissue camera samples 500-995 nm in 5 nm steps. The mapping was confirmed empirically: correlating each band against the TIVITA Suite's own greyscale RGB export peaks at band 12, i.e. 555 nm, which is where human photopic luminous efficiency peaks.

Usage

tivis_get_wavelengths(n_bands = 100L)

Arguments

n_bands

Integer number of bands. Default 100L, the native count.

Value

Numeric vector of band centre wavelengths in nanometres.

Examples

range(tivis_get_wavelengths())

Discover TIVITA Recordings Below a Directory

Description

Walks a directory tree and returns one row per recording found. Only headers are read, so scanning a large archive is cheap.

Usage

tivis_list_measurements(root, recursive = TRUE)

Arguments

root

Directory to search.

recursive

Logical. Descend into subdirectories. Default TRUE.

Value

A data frame with one row per recording: path, dir, timestamp, width, height, bands, file_size, and n_reference_images. Zero rows if nothing matches.

Examples

# tivis_list_measurements("/archive/tivita")

Read a Complete TIVITA Recording

Description

Convenience wrapper returning the cube together with everything the Suite stored alongside it: acquisition metadata and the paths of the exported parameter images.

Usage

tivis_measurement(path, bands = NULL)

Arguments

path

Path to a ⁠*_SpecCube.dat⁠ file.

bands

Optional integer vector of band indices. NULL reads all.

Value

A list with cube, wavelengths, metadata, references, timestamp and path.

Examples

m <- tivis_measurement(tivis_example_file())
dim(m$cube)

Parse a TIVITA Filename Timestamp

Description

TIVITA names every artefact of a recording ⁠YYYY_MM_DD_HH_MM_SS_<what>⁠. This extracts the acquisition time from such a name.

Usage

tivis_parse_timestamp(x)

Arguments

x

Character vector of file or directory names.

Value

A POSIXct vector, NA where no timestamp is present.

Examples

tivis_parse_timestamp("2019_11_25_13_29_24_SpecCube.dat")

Read a TIVITA Suite Hyperspectral Cube

Description

Reads a ⁠*_SpecCube.dat⁠ file written by the Diaspective Vision TIVITA Suite. Unlike Cubert .cu3s session files, the TIVITA container is a plain binary format, so this package needs no vendor SDK and no compiled code.

Usage

tivis_read_cube(path, bands = NULL, validate = TRUE)

Arguments

path

Path to a ⁠*_SpecCube.dat⁠ file.

bands

Optional integer vector of band indices to read. NULL (default) reads every band. Selecting a subset still reads the whole file, but returns only the requested bands.

validate

Logical. Check that the file size matches the header before reading. Default TRUE; there is no good reason to disable it.

Value

A numeric array with dimensions ⁠(rows, cols, bands)⁠ — matching the convention used by hyperspectR::hsi_cube() — carrying a wavelengths attribute in nanometres.

File format

The format was determined empirically from reference captures and validated against the TIVITA Suite's own ⁠_RGB-Image.png⁠ exports:

  • a 12-byte header of three big-endian uint32 values giving width, height and bands;

  • followed by big-endian float32 samples;

  • stored band-interleaved-by-pixel (BIP): all bands of one pixel are contiguous, pixels run in row-major order (x varies fastest).

Values are calibrated reflectance. They are normally within ⁠[0, 1]⁠ but may fall slightly below zero or exceed one in specular and saturated regions, so the reader does not clamp them.

See Also

tivis_read_header() for header-only access, tivis_get_wavelengths() for the wavelength axis.

Examples

f <- tivis_example_file()
cube <- tivis_read_cube(f)
dim(cube)
range(attr(cube, "wavelengths"))

Read a TIVITA Cube Header

Description

Parses the 12-byte header of a ⁠*_SpecCube.dat⁠ file without reading the sample data, which makes it cheap enough to scan large archives.

Usage

tivis_read_header(path, validate = TRUE)

Arguments

path

Path to a ⁠*_SpecCube.dat⁠ file.

validate

Logical. Verify that the file size equals 12 + width * height * bands * 4. Default TRUE.

Value

A named list with width, height, bands, n_values and file_size.

Examples

tivis_read_header(tivis_example_file())

Locate the Parameter Images Beside a Recording

Description

The TIVITA Suite exports its computed parameter maps as PNGs next to each cube: an RGB rendering plus tissue indices. These are the Suite's own results and are useful as a reference when validating independently computed indices.

Usage

tivis_reference_images(path)

Arguments

path

Path to a ⁠*_SpecCube.dat⁠ file, or to the directory holding it.

Value

A named character vector of existing file paths. Names are the parameter identifiers used by the Suite, for example RGB-Image, Oxygenation, NIR-Perfusion, THI, TWI, OHI. Zero-length if none are present.

Examples

# tivis_reference_images("/path/to/2019_11_25_13_29_24_SpecCube.dat")