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

Error in smooth_surf(Temp, 10) : #5

Open
jlhanson5 opened this issue Nov 30, 2024 · 2 comments
Open

Error in smooth_surf(Temp, 10) : #5

jlhanson5 opened this issue Nov 30, 2024 · 2 comments

Comments

@jlhanson5
Copy link

Hello all,

I got VertexWiseR kickstarted, but have been having trouble importing Freesurfer data using SURFvextract.

Here are the commands I ran:

library(VertexWiseR)
Sys.setenv(FREESURFER_HOME='/Applications/freesurfer/7.4.1/')
system("source /Applications/freesurfer/7.4.1/SetUpFreeSurfer.sh; env", ignore.stdout = TRUE, ignore.stderr = TRUE);
Sys.setenv(PATH = paste(Sys.getenv("PATH"), file.path(Sys.getenv("FREESURFER_HOME"), "bin"), sep = ":"))
Sys.setenv(SUBJECTS_DIR='/Volumes/Project/Hanson/Internal_MRI_Projects/Duke_PAC/Neuroimaging/BIDS/derivatives/Freesurfer_7/')
setwd('/Volumes/Project/Hanson/Internal_MRI_Projects/Duke_PAC/Neuroimaging/BIDS/derivatives/Freesurfer_7/')
Temp<-SURFvextract(sdirpath = "./", 
             filename="./thickness.rds", template="fsaverage6",
             measure="thickness") 
thickness_smoothed = smooth_surf(Temp, 10)

Regardless of what I do with SURFvextract, I can't seem to move that step forward. I stored it as Temp, but also load the thickness.rds file and for both approaches, I get the following errors:

> thickness_smoothed = smooth_surf(Temp, 10)
Checking for VertexWiseR system requirements ... 
Checking for Miniconda or Python environment...
Checking Numpy's version...
Checking for BrainStat package...
Checking BrainStat's analysis data...
No system requirements are missing. ✓ 

Error in smooth_surf(Temp, 10) : 
  surf_data vector should only contain 20484 (fsaverage5), 81924 (fsaverage6) or 14524 (hippocampal vertices) columns

Here's my R sessionInfo

> sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: x86_64-apple-darwin20
Running under: macOS Ventura 13.7.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] VertexWiseR_1.1.0

loaded via a namespace (and not attached):
 [1] gtable_0.3.6             ggplot2_3.5.1            htmlwidgets_1.6.4        lattice_0.22-6           vctrs_0.6.5              tools_4.4.2              keras_2.15.0             tfruns_1.5.3             doSNOW_1.0.20            bitops_1.0-9             generics_0.1.3           parallel_4.4.2          
[13] tibble_3.2.1             fansi_1.0.6              pkgconfig_2.0.3          R.oo_1.27.0              Matrix_1.7-1             data.table_1.16.2        oro.nifti_0.11.4         RColorBrewer_1.1-3       lifecycle_1.0.4          compiler_4.4.2           stringr_1.5.1            munsell_0.5.1           
[25] RNifti_1.7.0             codetools_0.2-20         snow_0.4-4               htmltools_0.5.8.1        lazyeval_0.2.2           plotly_4.10.4            pillar_1.9.0             whisker_0.4.1            tidyr_1.3.1              R.utils_2.12.3           iterators_1.0.14         abind_1.4-8             
[37] foreach_1.5.2            tidyselect_1.2.1         digest_0.6.37            stringi_1.8.4            dplyr_1.1.4              purrr_1.0.2              splines_4.4.2            fastmap_1.2.0            grid_4.4.2               colorspace_2.1-1         cli_3.6.3                magrittr_2.0.3          
[49] base64enc_0.1-3          utf8_1.2.4               withr_3.0.2              scales_1.3.0             rappdirs_0.3.3           httr_1.4.7               igraph_2.1.1             reticulate_1.39.0        png_0.1-8                R.methodsS3_1.8.2        pkgfilecache_0.1.5       doParallel_1.0.17       
[61] gifti_0.8.0              viridisLite_0.4.2        rlang_1.1.4              Rcpp_1.0.13-1            zeallot_0.1.0            glue_1.8.0               xml2_1.3.6               ciftiTools_0.16.1        freesurferformats_0.1.18 jsonlite_1.8.9           R6_2.5.1                 fs_1.6.5                
[73] tensorflow_2.16.0       
> 

And I'm doing this in R, but got some similar errors in R Studio.
Thoughts about troubleshooting this?

Any thoughts are much appreciated!
Jamie.

@CogBrainHealthLab
Copy link
Owner

CogBrainHealthLab commented Nov 30, 2024

Hi Jamie, assuming that SURFvextract has completed successfully, Temp would be a list object where Temp[[1]] is the subject list and Temp[[2]] is the thickness data.

You should be able to proceed with smoothing and subsequent analyses with the thickness data within Temp[[2]]. For instance:

thickness_smoothed = smooth_surf(Temp[[2]], 10)

If you don't want the subject list to be combined with the thickness data in a list object, you can optionally set include subj_ID = FALSE, within SURFvextract(), such that the output will be a matrix object containing only the thickness data

@chabld
Copy link
Collaborator

chabld commented Dec 9, 2024

I've pushed a modification of the commands so they should automatically read the surface matrix within the extraction functions' output (if subj_ID was set as TRUE, and the subject ID list was appended instead of the surface matrix on its own). That will avoid forcing the user to specify the matrix. It is in the git version right now and will be in the next CRAN update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants