Read a FreeSurfer color lookup table file (e.g., FreeSurferColorLUT.txt
or ASegStatsLUT.txt). These files map label indices to region names
and RGBA colours.
Value
A data.frame with columns: idx, label, R, G, B, A, and optionally type, hemi and context when the file carries them.
Details
A file written by write_lut() can carry declared columns after the
colours. With a single extra field it is read as type. With more, a
comment line naming the fields – # idx label R G B A type hemi – says
which is which, and a field holding NA is read as missing. A context
field is read as TRUE or FALSE.
See also
get_lut() to read and add hex colours, write_lut() to write,
lut_add() and lut_combine() to build one up
Examples
lut_file <- tempfile()
writeLines(c(
" 0 Unknown 0 0 0 0",
" 1 Left-Cerebral-Cortex 205 130 176 0"
), lut_file)
read_lut(lut_file)
#> idx label R G B A
#> 1 0 Unknown 0 0 0 0
#> 2 1 Left-Cerebral-Cortex 205 130 176 0