From f74d8dcaa8e34d4c52d63e1620edc58a9ce508ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Sch=C3=A4fer?= Date: Tue, 14 Apr 2020 16:42:09 +0200 Subject: [PATCH] Add format parameter to write.fs.surface, update vignette and docs --- CHANGES | 6 ++++- NAMESPACE | 1 - R/mgh2nii.R | 3 ++- R/read_fs_surface.R | 2 +- R/write_fs_surface.R | 23 +++++++++++++--- man/colortable.from.annot.Rd | 14 +++++----- man/fs.get.morph.file.ext.for.format.Rd | 17 +++++++----- man/fs.get.morph.file.format.from.filename.Rd | 17 +++++++----- man/fs.patch.Rd | 6 +++-- man/fs.volume.from.oro.nifti.Rd | 1 + man/mghheader.is.ras.valid.Rd | 13 ++++----- man/mghheader.ras2vox.Rd | 13 ++++----- man/mghheader.ras2vox.tkreg.Rd | 13 ++++----- man/mghheader.scanner2tkreg.Rd | 13 ++++----- man/mghheader.tkreg2scanner.Rd | 13 ++++----- man/mghheader.vox2ras.Rd | 13 ++++----- man/mghheader.vox2ras.tkreg.Rd | 13 ++++----- man/read.fs.annot.Rd | 12 ++++----- man/read.fs.colortable.Rd | 14 +++++----- man/read.fs.curv.Rd | 17 +++++++----- man/read.fs.label.Rd | 11 +++++--- man/read.fs.mgh.Rd | 26 +++++++++++------- man/read.fs.morph.Rd | 17 +++++++----- man/read.fs.patch.Rd | 7 ++--- man/read.fs.patch.asc.Rd | 6 +++-- man/read.fs.surface.Rd | 15 ++++++----- man/read.fs.surface.asc.Rd | 15 ++++++----- man/read.fs.surface.vtk.Rd | 15 ++++++----- man/read.fs.weight.Rd | 16 ++++++----- man/read_nisurface.Rd | 15 ++++++----- man/read_nisurfacefile.Rd | 18 ++++++------- man/readable.files.Rd | 8 ++++-- man/write.fs.annot.Rd | 18 ++++++++----- man/write.fs.colortable.Rd | 14 +++++----- man/write.fs.curv.Rd | 17 +++++++----- man/write.fs.label.Rd | 12 ++++++--- man/write.fs.mgh.Rd | 27 ++++++++++++------- man/write.fs.morph.Rd | 17 +++++++----- man/write.fs.patch.Rd | 7 ++--- man/write.fs.surface.Rd | 19 +++++++------ man/write.fs.surface.asc.Rd | 15 ++++++----- man/write.fs.surface.vtk.Rd | 15 ++++++----- man/write.fs.weight.Rd | 17 +++++++----- vignettes/freesurferformats_write.Rmd | 18 ++++++++----- 44 files changed, 352 insertions(+), 237 deletions(-) diff --git a/CHANGES b/CHANGES index 030f02f..3a59110 100644 --- a/CHANGES +++ b/CHANGES @@ -5,7 +5,11 @@ freesurferformats Changes Version 0.1.9 ------------- - Add support for reading brain surface meshes in VTK ASCII file format -- Add support for reading morph data from text files with one value per line +- Add support for writing brain surface meshes in VTK ASCII file format +- Add 'format' parameter to write.fs.surface, the function can now derive the format from the filename like similar functions +- Add support for reading morph data from text files with one numeric value per line (.txt format) +- Minor improvements to the vignette + Version 0.1.8 ------------- diff --git a/NAMESPACE b/NAMESPACE index d136e8d..457d3af 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,7 +15,6 @@ export(download_optional_data) export(fs.get.morph.file.ext.for.format) export(fs.get.morph.file.format.from.filename) export(fs.patch) -export(fs.volume.from.oro.nifti) export(get_optional_data_filepath) export(is.fs.annot) export(is.fs.label) diff --git a/R/mgh2nii.R b/R/mgh2nii.R index 154eda6..2920578 100644 --- a/R/mgh2nii.R +++ b/R/mgh2nii.R @@ -24,7 +24,7 @@ #' fsvolume = fs.volume.from.oro.nifti(nii_img); #' } #' -#'@export +#' @keywords internal fs.volume.from.oro.nifti <- function(nifti_img) { if (requireNamespace("oro.nifti", quietly = TRUE)) { @@ -110,6 +110,7 @@ fs.volume.from.oro.nifti <- function(nifti_img) { ico7_num_vertices = 163842L; # Vertex count of ICO 7 meshes, like fsaverage. If the dimensions match this, the file is assumed to # contain morphometry data stored with the FreeSurfer hack. + # It is very unlikely though that oro.nifti would accept such data, so this will most likely never happen. is_ico7 = (ncols * nifti_img@dim_[3] * nifti_img@dim_[4] == ico7_num_vertices); ico7_state_string = ifelse(is_ico7, "looks like", "does NOT look like"); diff --git a/R/read_fs_surface.R b/R/read_fs_surface.R index e498c3d..f4f6735 100644 --- a/R/read_fs_surface.R +++ b/R/read_fs_surface.R @@ -122,7 +122,7 @@ read.fs.surface.vtk <- function(filepath) { #' @export read.fs.surface <- function(filepath, format='auto') { - if(!(format %in% c('auto', 'bin', 'asc'))) { + if(!(format %in% c('auto', 'bin', 'asc', 'vtk'))) { stop("Format must be one of c('auto', 'bin', 'asc')."); } diff --git a/R/write_fs_surface.R b/R/write_fs_surface.R index e6e9fcb..cd3a363 100644 --- a/R/write_fs_surface.R +++ b/R/write_fs_surface.R @@ -9,6 +9,8 @@ #' #' @param faces n x 3 matrix of integers. Each row defined the 3 vertex indices that make up the face. WARNING: Vertex indices should be given in R-style, i.e., the index of the first vertex is 1. However, they will be written in FreeSurfer style, i.e., all indices will have 1 substracted, so that the index of the first vertex will be zero. #' +#' @param format character string, the format to use. One of 'bin' for FreeSurfer binary surface format, 'asc' for FreeSurfer ASCII format, 'vtk' for VTK ASCII legacy format, or 'auto' to derive the format from the file extension given in parameter 'filepath'. With 'auto', a path ending in '.asc' is interpreted as 'asc', a path ending in '.vtk' as vtk, and everything else as 'bin'. +#' #' @return string the format that was written. One of "tris" or "quads". Currently only triangular meshes are supported, so always 'tris'. #' #' @family mesh functions @@ -25,10 +27,23 @@ #' } #' #' @export -write.fs.surface <- function(filepath, vertex_coords, faces) { - TRIS_MAGIC_FILE_TYPE_NUMBER = 16777214; - OLD_QUAD_MAGIC_FILE_TYPE_NUMBER = 16777215; - NEW_QUAD_MAGIC_FILE_TYPE_NUMBER = 16777213; +write.fs.surface <- function(filepath, vertex_coords, faces, format='auto') { + + if(!(format %in% c('auto', 'bin', 'asc', 'vtk'))) { + stop("Format must be one of c('auto', 'bin', 'asc', 'vtk')."); + } + + if(format == 'asc' | (format == 'auto' & filepath.ends.with(filepath, c('.asc')))) { + return(write.fs.surface.asc(filepath, vertex_coords, faces)); + } + + if(format == 'vtk' | (format == 'auto' & filepath.ends.with(filepath, c('.vtk')))) { + return(write.fs.surface.vtk(filepath, vertex_coords, faces)); + } + + TRIS_MAGIC_FILE_TYPE_NUMBER = 16777214L; + OLD_QUAD_MAGIC_FILE_TYPE_NUMBER = 16777215L; + NEW_QUAD_MAGIC_FILE_TYPE_NUMBER = 16777213L; num_faces_with_index_zero = sum(faces==0); if(num_faces_with_index_zero > 0) { diff --git a/man/colortable.from.annot.Rd b/man/colortable.from.annot.Rd index df81b68..655c126 100644 --- a/man/colortable.from.annot.Rd +++ b/man/colortable.from.annot.Rd @@ -26,13 +26,15 @@ Extract a colortable lookup table (LUT) from an annotation. Such a LUT can also } \seealso{ -Other atlas functions: \code{\link{read.fs.annot}}, - \code{\link{read.fs.colortable}}, - \code{\link{write.fs.annot}}, - \code{\link{write.fs.colortable}} +Other atlas functions: +\code{\link{read.fs.annot}()}, +\code{\link{read.fs.colortable}()}, +\code{\link{write.fs.annot}()}, +\code{\link{write.fs.colortable}()} -Other colorLUT functions: \code{\link{read.fs.colortable}}, - \code{\link{write.fs.colortable}} +Other colorLUT functions: +\code{\link{read.fs.colortable}()}, +\code{\link{write.fs.colortable}()} } \concept{atlas functions} \concept{colorLUT functions} diff --git a/man/fs.get.morph.file.ext.for.format.Rd b/man/fs.get.morph.file.ext.for.format.Rd index 95eccbf..487c649 100644 --- a/man/fs.get.morph.file.ext.for.format.Rd +++ b/man/fs.get.morph.file.ext.for.format.Rd @@ -16,12 +16,15 @@ file ext, string. The standard file extension for the format. (May be an empty s Given a morphometry file format, derive the proper file extension. } \seealso{ -Other morphometry functions: \code{\link{fs.get.morph.file.format.from.filename}}, - \code{\link{read.fs.curv}}, \code{\link{read.fs.mgh}}, - \code{\link{read.fs.morph}}, - \code{\link{read.fs.weight}}, - \code{\link{write.fs.curv}}, \code{\link{write.fs.mgh}}, - \code{\link{write.fs.morph}}, - \code{\link{write.fs.weight}} +Other morphometry functions: +\code{\link{fs.get.morph.file.format.from.filename}()}, +\code{\link{read.fs.curv}()}, +\code{\link{read.fs.mgh}()}, +\code{\link{read.fs.morph}()}, +\code{\link{read.fs.weight}()}, +\code{\link{write.fs.curv}()}, +\code{\link{write.fs.mgh}()}, +\code{\link{write.fs.morph}()}, +\code{\link{write.fs.weight}()} } \concept{morphometry functions} diff --git a/man/fs.get.morph.file.format.from.filename.Rd b/man/fs.get.morph.file.format.from.filename.Rd index fc5b1a0..080f7d3 100644 --- a/man/fs.get.morph.file.format.from.filename.Rd +++ b/man/fs.get.morph.file.format.from.filename.Rd @@ -16,12 +16,15 @@ format, string. The format, one of c("mgz", "mgh", "curv"). Given a morphometry file name, derive the proper file format, based on the end of the string. Case is ignored, i.e., cast to lowercase before checks. If the filepath ends with "mgh", returns format "mgh". For suffix "mgz", returns "mgz" format. For all others, returns "curv" format. } \seealso{ -Other morphometry functions: \code{\link{fs.get.morph.file.ext.for.format}}, - \code{\link{read.fs.curv}}, \code{\link{read.fs.mgh}}, - \code{\link{read.fs.morph}}, - \code{\link{read.fs.weight}}, - \code{\link{write.fs.curv}}, \code{\link{write.fs.mgh}}, - \code{\link{write.fs.morph}}, - \code{\link{write.fs.weight}} +Other morphometry functions: +\code{\link{fs.get.morph.file.ext.for.format}()}, +\code{\link{read.fs.curv}()}, +\code{\link{read.fs.mgh}()}, +\code{\link{read.fs.morph}()}, +\code{\link{read.fs.weight}()}, +\code{\link{write.fs.curv}()}, +\code{\link{write.fs.mgh}()}, +\code{\link{write.fs.morph}()}, +\code{\link{write.fs.weight}()} } \concept{morphometry functions} diff --git a/man/fs.patch.Rd b/man/fs.patch.Rd index 1753f78..6dc3a43 100644 --- a/man/fs.patch.Rd +++ b/man/fs.patch.Rd @@ -29,7 +29,9 @@ Constructor for fs.patch } \seealso{ -Other patch functions: \code{\link{read.fs.patch.asc}}, - \code{\link{read.fs.patch}}, \code{\link{write.fs.patch}} +Other patch functions: +\code{\link{read.fs.patch.asc}()}, +\code{\link{read.fs.patch}()}, +\code{\link{write.fs.patch}()} } \concept{patch functions} diff --git a/man/fs.volume.from.oro.nifti.Rd b/man/fs.volume.from.oro.nifti.Rd index 6aa8aa4..ab046ae 100644 --- a/man/fs.volume.from.oro.nifti.Rd +++ b/man/fs.volume.from.oro.nifti.Rd @@ -29,3 +29,4 @@ This is work in progress. This function takes an `oro.nifti` instance and comput \seealso{ \code{\link[oro.nifti]{readNIfTI}}, \code{\link[freesurferformats]{read.fs.mgh}} } +\keyword{internal} diff --git a/man/mghheader.is.ras.valid.Rd b/man/mghheader.is.ras.valid.Rd index 0b399ac..a0f99a4 100644 --- a/man/mghheader.is.ras.valid.Rd +++ b/man/mghheader.is.ras.valid.Rd @@ -24,11 +24,12 @@ Check whether header contains valid ras information } \seealso{ -Other header coordinate space: \code{\link{mghheader.ras2vox.tkreg}}, - \code{\link{mghheader.ras2vox}}, - \code{\link{mghheader.scanner2tkreg}}, - \code{\link{mghheader.tkreg2scanner}}, - \code{\link{mghheader.vox2ras.tkreg}}, - \code{\link{mghheader.vox2ras}} +Other header coordinate space: +\code{\link{mghheader.ras2vox.tkreg}()}, +\code{\link{mghheader.ras2vox}()}, +\code{\link{mghheader.scanner2tkreg}()}, +\code{\link{mghheader.tkreg2scanner}()}, +\code{\link{mghheader.vox2ras.tkreg}()}, +\code{\link{mghheader.vox2ras}()} } \concept{header coordinate space} diff --git a/man/mghheader.ras2vox.Rd b/man/mghheader.ras2vox.Rd index 4d3d2e5..15ea073 100644 --- a/man/mghheader.ras2vox.Rd +++ b/man/mghheader.ras2vox.Rd @@ -24,11 +24,12 @@ This is also known as the 'scanner' or 'native' ras2vox. It is the inverse of th } \seealso{ -Other header coordinate space: \code{\link{mghheader.is.ras.valid}}, - \code{\link{mghheader.ras2vox.tkreg}}, - \code{\link{mghheader.scanner2tkreg}}, - \code{\link{mghheader.tkreg2scanner}}, - \code{\link{mghheader.vox2ras.tkreg}}, - \code{\link{mghheader.vox2ras}} +Other header coordinate space: +\code{\link{mghheader.is.ras.valid}()}, +\code{\link{mghheader.ras2vox.tkreg}()}, +\code{\link{mghheader.scanner2tkreg}()}, +\code{\link{mghheader.tkreg2scanner}()}, +\code{\link{mghheader.vox2ras.tkreg}()}, +\code{\link{mghheader.vox2ras}()} } \concept{header coordinate space} diff --git a/man/mghheader.ras2vox.tkreg.Rd b/man/mghheader.ras2vox.tkreg.Rd index 9d80071..1acdebd 100644 --- a/man/mghheader.ras2vox.tkreg.Rd +++ b/man/mghheader.ras2vox.tkreg.Rd @@ -24,11 +24,12 @@ This is also known as the 'tkreg' ras2vox. It is the inverse of the respective v } \seealso{ -Other header coordinate space: \code{\link{mghheader.is.ras.valid}}, - \code{\link{mghheader.ras2vox}}, - \code{\link{mghheader.scanner2tkreg}}, - \code{\link{mghheader.tkreg2scanner}}, - \code{\link{mghheader.vox2ras.tkreg}}, - \code{\link{mghheader.vox2ras}} +Other header coordinate space: +\code{\link{mghheader.is.ras.valid}()}, +\code{\link{mghheader.ras2vox}()}, +\code{\link{mghheader.scanner2tkreg}()}, +\code{\link{mghheader.tkreg2scanner}()}, +\code{\link{mghheader.vox2ras.tkreg}()}, +\code{\link{mghheader.vox2ras}()} } \concept{header coordinate space} diff --git a/man/mghheader.scanner2tkreg.Rd b/man/mghheader.scanner2tkreg.Rd index 9f50335..d3cf3e3 100644 --- a/man/mghheader.scanner2tkreg.Rd +++ b/man/mghheader.scanner2tkreg.Rd @@ -24,11 +24,12 @@ This is also known as the 'scanner2tkreg' matrix. Note that this is a RAS-to-RAS } \seealso{ -Other header coordinate space: \code{\link{mghheader.is.ras.valid}}, - \code{\link{mghheader.ras2vox.tkreg}}, - \code{\link{mghheader.ras2vox}}, - \code{\link{mghheader.tkreg2scanner}}, - \code{\link{mghheader.vox2ras.tkreg}}, - \code{\link{mghheader.vox2ras}} +Other header coordinate space: +\code{\link{mghheader.is.ras.valid}()}, +\code{\link{mghheader.ras2vox.tkreg}()}, +\code{\link{mghheader.ras2vox}()}, +\code{\link{mghheader.tkreg2scanner}()}, +\code{\link{mghheader.vox2ras.tkreg}()}, +\code{\link{mghheader.vox2ras}()} } \concept{header coordinate space} diff --git a/man/mghheader.tkreg2scanner.Rd b/man/mghheader.tkreg2scanner.Rd index 04750ce..f114cab 100644 --- a/man/mghheader.tkreg2scanner.Rd +++ b/man/mghheader.tkreg2scanner.Rd @@ -24,11 +24,12 @@ This is also known as the 'tkreg2scanner' matrix. Note that this is a RAS-to-RAS } \seealso{ -Other header coordinate space: \code{\link{mghheader.is.ras.valid}}, - \code{\link{mghheader.ras2vox.tkreg}}, - \code{\link{mghheader.ras2vox}}, - \code{\link{mghheader.scanner2tkreg}}, - \code{\link{mghheader.vox2ras.tkreg}}, - \code{\link{mghheader.vox2ras}} +Other header coordinate space: +\code{\link{mghheader.is.ras.valid}()}, +\code{\link{mghheader.ras2vox.tkreg}()}, +\code{\link{mghheader.ras2vox}()}, +\code{\link{mghheader.scanner2tkreg}()}, +\code{\link{mghheader.vox2ras.tkreg}()}, +\code{\link{mghheader.vox2ras}()} } \concept{header coordinate space} diff --git a/man/mghheader.vox2ras.Rd b/man/mghheader.vox2ras.Rd index ffd2142..836e7ec 100644 --- a/man/mghheader.vox2ras.Rd +++ b/man/mghheader.vox2ras.Rd @@ -24,11 +24,12 @@ This is also known as the 'scanner' or 'native' vox2ras. It is the inverse of t } \seealso{ -Other header coordinate space: \code{\link{mghheader.is.ras.valid}}, - \code{\link{mghheader.ras2vox.tkreg}}, - \code{\link{mghheader.ras2vox}}, - \code{\link{mghheader.scanner2tkreg}}, - \code{\link{mghheader.tkreg2scanner}}, - \code{\link{mghheader.vox2ras.tkreg}} +Other header coordinate space: +\code{\link{mghheader.is.ras.valid}()}, +\code{\link{mghheader.ras2vox.tkreg}()}, +\code{\link{mghheader.ras2vox}()}, +\code{\link{mghheader.scanner2tkreg}()}, +\code{\link{mghheader.tkreg2scanner}()}, +\code{\link{mghheader.vox2ras.tkreg}()} } \concept{header coordinate space} diff --git a/man/mghheader.vox2ras.tkreg.Rd b/man/mghheader.vox2ras.tkreg.Rd index 7e44883..a0827aa 100644 --- a/man/mghheader.vox2ras.tkreg.Rd +++ b/man/mghheader.vox2ras.tkreg.Rd @@ -24,11 +24,12 @@ This is also known as the 'tkreg' vox2ras. It is the inverse of the respective r } \seealso{ -Other header coordinate space: \code{\link{mghheader.is.ras.valid}}, - \code{\link{mghheader.ras2vox.tkreg}}, - \code{\link{mghheader.ras2vox}}, - \code{\link{mghheader.scanner2tkreg}}, - \code{\link{mghheader.tkreg2scanner}}, - \code{\link{mghheader.vox2ras}} +Other header coordinate space: +\code{\link{mghheader.is.ras.valid}()}, +\code{\link{mghheader.ras2vox.tkreg}()}, +\code{\link{mghheader.ras2vox}()}, +\code{\link{mghheader.scanner2tkreg}()}, +\code{\link{mghheader.tkreg2scanner}()}, +\code{\link{mghheader.vox2ras}()} } \concept{header coordinate space} diff --git a/man/read.fs.annot.Rd b/man/read.fs.annot.Rd index e43988c..1cd028e 100644 --- a/man/read.fs.annot.Rd +++ b/man/read.fs.annot.Rd @@ -4,8 +4,7 @@ \alias{read.fs.annot} \title{Read file in FreeSurfer annotation format} \usage{ -read.fs.annot(filepath, empty_label_name = "unknown", - metadata = list()) +read.fs.annot(filepath, empty_label_name = "unknown", metadata = list()) } \arguments{ \item{filepath}{string. Full path to the input annotation file. Note: gzipped files are supported and gz format is assumed if the filepath ends with ".gz".} @@ -31,9 +30,10 @@ Read a data annotation file in FreeSurfer format. Such a file assigns a label an } \seealso{ -Other atlas functions: \code{\link{colortable.from.annot}}, - \code{\link{read.fs.colortable}}, - \code{\link{write.fs.annot}}, - \code{\link{write.fs.colortable}} +Other atlas functions: +\code{\link{colortable.from.annot}()}, +\code{\link{read.fs.colortable}()}, +\code{\link{write.fs.annot}()}, +\code{\link{write.fs.colortable}()} } \concept{atlas functions} diff --git a/man/read.fs.colortable.Rd b/man/read.fs.colortable.Rd index 97fc061..d0850af 100644 --- a/man/read.fs.colortable.Rd +++ b/man/read.fs.colortable.Rd @@ -24,13 +24,15 @@ Read a colortable from a text file in FreeSurfer ASCII colortable lookup table ( } \seealso{ -Other atlas functions: \code{\link{colortable.from.annot}}, - \code{\link{read.fs.annot}}, - \code{\link{write.fs.annot}}, - \code{\link{write.fs.colortable}} +Other atlas functions: +\code{\link{colortable.from.annot}()}, +\code{\link{read.fs.annot}()}, +\code{\link{write.fs.annot}()}, +\code{\link{write.fs.colortable}()} -Other colorLUT functions: \code{\link{colortable.from.annot}}, - \code{\link{write.fs.colortable}} +Other colorLUT functions: +\code{\link{colortable.from.annot}()}, +\code{\link{write.fs.colortable}()} } \concept{atlas functions} \concept{colorLUT functions} diff --git a/man/read.fs.curv.Rd b/man/read.fs.curv.Rd index 04eb4eb..4996709 100644 --- a/man/read.fs.curv.Rd +++ b/man/read.fs.curv.Rd @@ -27,12 +27,15 @@ Read vertex-wise brain morphometry data from a file in FreeSurfer 'curv' format. } \seealso{ -Other morphometry functions: \code{\link{fs.get.morph.file.ext.for.format}}, - \code{\link{fs.get.morph.file.format.from.filename}}, - \code{\link{read.fs.mgh}}, \code{\link{read.fs.morph}}, - \code{\link{read.fs.weight}}, - \code{\link{write.fs.curv}}, \code{\link{write.fs.mgh}}, - \code{\link{write.fs.morph}}, - \code{\link{write.fs.weight}} +Other morphometry functions: +\code{\link{fs.get.morph.file.ext.for.format}()}, +\code{\link{fs.get.morph.file.format.from.filename}()}, +\code{\link{read.fs.mgh}()}, +\code{\link{read.fs.morph}()}, +\code{\link{read.fs.weight}()}, +\code{\link{write.fs.curv}()}, +\code{\link{write.fs.mgh}()}, +\code{\link{write.fs.morph}()}, +\code{\link{write.fs.weight}()} } \concept{morphometry functions} diff --git a/man/read.fs.label.Rd b/man/read.fs.label.Rd index f8ef1dd..f417aae 100644 --- a/man/read.fs.label.Rd +++ b/man/read.fs.label.Rd @@ -4,8 +4,12 @@ \alias{read.fs.label} \title{Read file in FreeSurfer label format} \usage{ -read.fs.label(filepath, return_one_based_indices = TRUE, full = FALSE, - metadata = list()) +read.fs.label( + filepath, + return_one_based_indices = TRUE, + full = FALSE, + metadata = list() +) } \arguments{ \item{filepath}{string. Full path to the input label file.} @@ -30,6 +34,7 @@ Read a mask in FreeSurfer label format. } \seealso{ -Other label functions: \code{\link{write.fs.label}} +Other label functions: +\code{\link{write.fs.label}()} } \concept{label functions} diff --git a/man/read.fs.mgh.Rd b/man/read.fs.mgh.Rd index 232bebb..505777c 100644 --- a/man/read.fs.mgh.Rd +++ b/man/read.fs.mgh.Rd @@ -4,8 +4,13 @@ \alias{read.fs.mgh} \title{Read file in FreeSurfer MGH or MGZ format} \usage{ -read.fs.mgh(filepath, is_gzipped = "AUTO", flatten = FALSE, - with_header = FALSE, drop_empty_dims = FALSE) +read.fs.mgh( + filepath, + is_gzipped = "AUTO", + flatten = FALSE, + with_header = FALSE, + drop_empty_dims = FALSE +) } \arguments{ \item{filepath}{string. Full path to the input MGZ or MGH file.} @@ -40,12 +45,15 @@ Read multi-dimensional brain imaging data from a file in FreeSurfer binary MGH o \seealso{ To derive more information from the header, see the `mghheader.*` functions, like \code{\link[freesurferformats]{mghheader.vox2ras.tkreg}}. -Other morphometry functions: \code{\link{fs.get.morph.file.ext.for.format}}, - \code{\link{fs.get.morph.file.format.from.filename}}, - \code{\link{read.fs.curv}}, \code{\link{read.fs.morph}}, - \code{\link{read.fs.weight}}, - \code{\link{write.fs.curv}}, \code{\link{write.fs.mgh}}, - \code{\link{write.fs.morph}}, - \code{\link{write.fs.weight}} +Other morphometry functions: +\code{\link{fs.get.morph.file.ext.for.format}()}, +\code{\link{fs.get.morph.file.format.from.filename}()}, +\code{\link{read.fs.curv}()}, +\code{\link{read.fs.morph}()}, +\code{\link{read.fs.weight}()}, +\code{\link{write.fs.curv}()}, +\code{\link{write.fs.mgh}()}, +\code{\link{write.fs.morph}()}, +\code{\link{write.fs.weight}()} } \concept{morphometry functions} diff --git a/man/read.fs.morph.Rd b/man/read.fs.morph.Rd index 3434f58..52564a4 100644 --- a/man/read.fs.morph.Rd +++ b/man/read.fs.morph.Rd @@ -31,12 +31,15 @@ Read vertex-wise brain surface data from a file. The file can be in any of the s } \seealso{ -Other morphometry functions: \code{\link{fs.get.morph.file.ext.for.format}}, - \code{\link{fs.get.morph.file.format.from.filename}}, - \code{\link{read.fs.curv}}, \code{\link{read.fs.mgh}}, - \code{\link{read.fs.weight}}, - \code{\link{write.fs.curv}}, \code{\link{write.fs.mgh}}, - \code{\link{write.fs.morph}}, - \code{\link{write.fs.weight}} +Other morphometry functions: +\code{\link{fs.get.morph.file.ext.for.format}()}, +\code{\link{fs.get.morph.file.format.from.filename}()}, +\code{\link{read.fs.curv}()}, +\code{\link{read.fs.mgh}()}, +\code{\link{read.fs.weight}()}, +\code{\link{write.fs.curv}()}, +\code{\link{write.fs.mgh}()}, +\code{\link{write.fs.morph}()}, +\code{\link{write.fs.weight}()} } \concept{morphometry functions} diff --git a/man/read.fs.patch.Rd b/man/read.fs.patch.Rd index a2e8dd2..4612dcc 100644 --- a/man/read.fs.patch.Rd +++ b/man/read.fs.patch.Rd @@ -18,8 +18,9 @@ named list with 2 entries: "faces": can be NULL, only available if the format is A patch is a subset of a surface. Note that the contents of ASCII and binary patch format files is different. A binary format patch contains vertices only, without connection (face) information. ASCII patch files can also contain face data. See the return value description for details. } \seealso{ -Other patch functions: \code{\link{fs.patch}}, - \code{\link{read.fs.patch.asc}}, - \code{\link{write.fs.patch}} +Other patch functions: +\code{\link{fs.patch}()}, +\code{\link{read.fs.patch.asc}()}, +\code{\link{write.fs.patch}()} } \concept{patch functions} diff --git a/man/read.fs.patch.asc.Rd b/man/read.fs.patch.asc.Rd index 615b9c2..52c0b1e 100644 --- a/man/read.fs.patch.asc.Rd +++ b/man/read.fs.patch.asc.Rd @@ -16,7 +16,9 @@ named list. The list has the following named entries: "vertices": see return val An ASCII format patch is a part of a brain surface mesh, and is a mesh itself. It consists of vertices and faces. The ASCII patch format is very similar to the ASCII surface format. **Note:** The contents of ASCII and binary patch format files is different. The ASCII patch format is not ideal for parsing, and loading such files is currently quite slow. } \seealso{ -Other patch functions: \code{\link{fs.patch}}, - \code{\link{read.fs.patch}}, \code{\link{write.fs.patch}} +Other patch functions: +\code{\link{fs.patch}()}, +\code{\link{read.fs.patch}()}, +\code{\link{write.fs.patch}()} } \concept{patch functions} diff --git a/man/read.fs.surface.Rd b/man/read.fs.surface.Rd index fde8de8..e8271bc 100644 --- a/man/read.fs.surface.Rd +++ b/man/read.fs.surface.Rd @@ -26,12 +26,13 @@ Read a brain surface mesh consisting of vertex and face data from a file in Free } \seealso{ -Other mesh functions: \code{\link{read.fs.surface.asc}}, - \code{\link{read.fs.surface.vtk}}, - \code{\link{read_nisurfacefile}}, - \code{\link{read_nisurface}}, - \code{\link{write.fs.surface.asc}}, - \code{\link{write.fs.surface.vtk}}, - \code{\link{write.fs.surface}} +Other mesh functions: +\code{\link{read.fs.surface.asc}()}, +\code{\link{read.fs.surface.vtk}()}, +\code{\link{read_nisurfacefile}()}, +\code{\link{read_nisurface}()}, +\code{\link{write.fs.surface.asc}()}, +\code{\link{write.fs.surface.vtk}()}, +\code{\link{write.fs.surface}()} } \concept{mesh functions} diff --git a/man/read.fs.surface.asc.Rd b/man/read.fs.surface.asc.Rd index b059baa..919a87f 100644 --- a/man/read.fs.surface.asc.Rd +++ b/man/read.fs.surface.asc.Rd @@ -16,12 +16,13 @@ named list. The list has the following named entries: "vertices": nx3 double mat Read FreeSurfer ASCII format surface. } \seealso{ -Other mesh functions: \code{\link{read.fs.surface.vtk}}, - \code{\link{read.fs.surface}}, - \code{\link{read_nisurfacefile}}, - \code{\link{read_nisurface}}, - \code{\link{write.fs.surface.asc}}, - \code{\link{write.fs.surface.vtk}}, - \code{\link{write.fs.surface}} +Other mesh functions: +\code{\link{read.fs.surface.vtk}()}, +\code{\link{read.fs.surface}()}, +\code{\link{read_nisurfacefile}()}, +\code{\link{read_nisurface}()}, +\code{\link{write.fs.surface.asc}()}, +\code{\link{write.fs.surface.vtk}()}, +\code{\link{write.fs.surface}()} } \concept{mesh functions} diff --git a/man/read.fs.surface.vtk.Rd b/man/read.fs.surface.vtk.Rd index f7b7f71..dff4f69 100644 --- a/man/read.fs.surface.vtk.Rd +++ b/man/read.fs.surface.vtk.Rd @@ -16,12 +16,13 @@ named list. The list has the following named entries: "vertices": nx3 double mat This reads meshes (vtk polygon datasets) from text files in VTK ASCII format. See https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf for format spec. Note that this function does **not** read arbitrary VTK datasets, i.e., it supports only a subset of the possible contents of VTK files (i.e., polygon meshes). } \seealso{ -Other mesh functions: \code{\link{read.fs.surface.asc}}, - \code{\link{read.fs.surface}}, - \code{\link{read_nisurfacefile}}, - \code{\link{read_nisurface}}, - \code{\link{write.fs.surface.asc}}, - \code{\link{write.fs.surface.vtk}}, - \code{\link{write.fs.surface}} +Other mesh functions: +\code{\link{read.fs.surface.asc}()}, +\code{\link{read.fs.surface}()}, +\code{\link{read_nisurfacefile}()}, +\code{\link{read_nisurface}()}, +\code{\link{write.fs.surface.asc}()}, +\code{\link{write.fs.surface.vtk}()}, +\code{\link{write.fs.surface}()} } \concept{mesh functions} diff --git a/man/read.fs.weight.Rd b/man/read.fs.weight.Rd index 53df3ee..db4f11c 100644 --- a/man/read.fs.weight.Rd +++ b/man/read.fs.weight.Rd @@ -18,11 +18,15 @@ the indices and weight data, as a named list. Entries: "vertex_indices": vector Read morphometry data in weight format (aka `w` files). A weight format file contains morphometry data for a set of vertices, defined by their index in a surface. This can be only a **subset** of the surface vertices. } \seealso{ -Other morphometry functions: \code{\link{fs.get.morph.file.ext.for.format}}, - \code{\link{fs.get.morph.file.format.from.filename}}, - \code{\link{read.fs.curv}}, \code{\link{read.fs.mgh}}, - \code{\link{read.fs.morph}}, \code{\link{write.fs.curv}}, - \code{\link{write.fs.mgh}}, \code{\link{write.fs.morph}}, - \code{\link{write.fs.weight}} +Other morphometry functions: +\code{\link{fs.get.morph.file.ext.for.format}()}, +\code{\link{fs.get.morph.file.format.from.filename}()}, +\code{\link{read.fs.curv}()}, +\code{\link{read.fs.mgh}()}, +\code{\link{read.fs.morph}()}, +\code{\link{write.fs.curv}()}, +\code{\link{write.fs.mgh}()}, +\code{\link{write.fs.morph}()}, +\code{\link{write.fs.weight}()} } \concept{morphometry functions} diff --git a/man/read_nisurface.Rd b/man/read_nisurface.Rd index e69daab..03bb7f7 100644 --- a/man/read_nisurface.Rd +++ b/man/read_nisurface.Rd @@ -30,12 +30,13 @@ Tries to read all files which can be constructed from the base path and the give } \seealso{ -Other mesh functions: \code{\link{read.fs.surface.asc}}, - \code{\link{read.fs.surface.vtk}}, - \code{\link{read.fs.surface}}, - \code{\link{read_nisurfacefile}}, - \code{\link{write.fs.surface.asc}}, - \code{\link{write.fs.surface.vtk}}, - \code{\link{write.fs.surface}} +Other mesh functions: +\code{\link{read.fs.surface.asc}()}, +\code{\link{read.fs.surface.vtk}()}, +\code{\link{read.fs.surface}()}, +\code{\link{read_nisurfacefile}()}, +\code{\link{write.fs.surface.asc}()}, +\code{\link{write.fs.surface.vtk}()}, +\code{\link{write.fs.surface}()} } \concept{mesh functions} diff --git a/man/read_nisurfacefile.Rd b/man/read_nisurfacefile.Rd index a0c31d3..8a371fe 100644 --- a/man/read_nisurfacefile.Rd +++ b/man/read_nisurfacefile.Rd @@ -4,8 +4,7 @@ \alias{read_nisurfacefile} \title{S3 method to read a neuroimaging surface file.} \usage{ -read_nisurfacefile(filepath, methods = c("fsnative", "fsascii", "gifti"), - ...) +read_nisurfacefile(filepath, methods = c("fsnative", "fsascii", "gifti"), ...) } \arguments{ \item{filepath}{character string, the full path to the input surface file.} @@ -28,12 +27,13 @@ Tries to read the file with all implemented surface format reader methods. The f } \seealso{ -Other mesh functions: \code{\link{read.fs.surface.asc}}, - \code{\link{read.fs.surface.vtk}}, - \code{\link{read.fs.surface}}, - \code{\link{read_nisurface}}, - \code{\link{write.fs.surface.asc}}, - \code{\link{write.fs.surface.vtk}}, - \code{\link{write.fs.surface}} +Other mesh functions: +\code{\link{read.fs.surface.asc}()}, +\code{\link{read.fs.surface.vtk}()}, +\code{\link{read.fs.surface}()}, +\code{\link{read_nisurface}()}, +\code{\link{write.fs.surface.asc}()}, +\code{\link{write.fs.surface.vtk}()}, +\code{\link{write.fs.surface}()} } \concept{mesh functions} diff --git a/man/readable.files.Rd b/man/readable.files.Rd index 380b839..39b4d76 100644 --- a/man/readable.files.Rd +++ b/man/readable.files.Rd @@ -4,8 +4,12 @@ \alias{readable.files} \title{Find files with the given base name and extensions that exist.} \usage{ -readable.files(filepath, precedence = c(".mgh", ".mgz"), - error_if_none = TRUE, return_all = FALSE) +readable.files( + filepath, + precedence = c(".mgh", ".mgz"), + error_if_none = TRUE, + return_all = FALSE +) } \arguments{ \item{filepath}{character string, path to a file without extension} diff --git a/man/write.fs.annot.Rd b/man/write.fs.annot.Rd index e67b73e..1c5876a 100644 --- a/man/write.fs.annot.Rd +++ b/man/write.fs.annot.Rd @@ -4,9 +4,14 @@ \alias{write.fs.annot} \title{Write annotation to binary file.} \usage{ -write.fs.annot(filepath, num_vertices = NULL, colortable = NULL, +write.fs.annot( + filepath, + num_vertices = NULL, + colortable = NULL, labels_as_colorcodes = NULL, - labels_as_indices_into_colortable = NULL, fs.annot = NULL) + labels_as_indices_into_colortable = NULL, + fs.annot = NULL +) } \arguments{ \item{filepath}{string, path to the output file} @@ -42,9 +47,10 @@ Write an annotation to a FreeSurfer binary format annotation file in the new for } \seealso{ -Other atlas functions: \code{\link{colortable.from.annot}}, - \code{\link{read.fs.annot}}, - \code{\link{read.fs.colortable}}, - \code{\link{write.fs.colortable}} +Other atlas functions: +\code{\link{colortable.from.annot}()}, +\code{\link{read.fs.annot}()}, +\code{\link{read.fs.colortable}()}, +\code{\link{write.fs.colortable}()} } \concept{atlas functions} diff --git a/man/write.fs.colortable.Rd b/man/write.fs.colortable.Rd index 1b4be6b..414efa5 100644 --- a/man/write.fs.colortable.Rd +++ b/man/write.fs.colortable.Rd @@ -18,13 +18,15 @@ the written dataframe, invisible. Note that this is will contain a column named Write the colortable to a text file in FreeSurfer ASCII colortable lookup table (LUT) format. An example file is `FREESURFER_HOME/FreeSurferColorLUT.txt`. } \seealso{ -Other atlas functions: \code{\link{colortable.from.annot}}, - \code{\link{read.fs.annot}}, - \code{\link{read.fs.colortable}}, - \code{\link{write.fs.annot}} +Other atlas functions: +\code{\link{colortable.from.annot}()}, +\code{\link{read.fs.annot}()}, +\code{\link{read.fs.colortable}()}, +\code{\link{write.fs.annot}()} -Other colorLUT functions: \code{\link{colortable.from.annot}}, - \code{\link{read.fs.colortable}} +Other colorLUT functions: +\code{\link{colortable.from.annot}()}, +\code{\link{read.fs.colortable}()} } \concept{atlas functions} \concept{colorLUT functions} diff --git a/man/write.fs.curv.Rd b/man/write.fs.curv.Rd index 2c9b969..7aec696 100644 --- a/man/write.fs.curv.Rd +++ b/man/write.fs.curv.Rd @@ -16,12 +16,15 @@ Write vertex-wise brain surface data to a file in FreeSurfer binary 'curv' forma For a subject (MRI image pre-processed with FreeSurfer) named 'bert', an example file would be 'bert/surf/lh.thickness', which contains n values. Each value represents the cortical thickness at the respective vertex in the brain surface mesh of bert. } \seealso{ -Other morphometry functions: \code{\link{fs.get.morph.file.ext.for.format}}, - \code{\link{fs.get.morph.file.format.from.filename}}, - \code{\link{read.fs.curv}}, \code{\link{read.fs.mgh}}, - \code{\link{read.fs.morph}}, - \code{\link{read.fs.weight}}, \code{\link{write.fs.mgh}}, - \code{\link{write.fs.morph}}, - \code{\link{write.fs.weight}} +Other morphometry functions: +\code{\link{fs.get.morph.file.ext.for.format}()}, +\code{\link{fs.get.morph.file.format.from.filename}()}, +\code{\link{read.fs.curv}()}, +\code{\link{read.fs.mgh}()}, +\code{\link{read.fs.morph}()}, +\code{\link{read.fs.weight}()}, +\code{\link{write.fs.mgh}()}, +\code{\link{write.fs.morph}()}, +\code{\link{write.fs.weight}()} } \concept{morphometry functions} diff --git a/man/write.fs.label.Rd b/man/write.fs.label.Rd index 5bea3a3..9680c83 100644 --- a/man/write.fs.label.Rd +++ b/man/write.fs.label.Rd @@ -4,8 +4,13 @@ \alias{write.fs.label} \title{Write vertex indices to file in FreeSurfer label format} \usage{ -write.fs.label(filepath, vertex_indices, vertex_coords = NULL, - vertex_data = NULL, indices_are_one_based = TRUE) +write.fs.label( + filepath, + vertex_indices, + vertex_coords = NULL, + vertex_data = NULL, + indices_are_one_based = TRUE +) } \arguments{ \item{filepath}{string. Full path to the output label file. If it ends with ".gz", the file is written in gzipped format. Note that this is not common, and that other software may not handle this transparently.} @@ -40,6 +45,7 @@ Write vertex coordinates and vertex indices defining faces to a file in FreeSurf } \seealso{ -Other label functions: \code{\link{read.fs.label}} +Other label functions: +\code{\link{read.fs.label}()} } \concept{label functions} diff --git a/man/write.fs.mgh.Rd b/man/write.fs.mgh.Rd index b53a26e..5351ba8 100644 --- a/man/write.fs.mgh.Rd +++ b/man/write.fs.mgh.Rd @@ -4,8 +4,13 @@ \alias{write.fs.mgh} \title{Write file in FreeSurfer MGH or MGZ format} \usage{ -write.fs.mgh(filepath, data, vox2ras_matrix = NULL, mr_params = c(0, 0, - 0, 0, 0), mri_dtype = "auto") +write.fs.mgh( + filepath, + data, + vox2ras_matrix = NULL, + mr_params = c(0, 0, 0, 0, 0), + mri_dtype = "auto" +) } \arguments{ \item{filepath}{string. Full path to the output curv file. If this ends with ".mgz", the file will be written gzipped (i.e., in MGZ instead of MGH format).} @@ -22,13 +27,15 @@ write.fs.mgh(filepath, data, vox2ras_matrix = NULL, mr_params = c(0, 0, Write brain data to a file in FreeSurfer binary MGH or MGZ format. } \seealso{ -Other morphometry functions: \code{\link{fs.get.morph.file.ext.for.format}}, - \code{\link{fs.get.morph.file.format.from.filename}}, - \code{\link{read.fs.curv}}, \code{\link{read.fs.mgh}}, - \code{\link{read.fs.morph}}, - \code{\link{read.fs.weight}}, - \code{\link{write.fs.curv}}, - \code{\link{write.fs.morph}}, - \code{\link{write.fs.weight}} +Other morphometry functions: +\code{\link{fs.get.morph.file.ext.for.format}()}, +\code{\link{fs.get.morph.file.format.from.filename}()}, +\code{\link{read.fs.curv}()}, +\code{\link{read.fs.mgh}()}, +\code{\link{read.fs.morph}()}, +\code{\link{read.fs.weight}()}, +\code{\link{write.fs.curv}()}, +\code{\link{write.fs.morph}()}, +\code{\link{write.fs.weight}()} } \concept{morphometry functions} diff --git a/man/write.fs.morph.Rd b/man/write.fs.morph.Rd index 365ba43..0d23330 100644 --- a/man/write.fs.morph.Rd +++ b/man/write.fs.morph.Rd @@ -20,12 +20,15 @@ format, string. The format that was used to write the data. One of c("mgh", "mgz Given data and a morphometry file name, derive the proper format and write the file. } \seealso{ -Other morphometry functions: \code{\link{fs.get.morph.file.ext.for.format}}, - \code{\link{fs.get.morph.file.format.from.filename}}, - \code{\link{read.fs.curv}}, \code{\link{read.fs.mgh}}, - \code{\link{read.fs.morph}}, - \code{\link{read.fs.weight}}, - \code{\link{write.fs.curv}}, \code{\link{write.fs.mgh}}, - \code{\link{write.fs.weight}} +Other morphometry functions: +\code{\link{fs.get.morph.file.ext.for.format}()}, +\code{\link{fs.get.morph.file.format.from.filename}()}, +\code{\link{read.fs.curv}()}, +\code{\link{read.fs.mgh}()}, +\code{\link{read.fs.morph}()}, +\code{\link{read.fs.weight}()}, +\code{\link{write.fs.curv}()}, +\code{\link{write.fs.mgh}()}, +\code{\link{write.fs.weight}()} } \concept{morphometry functions} diff --git a/man/write.fs.patch.Rd b/man/write.fs.patch.Rd index 6f263c4..6a04b6b 100644 --- a/man/write.fs.patch.Rd +++ b/man/write.fs.patch.Rd @@ -18,8 +18,9 @@ the patch, invisible Write a surface patch, i.e. a set of vertices and patch border information, to a binary patch file. } \seealso{ -Other patch functions: \code{\link{fs.patch}}, - \code{\link{read.fs.patch.asc}}, - \code{\link{read.fs.patch}} +Other patch functions: +\code{\link{fs.patch}()}, +\code{\link{read.fs.patch.asc}()}, +\code{\link{read.fs.patch}()} } \concept{patch functions} diff --git a/man/write.fs.surface.Rd b/man/write.fs.surface.Rd index 4a7f449..9b6d14e 100644 --- a/man/write.fs.surface.Rd +++ b/man/write.fs.surface.Rd @@ -4,7 +4,7 @@ \alias{write.fs.surface} \title{Write mesh to file in FreeSurfer binary surface format} \usage{ -write.fs.surface(filepath, vertex_coords, faces) +write.fs.surface(filepath, vertex_coords, faces, format = "auto") } \arguments{ \item{filepath}{string. Full path to the output curv file. If it ends with ".gz", the file is written in gzipped format. Note that this is not common, and that other software may not handle this transparently.} @@ -12,6 +12,8 @@ write.fs.surface(filepath, vertex_coords, faces) \item{vertex_coords}{n x 3 matrix of doubles. Each row defined the x,y,z coords for a vertex.} \item{faces}{n x 3 matrix of integers. Each row defined the 3 vertex indices that make up the face. WARNING: Vertex indices should be given in R-style, i.e., the index of the first vertex is 1. However, they will be written in FreeSurfer style, i.e., all indices will have 1 substracted, so that the index of the first vertex will be zero.} + +\item{format}{character string, the format to use. One of 'bin' for FreeSurfer binary surface format, 'asc' for FreeSurfer ASCII format, 'vtk' for VTK ASCII legacy format, or 'auto' to derive the format from the file extension given in parameter 'filepath'. With 'auto', a path ending in '.asc' is interpreted as 'asc', a path ending in '.vtk' as vtk, and everything else as 'bin'.} } \value{ string the format that was written. One of "tris" or "quads". Currently only triangular meshes are supported, so always 'tris'. @@ -33,12 +35,13 @@ Write vertex coordinates and vertex indices defining faces to a file in FreeSurf } \seealso{ -Other mesh functions: \code{\link{read.fs.surface.asc}}, - \code{\link{read.fs.surface.vtk}}, - \code{\link{read.fs.surface}}, - \code{\link{read_nisurfacefile}}, - \code{\link{read_nisurface}}, - \code{\link{write.fs.surface.asc}}, - \code{\link{write.fs.surface.vtk}} +Other mesh functions: +\code{\link{read.fs.surface.asc}()}, +\code{\link{read.fs.surface.vtk}()}, +\code{\link{read.fs.surface}()}, +\code{\link{read_nisurfacefile}()}, +\code{\link{read_nisurface}()}, +\code{\link{write.fs.surface.asc}()}, +\code{\link{write.fs.surface.vtk}()} } \concept{mesh functions} diff --git a/man/write.fs.surface.asc.Rd b/man/write.fs.surface.asc.Rd index e927eae..82bc797 100644 --- a/man/write.fs.surface.asc.Rd +++ b/man/write.fs.surface.asc.Rd @@ -33,12 +33,13 @@ Write vertex coordinates and vertex indices defining faces to a file in FreeSurf } \seealso{ -Other mesh functions: \code{\link{read.fs.surface.asc}}, - \code{\link{read.fs.surface.vtk}}, - \code{\link{read.fs.surface}}, - \code{\link{read_nisurfacefile}}, - \code{\link{read_nisurface}}, - \code{\link{write.fs.surface.vtk}}, - \code{\link{write.fs.surface}} +Other mesh functions: +\code{\link{read.fs.surface.asc}()}, +\code{\link{read.fs.surface.vtk}()}, +\code{\link{read.fs.surface}()}, +\code{\link{read_nisurfacefile}()}, +\code{\link{read_nisurface}()}, +\code{\link{write.fs.surface.vtk}()}, +\code{\link{write.fs.surface}()} } \concept{mesh functions} diff --git a/man/write.fs.surface.vtk.Rd b/man/write.fs.surface.vtk.Rd index bf4542c..6157ceb 100644 --- a/man/write.fs.surface.vtk.Rd +++ b/man/write.fs.surface.vtk.Rd @@ -32,12 +32,13 @@ Write mesh to file in VTK ASCII format } \seealso{ -Other mesh functions: \code{\link{read.fs.surface.asc}}, - \code{\link{read.fs.surface.vtk}}, - \code{\link{read.fs.surface}}, - \code{\link{read_nisurfacefile}}, - \code{\link{read_nisurface}}, - \code{\link{write.fs.surface.asc}}, - \code{\link{write.fs.surface}} +Other mesh functions: +\code{\link{read.fs.surface.asc}()}, +\code{\link{read.fs.surface.vtk}()}, +\code{\link{read.fs.surface}()}, +\code{\link{read_nisurfacefile}()}, +\code{\link{read_nisurface}()}, +\code{\link{write.fs.surface.asc}()}, +\code{\link{write.fs.surface}()} } \concept{mesh functions} diff --git a/man/write.fs.weight.Rd b/man/write.fs.weight.Rd index 84d5a55..a67784c 100644 --- a/man/write.fs.weight.Rd +++ b/man/write.fs.weight.Rd @@ -17,12 +17,15 @@ write.fs.weight(filepath, vertex_indices, values) Write vertex-wise brain data for a set of vertices to a binary file in *weight* format. This format is also known as *paint* format or simply as *w* format. } \seealso{ -Other morphometry functions: \code{\link{fs.get.morph.file.ext.for.format}}, - \code{\link{fs.get.morph.file.format.from.filename}}, - \code{\link{read.fs.curv}}, \code{\link{read.fs.mgh}}, - \code{\link{read.fs.morph}}, - \code{\link{read.fs.weight}}, - \code{\link{write.fs.curv}}, \code{\link{write.fs.mgh}}, - \code{\link{write.fs.morph}} +Other morphometry functions: +\code{\link{fs.get.morph.file.ext.for.format}()}, +\code{\link{fs.get.morph.file.format.from.filename}()}, +\code{\link{read.fs.curv}()}, +\code{\link{read.fs.mgh}()}, +\code{\link{read.fs.morph}()}, +\code{\link{read.fs.weight}()}, +\code{\link{write.fs.curv}()}, +\code{\link{write.fs.mgh}()}, +\code{\link{write.fs.morph}()} } \concept{morphometry functions} diff --git a/vignettes/freesurferformats_write.Rmd b/vignettes/freesurferformats_write.Rmd index ad81627..d410ea1 100644 --- a/vignettes/freesurferformats_write.Rmd +++ b/vignettes/freesurferformats_write.Rmd @@ -92,9 +92,11 @@ You can manually set the 'dtype' parameter to force a certain MRI data type. E.g write.fs.mgh("regionmask_stored_as_MRI_FLOAT.mgh", as.double(some_surface_mask)); ``` -## Writing 'curv' format files +Notice: That was an example only. For a label, storing the indices as MRI_FLOAT makes little sense (you could use `as.logical()` instead to store them as as 'MRI_UCHAR'). -You can use `write.fs.curv` to write arbitrary data in binary curv format. The result is identical to using `write.fs.morph` with any filename that does not end in `mgh` or `mgz` instead.) +## Writing 'curv' format files (morphometry data) + +You can use `write.fs.curv` to write arbitrary data in binary curv format. The result is identical to using `write.fs.morph` with any filename that does not end in `mgh` or `mgz`.) ```{r, eval = FALSE} data = rnorm(120000, 2.0, 1.0); @@ -103,12 +105,12 @@ You can use `write.fs.curv` to write arbitrary data in binary curv format. The r ``` -It's worth knowing the if your filename ends with `.gz`, the file will be written in gzip format. +It's worth knowing the if your filename ends with `.gz`, the file will be written compressed. ## Writing surface format files -You can use `write.fs.surface` to write triangular meshes in binary surface format (the format used for files like 'surf/lh.white' or 'surf/rh.pial'). A mesh is defined by a list of vertices and a list of faces. +You can use `write.fs.surface` to write triangular meshes in binary surface format (the format used for files like 'surf/lh.white' or 'surf/rh.pial'). A mesh is defined by a list of vertices and a list of faces as indices into the latter, knows as an *indexed face-set*. ```{r, eval = FALSE} vertices = matrix(rep(0.3, 15), nrow=3); # 5 vertices @@ -119,10 +121,12 @@ You can use `write.fs.surface` to write triangular meshes in binary surface form The vertex indices used to define the faces should be 1-based, as used in R. They will be written 0-based to the file. +You can also use this function to write meshes in FreeSurfer ASCII format (`.asc`) or in VTK ASCII format (`.vtk`), see the parameter `format` for details. + ## Writing label files -Labels can be written with the `write.fs.label` function. A label is nothing but a list of vertex indices. +Labels can be written with the `write.fs.label` function. A label is nothing but a list of vertex indices. These indices should be passed 1-based, as they are used in `R`. ```{r, eval = FALSE} output_file = tempfile(); @@ -135,6 +139,8 @@ write.fs.label(output_file, vertex_indices); ``` +You can attach a single floating point value to each vertex of the label, see the parameter 'vertex_data' for details. + ## Writing color lookup table (LUT) files in ASCII format @@ -148,4 +154,4 @@ output_file = tempfile(fileext = ".txt"); write.fs.colortable(output_file, colortable_df); ``` - +A colortable is a table that contains one structure per row, and assigns each structure an RGBA color. Colortables are typically used to color the different brain regions of the segmented brain volume. The file 'FreeSurferColorLUT.txt' that comes with FreeSurfer is an example for a colortable.