spectrogram: Computes spectrogram

View source: R/spectrogram.R

spectrogramR Documentation

Computes spectrogram

Description

This function builds spectrogram, using CWT, for each individual of a behavr table

Usage

spectrogram(var, data, period_range = c(hours(16), hours(32)),
  resample_rate = 1/mins(15), FUN = cwt_spectrogram, ...)

Arguments

var

variable to analyse

data

behavr table

period_range

vector of size 2 defining minimal and maximal range of period to study (in seconds)

resample_rate

frequency to resample (up or down) the data at (in hertz)

FUN

function used to compute spectrograms (so far, only CWT is implemented via cwt_spectrogram)

...

additional arguments to be passed to FUN

Details

A spectrogram is a estimation of the local periodicity of a signal at a given time. In the context of circadian rhythm, it can be useful to understand how infradian rhythms change along the day or, for instance, how circadian rhythm change ver the course of an multi-day experiment.

Value

A behavr::behavr table. In addition to the metadata, it contains data that encodes a spectrogram (i.e. power vs period). The data contains the columns:

  • t – the time (in s) (same range the input time)

  • period – the period at which the power is computed, for a given t (in s)

  • power – the power the or equivalent (according to FUN)

  • ridge – a logical defining whether the point (t and period) is a ridge

References

See Also

  • periodogram – to compute periodogram instead

  • cwt_spectrogram – The dunction use to compute individual spectrograms

  • ggetho::ggspectro – to plot spectrograms

Examples

data(dams_sample)
dt <- dams_sample[id %in% dams_sample[meta=TRUE, ,id[1:5]]]
spect_dt <- spectrogram(activity, dt)


require(ggetho)
ggspectro(spect_dt) +
        stat_tile_etho() +
        scale_y_log10() +
        facet_wrap(~ id)


rethomics/zeitgebr documentation built on April 11, 2024, 2:28 a.m.