Writing to GIfTI with face index stored as float results in errors
Closed this issue · 2 comments
dipterix commented
Hi @dfsp-spirit , I recently encountered an issue when saving geometry when faces
storage is not integer. Here's an reproducible example:
mesh <- rgl::icosahedron3d(diag(c(50, 50, 50, 1)))
f <- tempfile()
faces <- t(mesh$it)
faces[1:4, ]
#> [,1] [,2] [,3]
#> [1,] 1 3 9
#> [2,] 1 9 5
#> [3,] 1 5 7
#> [4,] 1 7 10
# storage.mode(faces) <- "double"
freesurferformats::write.fs.surface.gii(
filepath = f,
vertex_coords = t(mesh$vb[1:3, ]),
faces = faces
)
m <- freesurferformats::read.fs.surface.gii(f)
m$faces[1:4, ]
#> [,1] [,2] [,3]
#> [1,] 1 1073741825 1090519041
#> [2,] 1 1090519041 1082130433
#> [3,] 1 1082130433 1086324737
#> [4,] 1 1086324737 1091567617
The issue was caused due to writing faces as float and then read back as integer32. A PR has been opened last night for this. #32.
Please let me know if anything is needed.
dfsp-spirit commented
Thanks, I'll have a look and let you know.
dfsp-spirit commented
I merged the PR, this will be part of the next release.