nbasis | R Documentation |
Get the number of basis functions used in a hemodynamic response function (HRF) or model term. For canonical HRFs (like SPM's canonical HRF), this returns 1. For flexible basis sets (like Fourier or B-spline bases), this returns the number of basis functions used to model the response shape.
nbasis(x)
## S3 method for class 'convolved_term'
nbasis(x)
## S3 method for class 'hrfspec'
nbasis(x)
x |
The object to query (typically an HRF, hrfspec, or convolved_term) |
An integer indicating the number of basis functions:
1 for canonical HRFs (e.g., SPM gamma)
>1 for flexible basis sets (e.g., Fourier, B-spline)
For convolved terms: number of basis functions per condition
HRF_SPMG1()
, event_model()
Other hrf:
fitted_hrf()
# Check basis functions for different HRF types
# Canonical HRF (single basis)
canonical_hrf <- HRF_SPMG1
nbasis(canonical_hrf) # Returns: 1
# Fourier basis set
fourier_hrf <- getHRF("fourier", nbasis = 3)
nbasis(fourier_hrf) # Returns: 3
# Create event model with multiple basis functions
event_data <- data.frame(
condition = factor(c("A", "B", "A", "B")),
onsets = c(1, 10, 20, 30),
run = c(1, 1, 1, 1)
)
sframe <- sampling_frame(blocklens = 50, TR = 2)
# Model with Fourier basis
evmodel <- event_model(
onsets ~ hrf(condition, basis = "fourier", nbasis = 3),
data = event_data,
block = ~run,
sampling_frame = sframe
)
# Get number of basis functions for model term
nbasis(evmodel) # Returns: 3 (basis functions per condition)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.