htbCountSpike: Calculator of spikes in htbRas object

View source: R/htbCountSpike.R

htbCountSpikeR Documentation

Calculator of spikes in htbRas object

Description

Counts number of spikes or firing rate an htbRas object.

Usage

htbCountSpike(ras, from = NULL, to = NULL, type = "m")

Arguments

ras

An htbRas object of spike type. Since "counting the number of firing" makes no sense, htbCountSpike() does not naturally accept htbRas object of analog type.

from

A numeric or string. The start of the targeted period you want to examine in millisecond (relative to the aligning event you used in creating htbRas object). Alternatively, you can designate an event from where you want to start counting spikes. In the latter case, the designated event should always exists in (ideally) all the trials. Otherwise you will lose some trials, since the start of the period cannot be determined in trials in which that event did not happen.

to

A numeric or string. Same to from argument but for the end of the targeted period. An event name can also be accepted.

type

A string either m or n. If set m (default), htbCountSpike() returns firing rates by dividing the numbers of spikes by the lengths of designated period. If set n, htbCountSpike() returns raw spike counts instead.

Details

After you aligned and visualized neural activity by creating an htbRas object, you will then want to perform statistical tests for the difference in firing between task conditions. To count number of spikes in the htbRas object, you can use htbCountSpike() function. Because htbRas objects are already aligned by certain task event (usually the most important task event you are targeting), you need to just designate the range of the period by from and to arguments. The spike counts within the range are calculated for each of the conditions in the htbRas object. The result is returned as a list, whose length and numbers of elements contained equal to the original number of conditions and numbers of trials in the htbRas object, respectively. htbCountSpike() can also return the firing rates instead of the raw spike counts, that may be more useful when you need to further compare the neural activation between periods with different ranges (and therefore this is set as the default behavior of the function).

Value

A list. Each element contains the spike counts or firing rates of the corresponding condition in the provided htbRas object.

Examples

alignment <- list(CUEON_L = c(-1500, 2000), CUEON_R = c(-1500, 2000))
incld <- list(TRIALSTART = c(-2000, 0), TRIALEND = c(0, 2000))
excld <- list(ERROR = c(0, 2000))

## Not run: 
db_sp <- htbGetDb("spike.htb")
db_ev <- htbGetDb("event.htb")
ras <- htbGetRas(db_sp, db_ev, alignment,
  incld = incld, excld = excld)
s <- htbCountSpike(ras, 0, 500)

## End(Not run)


keimochizuki/htb documentation built on June 9, 2025, 10:03 p.m.