# 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)
}
Run the code above in your browser using DataLab