read.markups.fcsv | R Documentation |
This function imports an FCSV as written by 3D Slicer file into R.
read.markups.fcsv(file = NULL, forceLPS = FALSE)
file |
The file path that leads to a particular FCSV file. |
forceLPS |
The forceLPS determines if the coordinate system should be converted into LPS. The default is FALSE. If set to be TRUE, the function will read the "coordinateSystem" value at the second line of fcsv. If not "LPS", it will reverse the signs of x and y coordinates to force the coordinate system into LPS. |
In the older version of 3D Slicer,
markup coordinates were written in RAS (Right-Anterior-Superior) coordinate system assumption.
More recently, it has been saved as LPS (Left-Posterior-Superior).
If forceLPS set to FALSE (default), the contents of the file will be read as as, ignoring the header information, where the coordinate system is stored.
If forceLPS is set to TRUE, the function will check for the coordinate system definition in the FCSV header, and will negate the x,y coordinate values if the coordinate system is defined as RAS. File will be read as is, if the coordinate system definition is LPS.
An array/matrix that contains the landmark coordinates.
Row numbers = number of landmarks;
Column numbers = dimensions of the landmark coordinates
Row names are assigned from the labels in the FCSV file
Column names are assigned as "x", "y", and "z", depending on the dimension
#forceLPS = FALSE file = "https://raw.githubusercontent.com/SlicerMorph/SampleData/master/Gorilla_template_LM1.fcsv" lms = read.markups.fcsv(file = file, forceLPS = FALSE) #default setting for forceLPS #Return a 41x3 matrix that stores raw landmark coordinates from the fcsv files; rownames = labels in the FCSV file; colnames = "x", "y", "z" lms[1:3, ] X Y Z Gorilla_template_LM1-1 111.987 312.757 -148.0780 Gorilla_template_LM1-2 114.785 381.650 -128.2390 Gorilla_template_LM1-3 109.137 294.534 -97.4347 #forceLPS = TRUE file = "https://raw.githubusercontent.com/SlicerMorph/SampleData/master/Gorilla_template_LM1.fcsv" lms = read.markups.fcsv(file = file, forceLPS = TRUE) #Because forceLPS = TRUE, the function will read the "coordinateSystem" in the 2nd line of the fcsv to see if it is "LPS" x <- readLines(file, n = 2) x[[2]] [1] "# CoordinateSystem = 0" #The coordinateSystem is not "LPS", so the signs of x, y coordinates are reversed to be consistent with the LPS coordinate system. lms[1:3, ] [,1] [,2] [,3] Gorilla_template_LM1-1 -111.987 -312.757 -148.0780 Gorilla_template_LM1-2 -114.785 -381.650 -128.2390 Gorilla_template_LM1-3 -109.137 -294.534 -97.4347
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.