get_bids_participants {bidsr}R Documentation

'BIDS' participant table class

Description

A tabular containing a list of participants and their demographics. The class is a child class of BIDSTabular, hence see the methods there. The original specification is at https://bids-specification.readthedocs.io/en/stable/modality-agnostic-files.html#participants-file.

Usage

get_bids_participants(x, ...)

BIDSTabularParticipants(content, meta = NULL)

Arguments

x

R object such as file path, project instances, etc.

...

passed to other methods or ignored

content, meta

see BIDSTabular

Value

A BIDSTabularParticipants instance inheriting BIDSTabular.

Author(s)

Zhengjia Wang

Examples




# basic
tabular <- BIDSTabularParticipants(
  data.frame(
    participant_id = "sub-001"
  )
)
tabular


# Run `download_bids_examples()` first
examples <- download_bids_examples(test = TRUE)
if(!isFALSE(examples)) {

  file <- file.path(examples, "ieeg_epilepsy_ecog", "participants.tsv")

  # read tabular as BIDSTabularParticipants
  as_bids_tabular(file, cls = BIDSTabularParticipants)

  # convert existing tabular
  tabular <- BIDSTabular(
    data.frame(
      participant_id = "sub-001"
    )
  )
  tabular <- as_bids_tabular(tabular, cls = BIDSTabularParticipants)

  # save to tsv
  tsv <- file.path(tempdir(), "participants.tsv")
  paths <- save_bids_tabular(tabular, tsv)
  print(paths)

  # use base R to read
  read.table(tsv, header = TRUE, na.strings = "n/a")

  # get sidecar
  cat(readLines(paths$sidecar_path), sep = "\n")

  unlink(tsv)
  unlink(paths$sidecar_path)
}


[Package bidsr version 0.1.0 Index]