Custom atlas trouble in make_brainGraphList, v3.0.2, windows, R version 4.2.1

120 views
Skip to first unread message

danandre...@gmail.com

unread,
Nov 30, 2022, 5:16:11 PM11/30/22
to brainGraph-help

Hi Chris,

I am using brainGraph v.3.0.2 with R version 4.2.1 (2022-06-23 ucrt) to conduct MTPC using resting state fmri connectivity matrices prepared in Conn toolbox, transformed to Pearson correlations and restricted to positive values.  I have been able to complete this analysis using the brainnetome atlas parcellation, however I originally intended and would still like to use the Schaefer_400p_17network parcellation.  

When trying to create either subject level or group level graphs I get the following error:

 

> gthresholds <-  rev(seq(0.25, 0.5, 0.01))
> g <- vector('list',length(gthresholds))
> for (j in seq_along(gthresholds)) {
   g[[j]] <- make_brainGraphList(A.norm.sub[[j]], atlas='Schaefer_Atlas', set.attrs =TRUE, modality='fmri', weighting='pearson', threshold=gthresholds[j], weighted=TRUE, gnames=covars.fmri1$Study.ID, grpNames=covars.fmri1$Group)}

[1] "Start time: 2022-11-30 16:02:02"
  |                                                                                                                                  |   0%Error in { : task 1 failed - "object 'Schaefer_Atlas' not found"

 

As far as I can tell my atlas is in the correct format and loaded to my workspace

 

> str(Schaefer_Atlas)

Classes ‘data.table’ and 'data.frame':              400 obs. of  8 variables:

 $ name   : chr  "VisCentExStr1" "VisCentExStr2" "VisCentExStr3" "VisCentExStr4" ...

 $ x.mni  : num  -36 -24 -36 -16 -24 -42 -8 -46 -24 -40 ...

 $ y.mni  : num  -62 -72 -82 -86 -96 -86 -98 -74 -96 -84 ...

 $ z.mni  : num  -16 -10 -16 -16 -12 -4 -8 6 6 14 ...

 $ lobe   : Factor w/ 4 levels "Frontal","Occiptal",..: 2 2 2 2 2 2 2 2 2 2 ...

 $ hemi   : Factor w/ 2 levels "L","R": 1 1 1 1 1 1 1 1 1 1 ...

 $ index  : num  1 2 3 4 5 6 7 8 9 10 ...

 $ network: chr  "VisCent" "VisCent" "VisCent" "VisCent" ...

 - attr(*, "spec")=

  .. cols(

  ..   name = col_character(),

  ..   x.mni = col_double(),

  ..   y.mni = col_double(),

  ..   z.mni = col_double(),

  ..   lobe = col_character(),

  ..   hemi = col_character(),

  ..   index = col_double(),

  ..   network = col_character()

  .. )

 - attr(*, "problems")=<externalptr>

 - attr(*, ".internal.selfref")=<externalptr>

 - attr(*, "index")= int(0)

  ..- attr(*, "__name")= int [1:400] 133 335 122 325 123 326 124 327 125 328 ...

 

 

> ls()

 [1] "A.norm.mean"                              "A.norm.sub"                               "anti_datadir"                           

 [4] "atlas"                                    "cl"                                       "covars.all"                             

 [7] "covars.fmri"                              "covars.fmri1"                             "datadir"                                

[10] "divisor"                                  "g"                                        "g.group"                                

[13] "g.ss"                                     "ggthresholds"                             "grps"                                   

[16] "gthresholds"                              "inds"                                     "j"                                      

[19] "matfiles"                                 "modality"                                 "my.mats"                                

[22] "neg_matfiles"                             "num.cores"                                "pos_datadir"                            

[25] "pos_matfiles"                             "savedir"                                  "Schaefer"                               

[28] "Schaefer.Atlas"                           "Schaefer_Atlas"                           "Schaefer2"                               

[31] "Schaefer2018_400Parcels_17Networks_order" "sub.thresh"                               "threshold.by"                           

[34] "thresholds"                               "today"  

 

Attempting to create a graph for a single subject I get the following error and traceback:

> g.ss <- vector('list',length(1))
> g.ss <- make_brainGraph(A.norm.sub[[1]][,,1], atlas = 'Schaefer_Atlas',  set.attrs =TRUE, modality='fmri', weighting='pearson', threshold=gthresholds[1], weighted=TRUE, gnames=covars.fmri1$Study.ID[1], grpNames=covars.fmri1$Group[1])


Error in rep_len("gray", max(memb)) : invalid 'length.out' value

In addition: Warning messages:
1: In as_adj(g, names = FALSE, sparse = FALSE, edges = TRUE) :
  The `edges` argument of `as_adjacency_matrix` is deprecated; it will be removed in igraph 1.4.0
2: In eval(jsub, SDenv, parent.frame()) : NAs introduced by coercion
3: In eval(jsub, SDenv, parent.frame()) : NAs introduced by coercion

> traceback()
5: set_graph_colors(x, paste0("color.", col), DT[vorder, as.numeric(get(col))])
4: make_brainGraph.igraph(g, atlas, type, level, set.attrs, modality,
       weighting, threshold, name, Group, subnet, A = x, ...)
3: make_brainGraph(g, atlas, type, level, set.attrs, modality, weighting,
       threshold, name, Group, subnet, A = x, ...)
2: make_brainGraph.matrix(A.norm.sub[[1]][, , 1], atlas = "Schaefer_Atlas",
       set.attrs = TRUE, modality = "fmri", weighting = "pearson",
       threshold = gthresholds[1], weighted = TRUE, gnames = covars.fmri1$Study.ID[1],
       grpNames = covars.fmri1$Group[1])
1: make_brainGraph(A.norm.sub[[1]][, , 1], atlas = "Schaefer_Atlas",
       set.attrs = TRUE, modality = "fmri", weighting = "pearson",
       threshold = gthresholds[1], weighted = TRUE, gnames = covars.fmri1$Study.ID[1],
       grpNames = covars.fmri1$Group[1])

 

I have attached the full session info and the saved atlas object, can provide more if this is not a simple mistake that I'm overlooking.  Could you offer any advice as to what I might be missing?  Thank you for your time.

Dan

session_info.txt
Schaefer_Atlas.rda

Chris Watson

unread,
Dec 2, 2022, 11:05:55 AM12/2/22
to brainGr...@googlegroups.com
This is a common error but please send me *all* data needed to debug this. It would help to also get a ".R" file so I can just re-run the code. You can send to me off-list if you prefer.

--
You received this message because you are subscribed to the Google Groups "brainGraph-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-he...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/4eaa8ef6-a1f0-481a-a554-f345f3ca43e3n%40googlegroups.com.

danandre...@gmail.com

unread,
Dec 8, 2022, 3:07:17 PM12/8/22
to brainGraph-help
  Hi Chris,

Thanks for your reply and for taking the time to help me with this.  I have included the requested data and R file below.  Please let me know if there is anything else that would be helpful or anything I can try on my end.  Apologies for the delay, I thought I sent this reply previously.
Dan

Schaefer Density Thresholding.R
S1_CompCog_subset.zip

Chris Watson

unread,
Mar 25, 2023, 4:20:59 PM3/25/23
to brainGr...@googlegroups.com
Sorry for such a long delay, but I didn't get the same error "Schaefer_atlas not found".
Either way, I had to add the following 2 lines of code to get it to run:

Schaefer_Atlas[, network := factor(network)]
Schaefer_Atlas[, name := paste(name, hemi, sep='.')]

Chris

--
You received this message because you are subscribed to the Google Groups "brainGraph-help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-he...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages