Package: freesurferformats 0.1.17.9000

freesurferformats: Read and Write 'FreeSurfer' Neuroimaging File Formats

Provides functions to read and write neuroimaging data in various file formats, with a focus on 'FreeSurfer' <http://freesurfer.net/> formats. This includes, but is not limited to, the following file formats: 1) MGH/MGZ format files, which can contain multi-dimensional images or other data. Typically they contain time-series of three-dimensional brain scans acquired by magnetic resonance imaging (MRI). They can also contain vertex-wise measures of surface morphometry data. The MGH format is named after the Massachusetts General Hospital, and the MGZ format is a compressed version of the same format. 2) 'FreeSurfer' morphometry data files in binary 'curv' format. These contain vertex-wise surface measures, i.e., one scalar value for each vertex of a brain surface mesh. These are typically values like the cortical thickness or brain surface area at each vertex. 3) Annotation file format. This contains a brain surface parcellation derived from a cortical atlas. 4) Surface file format. Contains a brain surface mesh, given by a list of vertices and a list of faces.

Authors:Tim Schäfer [aut, cre]

freesurferformats_0.1.17.9000.tar.gz
freesurferformats_0.1.17.9000.zip(r-4.5)freesurferformats_0.1.17.9000.zip(r-4.4)freesurferformats_0.1.17.9000.zip(r-4.3)
freesurferformats_0.1.17.9000.tgz(r-4.4-any)freesurferformats_0.1.17.9000.tgz(r-4.3-any)
freesurferformats_0.1.17.9000.tar.gz(r-4.5-noble)freesurferformats_0.1.17.9000.tar.gz(r-4.4-noble)
freesurferformats_0.1.17.9000.tgz(r-4.4-emscripten)freesurferformats_0.1.17.9000.tgz(r-4.3-emscripten)
freesurferformats.pdf |freesurferformats.html
freesurferformats/json (API)

# Install 'freesurferformats' in R:
install.packages('freesurferformats', repos = c('https://dfsp-spirit.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/dfsp-spirit/freesurferformats/issues

On CRAN:

brainbrain-atlasbrain-surfacescurvdtifileformatsfreesurferlabelmeshmghmrineuroimagingparcellationresearchsurfacevoxel

146 exports 23 stars 7.82 score 8 dependencies 8 dependents 20 scripts 999 downloads

Last updated 28 days agofrom:4588ac6be3. Checks:OK: 1 NOTE: 6. Indexed: yes.

TargetResultDate
Doc / VignettesOKSep 15 2024
R-4.5-winNOTESep 15 2024
R-4.5-linuxNOTESep 15 2024
R-4.4-winNOTESep 15 2024
R-4.4-macNOTESep 15 2024
R-4.3-winNOTESep 15 2024
R-4.3-macNOTESep 15 2024

Exports:annot.max.region.idxbvsmpcdataclosest.vert.to.pointcolortable.from.annotdelete_all_opt_datadoapply.transform.mtxdownload_opt_datafaces.quad.to.trisfaces.tris.to.quadflip2Dflip3Dfs.get.morph.file.ext.for.formatfs.get.morph.file.format.from.filenamefs.patchfs.surface.to.tmesh3dget_opt_data_filepathgifti_writergifti_xmlgifti_xml_add_global_metadatagifti_xml_writegiftixml_add_labeltable_from_annotis.bvsmpis.fs.annotis.fs.labelis.fs.surfaceis.fs.volumeis.mghheaderlist_opt_datamghheader.centervoxelRAS.from.firstvoxelRASmghheader.crs.orientationmghheader.is.conformedmghheader.is.ras.validmghheader.primary.slice.directionmghheader.ras2voxmghheader.ras2vox.tkregmghheader.scanner2tkregmghheader.tkreg2scannermghheader.update.from.vox2rasmghheader.vox2rasmghheader.vox2ras.tkregmghheader.vox2voxmni152regni1header.templateni2header.templatenifti.datadim.from.dimfieldnifti.datadim.to.dimfieldnifti.file.uses.fshacknifti.file.versionnifti.header.checkras.to.surfacerasras.to.talairachrasread_nisurfaceread_nisurfacefileread.dti.tckread.dti.trkread.dti.tsfread.fs.annotread.fs.annot.giiread.fs.colortableread.fs.curvread.fs.gcaread.fs.labelread.fs.label.giiread.fs.label.nativeread.fs.mghread.fs.morphread.fs.morph.ascread.fs.morph.bvsmpread.fs.morph.ciftiread.fs.morph.giiread.fs.morph.ni1read.fs.morph.ni2read.fs.morph.niiread.fs.morph.txtread.fs.patchread.fs.patch.ascread.fs.surfaceread.fs.surface.ascread.fs.surface.bvsrfread.fs.surface.byuread.fs.surface.georead.fs.surface.giiread.fs.surface.icoread.fs.surface.mz3read.fs.surface.objread.fs.surface.offread.fs.surface.plyread.fs.surface.stlread.fs.surface.stl.binread.fs.surface.vtkread.fs.transformread.fs.transform.datread.fs.transform.ltaread.fs.transform.xfmread.fs.volumeread.fs.volume.niiread.fs.weightread.mesh.brainvoyagerread.nifti1.dataread.nifti1.headerread.nifti2.dataread.nifti2.headerread.smp.brainvoyagerreadable.filesrotate2Drotate3Dsm0to1sm1to0surfaceras.to.rassurfaceras.to.talairachtalairachras.to.rasvertex.euclid.distvertexdists.to.pointwrite.fs.annotwrite.fs.annot.giiwrite.fs.colortablewrite.fs.curvwrite.fs.labelwrite.fs.label.giiwrite.fs.mghwrite.fs.morphwrite.fs.morph.ascwrite.fs.morph.giiwrite.fs.morph.ni1write.fs.morph.ni2write.fs.morph.smpwrite.fs.morph.txtwrite.fs.patchwrite.fs.surfacewrite.fs.surface.ascwrite.fs.surface.bvsrfwrite.fs.surface.byuwrite.fs.surface.giiwrite.fs.surface.mz3write.fs.surface.objwrite.fs.surface.offwrite.fs.surface.plywrite.fs.surface.ply2write.fs.surface.vtkwrite.fs.weightwrite.fs.weight.ascwrite.nifti1write.nifti2write.smp.brainvoyagerxml_node_gifti_coordtransform

Dependencies:clicurldigestdownloaderpkgfilecacherappdirsrlangxml2

Computing volume header data with freesurferformats

Rendered fromfreesurferformats_header.Rmdusingknitr::rmarkdownon Sep 15 2024.

Last update: 2020-02-11
Started: 2020-02-11

Reading FreeSurfer neuroimaging data with freesurferformats

Rendered fromfreesurferformats.Rmdusingknitr::rmarkdownon Sep 15 2024.

Last update: 2020-09-04
Started: 2019-08-21

Writing FreeSurfer neuroimaging data with freesurferformats

Rendered fromfreesurferformats_write.Rmdusingknitr::rmarkdownon Sep 15 2024.

Last update: 2020-04-14
Started: 2019-09-13

Readme and manuals

Help Manual

Help pageTopics
Get max region index of an fs.annot instance.annot.max.region.idx
Create new bvsmp instance encoding morph data for Brainvoyager.bvsmp
Create CDATA element string from string.cdata
Find vertex index closest to given query coordinate using Euclidean distance.closest.vert.to.point
Extract color lookup table (LUT) from annotation.colortable.from.annot
Delete all data in the package cache.delete_all_opt_data
Apply a spatial transformation matrix to the given coordinates.doapply.transform.mtx
Download optional data for the freesurferformats package.download_opt_data
Convert quadrangular faces or polygons to triangular ones.faces.quad.to.tris
Convert tris faces to quad faces by simple merging.faces.tris.to.quad
Flip a 2D matrix.flip2D
Flip a 3D array along an axis.flip3D
Determine morphometry file extension from formatfs.get.morph.file.ext.for.format
Determine morphometry file format from filenamefs.get.morph.file.format.from.filename
Constructor for fs.patchfs.patch
Get an rgl tmesh3d instance from a brain surface mesh.fs.surface.to.tmesh3d
Access a single file from the package cache by its file name.get_opt_data_filepath
Write data to a gifti file.gifti_writer
Get GIFTI XML representation of data.gifti_xml
Add metadata to GIFTI XML tree.gifti_xml_add_global_metadata
Write XML tree to a gifti file.gifti_xml_write
Add a label tabel from an annotation to a GIFTI XML tree.giftixml_add_labeltable_from_annot
Check whether object is a bvsmp instance.is.bvsmp
Check whether object is an fs.annotis.fs.annot
Check whether object is an fs.labelis.fs.label
Check whether object is an fs.surfaceis.fs.surface
Check whether object is an fs.volumeis.fs.volume
Check whether object is an mghheaderis.mghheader
Get file names available in package cache.list_opt_data
Compute RAS coords of center voxel.mghheader.centervoxelRAS.from.firstvoxelRAS
Compute MGH volume orientation string.mghheader.crs.orientation
Determine whether an MGH volume is conformed.mghheader.is.conformed
Check whether header contains valid ras informationmghheader.is.ras.valid
Compute MGH primary slice directionmghheader.primary.slice.direction
Compute ras2vox matrix from basic MGH header fields.mghheader.ras2vox
Compute ras2vox-tkreg matrix from basic MGH header fields.mghheader.ras2vox.tkreg
Compute scanner-RAS 2 tkreg-RAS matrix from basic MGH header fields.mghheader.scanner2tkreg
Compute tkreg-RAS to scanner-RAS matrix from basic MGH header fields.mghheader.tkreg2scanner
Update mghheader fields from vox2ras matrix.mghheader.update.from.vox2ras
Compute vox2ras matrix from basic MGH header fields.mghheader.vox2ras
Compute vox2ras-tkreg matrix from basic MGH header fields.mghheader.vox2ras.tkreg
Compute vox2vox matrix between two volumes.mghheader.vox2vox
Get fsaverage (MNI305) to MNI152 transformation matrix.mni152reg
Create NIFTI v1 header suitable for given data.ni1header.for.data
Create a template NIFTI v1 header. You will have to adapt it for your use case.ni1header.template
Create NIFTI v2 header suitable for given data.ni2header.for.data
Create a template NIFTI v2 header. You will have to adapt it for your use case.ni2header.template
Compute data dimensions from the 'dim' field of the NIFTI (v1 or v2) header.nifti.datadim.from.dimfield
Compute NIFTI dim field for data dimension.nifti.datadim.to.dimfield
Determine whether a NIFTI file uses the FreeSurfer hack.nifti.file.uses.fshack
Determine NIFTI file version information and whether file is a NIFTI file.nifti.file.version
Perform basic sanity checks on NIFTI header data. These are in no way meant to be exhaustive.nifti.header.check
Print description of a brain atlas or annotation.print.fs.annot
Print description of a brain surface label.print.fs.label
Print description of a brain surface patch.print.fs.patch
Print description of a brain surface.print.fs.surface
Print description of a brain volume.print.fs.volume
Translate RAS coordinates, as used in volumes by applying vox2ras, to surface RAS.ras.to.surfaceras
Compute MNI talairach coordinates from RAS coords.ras.to.talairachras
Read a surface, based on the file path without extension.read_nisurface
S3 method to read a neuroimaging surface file.read_nisurfacefile
Read a FreeSurfer ASCII surface file.read_nisurfacefile.fsascii
Read a FreeSurfer ASCII surface file.read_nisurfacefile.fsnative
Read a gifti file as a surface.read_nisurfacefile.gifti
Read DTI tracking data from file in MRtrix 'TCK' format.read.dti.tck
Read fiber tracks from Diffusion Toolkit in trk format.read.dti.trk
Read DTI tracking per-coord data from file in MRtrix 'TSF' format.read.dti.tsf
Read file in FreeSurfer annotation formatread.fs.annot
Read an annotation or label in GIFTI format.read.fs.annot.gii
Read colortable file in FreeSurfer ASCII LUT format.read.fs.colortable
Read file in FreeSurfer curv formatread.fs.curv
Read FreeSurfer GCA file.read.fs.gca
Read a label file.read.fs.label
Read a label from a GIFTI label/annotation file.read.fs.label.gii
Read file in FreeSurfer label formatread.fs.label.native
Read file in FreeSurfer MGH or MGZ formatread.fs.mgh
Read morphometry data file in any FreeSurfer format.read.fs.morph
Read morphometry data from ASCII curv format fileread.fs.morph.asc
Read Brainvoyager vertex-wise statistical surface data from SMP file.read.fs.morph.bvsmp
Read surface morphometry data from CIFTI dscalar files.read.fs.morph.cifti
Read morphometry data file in GIFTI format.read.fs.morph.gii
Read morphometry data from FreeSurfer NIFTI v1 format files.read.fs.morph.ni1
Read morphometry data from FreeSurfer NIFTI v2 format files.read.fs.morph.ni2
Read morphometry data from FreeSurfer NIFTI format files, determine NIFTI version automatically.read.fs.morph.nii
Read morphometry data from plain text fileread.fs.morph.txt
Read FreeSurfer binary or ASCII patch file.read.fs.patch
Read FreeSurfer ASCII format patch.read.fs.patch.asc
Read file in FreeSurfer surface format or various mesh formats.read.fs.surface
Read FreeSurfer ASCII format surface.read.fs.surface.asc
Read Brainvoyager srf format (.srf) mesh as surface.read.fs.surface.bvsrf
Read mesh in BYU format.read.fs.surface.byu
Read GEO format mesh as surface.read.fs.surface.geo
Read GIFTI format mesh as surface.read.fs.surface.gii
Read ICO format mesh as surface.read.fs.surface.ico
Read surface mesh in mz3 format, used by Surf-Ice.read.fs.surface.mz3
Read OBJ format mesh as surface.read.fs.surface.obj
Read Object File Format (OFF) mesh as surface.read.fs.surface.off
Read Stanford PLY format mesh as surface.read.fs.surface.ply
Read mesh in STL format, auto-detecting ASCII versus binary format version.read.fs.surface.stl
Read surface mesh in STL binary format.read.fs.surface.stl.bin
Read VTK ASCII format mesh as surface.read.fs.surface.vtk
Load transformation matrix from a file.read.fs.transform
Load transformation matrix from a tkregister dat file.read.fs.transform.dat
Load transformation matrix from a FreeSurfer linear transform array (LTA) file.read.fs.transform.lta
Load transformation matrix from an XFM file.read.fs.transform.xfm
Read volume file in MGH, MGZ or NIFTI formatread.fs.volume
Turn a 3D or 4D `oro.nifti` instance into an `fs.volume` instance with complete header.read.fs.volume.nii
Read file in FreeSurfer weight or w formatread.fs.weight
Read Brainvoyager srf format (.srf) mesh.read.mesh.brainvoyager
Read raw NIFTI v1 data from file (which may contain the FreeSurfer hack).read.nifti1.data
Read NIFTI v1 header from file (which may contain the FreeSurfer hack).read.nifti1.header
Read raw data from NIFTI v2 file.read.nifti2.data
Read NIFTI v2 header from file.read.nifti2.header
Read Brainvoyager statistical surface results from SMP file.read.smp.brainvoyager
Find files with the given base name and extensions that exist.readable.files
Rotate a 2D matrix in 90 degree steps.rotate2D
Rotate a 3D array in 90 degree steps.rotate3D
Adapt spatial transformation matrix for 1-based indices.sm0to1
Adapt spatial transformation matrix for 0-based indices.sm1to0
Translate surface RAS coordinates, as used in surface vertices and surface labels, to volume RAS.surfaceras.to.ras
Compute Talairach RAS for surface RAS (e.g., vertex coordinates).surfaceras.to.talairach
Compute MNI talairach coordinates from RAS coords.talairachras.to.ras
Compute Euclidean distance between two vertices v1 and v2.vertex.euclid.dist
Compute Euclidean distance from all mesh vertices to given point.vertexdists.to.point
Write annotation to binary file.write.fs.annot
Write annotation to GIFTI file.write.fs.annot.gii
Write colortable file in FreeSurfer ASCII LUT format.write.fs.colortable
Write file in FreeSurfer curv formatwrite.fs.curv
Write vertex indices to file in FreeSurfer label formatwrite.fs.label
Write a binary surface label in GIFTI format.write.fs.label.gii
Write file in FreeSurfer MGH or MGZ formatwrite.fs.mgh
Write morphometry data in a format derived from the given file name.write.fs.morph
Write file in FreeSurfer ASCII curv formatwrite.fs.morph.asc
Write morphometry data in GIFTI format.write.fs.morph.gii
Write morphometry data in NIFTI v1 format.write.fs.morph.ni1
Write morphometry data in NIFTI v2 format.write.fs.morph.ni2
Write morphometry data in Brainvoyager SMP format.write.fs.morph.smp
Write curv data to file in simple text formatwrite.fs.morph.txt
Write a surface patchwrite.fs.patch
Write mesh to file in FreeSurfer binary surface formatwrite.fs.surface
Write mesh to file in FreeSurfer ASCII surface formatwrite.fs.surface.asc
Write surface to Brainvoyager SRF file.write.fs.surface.bvsrf
Write mesh to file in BYU ASCII format.write.fs.surface.byu
Write mesh to file in GIFTI surface formatwrite.fs.surface.gii
Write mesh to file in mz3 binary format.write.fs.surface.mz3
Write mesh to file in Wavefront object (.obj) formatwrite.fs.surface.obj
Write mesh to file in Object File Format (.off)write.fs.surface.off
Write mesh to file in PLY format (.ply)write.fs.surface.ply
Write mesh to file in PLY2 File Format (.ply2)write.fs.surface.ply2
Write mesh to file in VTK ASCII formatwrite.fs.surface.vtk
Write file in FreeSurfer weight formatwrite.fs.weight
Write file in FreeSurfer weight ASCII formatwrite.fs.weight.asc
Write header and data to a file in NIFTI v1 format.write.nifti1
Write header and data to a file in NIFTI v2 format.write.nifti2
Write a brainvoyager SMP file.write.smp.brainvoyager
Create XML GIFTI CoordinateSystemTransformMatrix node.xml_node_gifti_coordtransform