SCN pipeline – using custom atlas for DTI

45 views
Skip to first unread message

jonata...@gmail.com

unread,
Nov 27, 2021, 4:07:33 PM11/27/21
to brainGraph-help
Hi Chris and everybody,

I'm trying to force skeletonised FA features (in accordance with the ICBM-81 White Matter atlas) to work in the structural covariance pipeline. 

After solving some issues, I've reached a point in where I cannot go any further – concretely, I cannot set the braingraph attributes to the adjacency matrices. Below the commands (and in yellow the error message):

> densities <- seq(0.05, 0.3, 0.01)

> corrs <- corr.matrix(all.dat.resids, densities = densities, what = 'resids')

> t(sapply(corrs, with, thresholds))                          
       [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]      [,8]      [,9]     [,10]     [,11]
F 0.6553267 0.6446375 0.6337028 0.6209303 0.6058078 0.5990436 0.5939710 0.5843899 0.5755557 0.5671513 0.5655249
M 0.6547830 0.6352256 0.6258014 0.6169424 0.5956751 0.5927107 0.5878497 0.5785243 0.5728271 0.5697809 0.5668147

      [,12]     [,13]     [,14]     [,15]     [,16]     [,17]     [,18]     [,19]     [,20]     [,21]     [,22]
F 0.5577356 0.5508120 0.5475624 0.5407722 0.5314159 0.5302483 0.5225112 0.5187977 0.5181231 0.5136624 0.5100575
M 0.5588886 0.5551932 0.5476612 0.5432956 0.5355450 0.5320407 0.5264260 0.5176659 0.5136578 0.5083376 0.5054364
      [,23]     [,24]     [,25]     [,26]
F 0.5072010 0.5014536 0.4969798 0.4942124
M 0.5016274 0.4998780 0.4964702 0.4930049

> g <- lapply(corrs, function(x)
+   apply(x$r.thresh, 3,
+         graph_from_adjacency_matrix, 
+         mode = 'undirected', 
+         diag = F))

> g <- Map(function(x, y) 
+   plyr::llply(x, 
+               set_brainGraph_attr, 
+               atlas = atlas,                 
+               modality = 'thickness',
+               group = y, 
+               .progress = 'text'), 
+   g, as.list(groups))

Error in mapply(FUN = f, ..., SIMPLIFY = FALSE) : 
  zero-length inputs cannot be mixed with those of non-zero length

> traceback()
2: mapply(FUN = f, ..., SIMPLIFY = FALSE)
1: Map(function(x, y) plyr::llply(x, set_brainGraph_attr, atlas = atlas, 
       modality = "thickness", group = y, .progress = "text"), g, 
       as.list(groups))

Any thoughts on why this might be happening? Thanks in advance!

Best,
Jonatan

Chris Watson

unread,
Nov 29, 2021, 8:07:27 AM11/29/21
to brainGr...@googlegroups.com
Can you try with the latest version of brainGraph?

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/005e0c30-2bb1-4cbc-baa0-a5b0a62d653bn%40googlegroups.com.

jonata...@gmail.com

unread,
Nov 29, 2021, 7:58:39 PM11/29/21
to brainGraph-help
Hi Chris,

thanks for following. This is the new error w/brainGraph latest version:

> g <- lapply(seq_along(densities), function(x) 
               make_brainGraphList(corrs[x], modality = 'thickness'))

[1] "Start time: 2021-11-29 19:56:25"
  |                                                                                                           |   0%
 Error in { : task 1 failed - "object 'NA' not found" 

> traceback()

9: stop(simpleError(msg, call = expr))
8: e$fun(obj, substitute(ex), parent.frame(), e$data)
7: foreach(i = seq_len(kNumGraphs)) %dopar% {
       res <- loopfun(x[, , i], atlas, type, level, set.attrs, modality, 
           weighting, threshold[i], name = gnames[i], Group = grpNames[i], 
           subnet = subnet, mode = mode, diag = diag, weighted = weighted, 
           use.parallel = FALSE, ...)
   }
6: make_brainGraphList.array(A, atlas = atlas, type = type, level = level, 
       set.attrs = set.attrs, modality = modality, weighting = weighting, 
       threshold = threshold, mode = mode, weighted = weighted, 
       diag = diag, gnames = gnames, grpNames = grpNames, .progress = .progress, 
       ...)
5: make_brainGraphList(A, atlas = atlas, type = type, level = level, 
       set.attrs = set.attrs, modality = modality, weighting = weighting, 
       threshold = threshold, mode = mode, weighted = weighted, 
       diag = diag, gnames = gnames, grpNames = grpNames, .progress = .progress, 
       ...)
4: make_brainGraphList.corr_mats(corrs[x], modality = "thickness")
3: make_brainGraphList(corrs[x], modality = "thickness") at #1
2: FUN(X[[i]], ...)
1: lapply(seq_along(densities), function(x) make_brainGraphList(corrs[x], 
       modality = "thickness"))

Chris Watson

unread,
Nov 29, 2021, 11:26:08 PM11/29/21
to brainGr...@googlegroups.com
Could you first try with "set.attrs=F", to try to narrow down the error?
If there is nothing helpful there, I'll have to see the data and try to reproduce the error.

Chris

Chris Watson

unread,
Dec 1, 2021, 9:48:22 AM12/1/21
to brainGr...@googlegroups.com
Thanks for sending the data.
There is a bug in "corr.matrix" when using a custom atlas. So you will have to add the following line *before* creating graphs:

corrs$atlas <- 'myAtlas'

where "myAtlas" would be replaced with the name of the atlas you are using. Then it should run without error.
Chris

Chris Watson

unread,
Dec 1, 2021, 10:43:27 AM12/1/21
to brainGr...@googlegroups.com
Actually you could also pass the "atlas" argument when calling "get.resid", and that should work as well.
Chris
Reply all
Reply to author
Forward
0 new messages