Introduction to neuroUp

Are you:

Then the neuroUp package can help:

This document will show how to use the package.

Data: feedback fMRI task

As an example, we read the Feedback task fMRI region of interest data using the read_csv() function from the readr package. This data comes shipped with the NeuroUp package in two forms: as an R dataset that you can directly call using feedback and as a csv file in the extdata/ folder. Here, we load the data from the csv-file to mimic the expected use-case that you have region of interest data in a similar format:

# load feedback.csv data located at local system 
feedback_csv <- (system.file("extdata/feedback.csv", package = "neuroUp"))

# use read_csv function to load csv-file as tibble
feedback_data <- readr::read_csv(feedback_csv)
#> Rows: 271 Columns: 4
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (4): participant_id, age, mfg_learning, mfg_application
#> 
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

When you have a csv-file locally you can load it directly like this:

taskname_data <- readr::read_csv("path/to/filename.csv")

Estimate raw differences and Cohen’s d

estim_diff allows you to determine the sample size required to estimate differences in raw means and Cohen’s d’s for multiple sample sizes with a certain precision. Precision is presented in the form of a 95% highest density credible interval (HDCI), that is, the narrowest possible interval that is believed to contain the true value of the parameter of interest with a probability of .95 . The narrower this interval, the higher the precision with which the parameter is estimated.

In this example, we are interested in the contrast between the learning phase and the application phase in the atlas-based middle frontal gyrus during the feedback task. We use an existing dataset with a sample size of N = 271, and for all sample sizes between a minimum (e.g., N = 20) and maximum sample size of the sample at hand the estim_diff() function will compute the HDCI. To account for the arbitrary order of the participant in a data set, this is done for a set number of permutations (50 by default), of the participants in the data set. For each sample size, the average HDCI of all permutations is also calculated.

The following arguments need to be provided:

We provide these arguments to the estim_diff() function and store it in a new object called feedback_estim. Before we do so, we set the seed value to make sure we get the same results when re-running the function.

set.seed(1234)

feedback_estim <- estim_diff(feedback_data,
                             c("mfg_learning", "mfg_application"), 20:271,
                             20, "Feedback middle frontal gyrus")

Explore estim_diff() output

The estim_diff() function provides several outputs that we can call to explore the results of the estimations. We will display the different outputs below.

fig_diff: scatterplot with HDCI’s for difference in raw means

First, we will plot fig_diff, which returns a scatterplot for the difference in raw means, where for five different sample sizes, 10 out of the total number of HDCI’s computed are displayed (in light blue). The average estimate with credible interval summarizing the total number of HDCIs for each sample size are plotted in reddish purple

feedback_estim$fig_diff

fig_nozero: barplot with proportion permutations not containing zero for difference in raw means

The second plot we will display is fig_nozero, which returns a barplot where for each of the five sample sizes the proportion of permutations not containing zero is displayed for the difference in raw means:

feedback_estim$fig_nozero

fig_cohens_d: scatterplot with HDCI’s for difference in raw means

Next, we will plot fig_cohens_d, which returns a scatterplot for Cohen’s d, where for five different sample sizes, 10 out of the total number of HDCI’s computed are displayed (in light blue). The average estimate with credible interval summarizing the total number of HDCIs for each sample size are plotted in reddish purple:

feedback_estim$fig_cohens_d