Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure faces are integers before writing surface geometries #32

Merged
merged 1 commit into from
Sep 15, 2024

Conversation

dipterix
Copy link
Contributor

The goal is to fix this issue when writing double as integer32:

mesh <- rgl::icosahedron3d(diag(c(50, 50, 50, 1)))
f <- tempfile()

faces <- t(mesh$it)
faces
#>       [,1] [,2] [,3]
#>  [1,]    1    3    9
#>  [2,]    1    9    5
#>  [3,]    1    5    7
#>  [4,]    1    7   10
#>  [5,]    1   10    3
#>  [6,]    4   12    2
#>  [7,]    4    2   11
#>  [8,]    4   11    6
#>  [9,]    4    6    8
#> [10,]    4    8   12
#> [11,]    9    3    6
#> [12,]    5    9   11
#> [13,]    7    5    2
#> [14,]   10    7   12
#> [15,]    3   10    8
#> [16,]    2   12    7
#> [17,]   11    2    5
#> [18,]    6   11    9
#> [19,]    8    6    3
#> [20,]   12    8   10
# storage.mode(faces) <- "integer"
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]       [,2]       [,3]
#>  [1,]          1 1073741825 1090519041
#>  [2,]          1 1090519041 1082130433
#>  [3,]          1 1082130433 1086324737
#>  [4,]          1 1086324737 1091567617
#>  [5,]          1 1091567617 1073741825
#>  [6,] 1077936129 1093664769 1065353217
#>  [7,] 1077936129 1065353217 1092616193
#>  [8,] 1077936129 1092616193 1084227585
#>  [9,] 1077936129 1084227585 1088421889
#> [10,] 1077936129 1088421889 1093664769
#> [11,] 1090519041 1073741825 1084227585
#> [12,] 1082130433 1090519041 1092616193
#> [13,] 1086324737 1082130433 1065353217
#> [14,] 1091567617 1086324737 1093664769
#> [15,] 1073741825 1091567617 1088421889
#> [16,] 1065353217 1093664769 1086324737
#> [17,] 1092616193 1065353217 1082130433
#> [18,] 1084227585 1092616193 1090519041
#> [19,] 1088421889 1084227585 1073741825
#> [20,] 1093664769 1088421889 1091567617

@dfsp-spirit
Copy link
Owner

Thanks for the fix, much appreciated.

@dfsp-spirit dfsp-spirit self-requested a review September 15, 2024 16:03
@dfsp-spirit dfsp-spirit self-assigned this Sep 15, 2024
@dfsp-spirit dfsp-spirit added the enhancement New feature or request label Sep 15, 2024
@dfsp-spirit dfsp-spirit merged commit 4588ac6 into dfsp-spirit:master Sep 15, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants