# basic
tabular <- BIDSTabularSessions(data.frame(
session_id = c("ses-predrug", "ses-postdrug", "ses-followup"),
acq_time = c(
"2009-06-15T13:45:30",
"2009-06-16T13:45:30",
"2009-06-17T13:45:30"
),
systolic_blood_pressure = c(120, 100, 110)
))
tabular
# convert existing tabular
tabular <- BIDSTabular(
data.frame(
acq_time = "2009-06-15T13:45:30",
session_id = "ses-predrug",
systolic_blood_pressure = 120
)
)
tabular <- as_bids_tabular(tabular, cls = BIDSTabularSessions)
tabular
# save to tsv
tsv <- file.path(tempdir(), "sessions.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")
# clean up
unlink(tsv)
unlink(paths$sidecar_path)
Run the code above in your browser using DataLab