augment_ttl_details: Recode TTL code vector to reflect changes in the value,...

View source: R/physio_functions.R

augment_ttl_detailsR Documentation

Recode TTL code vector to reflect changes in the value, compute onsets and offsets, add to object

Description

This functions helps to identify the key time markers when TTL codes onset, which is hard to detect using the raw vector alone (since the code will have some duration)

Usage

augment_ttl_details(
  ep.physio,
  lazy_ttl = 2,
  zero_code = 0,
  code_labels_df = NULL
)

Arguments

lazy_ttl

a non-negative integer indicating the lowest number of samples that could reflect a genuine change in a TTL code. Default: 2

zero_code

what code reflects that all pins are off (no active code). If you have a stuck parallel port pin, set zero_code to that value to prevent flagging onsets of that value as events.

ttl_vec

a vector of integer TTL codes reconstructed from the acq file

Details

The parallel port cannot truly change all 8 pins simultaneously for a new code. If the speed of the pins changing falls on a sampling boundary on the BIOPAC hardware, this can lead to false codes for very brief periods of time (~2ms). Thus, identify rapid code changes, then interrogate around these, replacing the dubious code with the code that 'sticks' subsequently. This decision means that if any pin has changed, then the experiment has executed a new TTL code.

For example, at 1000Hz, @lazy_ttl = 2 would flag any codes with duration of 2ms or less as suspicious and would replace these with the longer, genuine code that immediately follows.

Author(s)

Michael Hallquist


PennStateDEPENdLab/experiment.pipeline documentation built on April 14, 2024, 9:37 p.m.