From 70aa92efadfa7448fe0aad46ead66a355f194d9a Mon Sep 17 00:00:00 2001 From: dipterix Date: Sun, 26 Jan 2025 16:41:39 -0500 Subject: [PATCH] Function `threeBrain` does not automatically download templates if annotation is not found --- DESCRIPTION | 2 +- R/class_brain.R | 4 ++++ R/template_cortical-annotation.R | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0875ba26..f3fd495b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: threeBrain Type: Package Title: Your Advanced 3D Brain Visualization -Version: 1.2.0.9014 +Version: 1.2.0.9015 Authors@R: c( person("Zhengjia", "Wang", email = "dipterix.wang@gmail.com", role = c("aut", "cre", "cph")), person("John", "Magnotti", email = "John.Magnotti@Pennmedicine.upenn.edu", role = c("ctb", "res")), diff --git a/R/class_brain.R b/R/class_brain.R index 10473859..4023348b 100644 --- a/R/class_brain.R +++ b/R/class_brain.R @@ -298,6 +298,10 @@ Brain2 <- R6::R6Class( surface_instance <- self$surfaces[[surface_type]] if(!length(lh_path) || !length(rh_path)) { + if(length(template_subject) != 1 || is.na(template_subject)) { + # no-op: do NOT generate parc, just return + return(invisible()) + } # annot file is missing; generate one on the fly tryCatch({ generate_cortical_parcellation(brain = self, diff --git a/R/template_cortical-annotation.R b/R/template_cortical-annotation.R index 0cfca788..38d6bab0 100644 --- a/R/template_cortical-annotation.R +++ b/R/template_cortical-annotation.R @@ -140,7 +140,7 @@ generate_cortical_parcellation <- function( # ieegio::write_surface(x = rh_annot, con = file.path(brain$base_path, "label", sprintf("rh.%s.annot", annotation)), format = "freesurfer", type = "annotations") if( add_annotation ) { - brain$add_annotation(sprintf("label/%s", annotation)) + brain$add_annotation(sprintf("label/%s", annotation), template_subject = NULL) } invisible(brain)