# run `ieegio_sample_data("streamlines/CNVII_R.tck")` to
# download sample data
if( ieegio_sample_data("streamlines/CNVII_R.tck", test = TRUE) ) {
path <- ieegio_sample_data("streamlines/CNVII_R.tck")
# Read
streamlines <- io_read_tck(path)
plot(streamlines)
# write
tfile <- tempfile(fileext = ".tck")
io_write_tck(streamlines, tfile, datatype = streamlines$header$datatype)
# verify two files are identical
digest::digest(file = tfile) == digest::digest(file = path)
unlink(tfile)
}
# This example uses sample data, run
# `ieegio_sample_data("streamlines/CNVII_R.trk")` to download
if( ieegio_sample_data("streamlines/CNVII_R.trk", test = TRUE) ) {
path <- ieegio_sample_data("streamlines/CNVII_R.trk")
tfile <- tempfile(fileext = ".trk")
# read
x <- io_read_trk(path)
# write
io_write_trk(x, tfile)
# compare two files
file.size(path) == file.size(tfile)
src_raw <- readBin(path, "raw", n = file.size(path))
dst_raw <- readBin(tfile, "raw", n = file.size(tfile))
equal_raw <- src_raw == dst_raw
# Some reserved information are removed
all(equal_raw[-c(945:947)])
unlink(tfile)
}
Run the code above in your browser using DataLab