error during make_brainGraphList()

88 views
Skip to first unread message

Melanie Ehrler

unread,
Feb 21, 2023, 12:16:39 PM2/21/23
to brainGraph-help
Hi Chris 

first of all, thank you for the tremendous work you put into brainGraph and the user guide! 
I would really appreciate your help as I am stuck when running make_brainGraphList() and I cannot find a solution from your previous google group conversations.

Here some background info: 
- I aim to analyze DTI data which was processed with MRtrix. I have symmetric connectome matrices which are space separated (similar to the fdt_network_matrix files from probtrackx2). 
- I use a custom atlas (AAL3v1 atlas with some ROIs excluded). It is in a similar format as the atlases included in brainGraph
- I run my analyses on a Mac OS Version 13.2.1, R Version 4.2.2, BrainGraph Version 3.0.2
- I have set up multicore processing according to your readme.md

When I run the following code: 
matfiles <-
  list(A=list.files(datadir, pattern='fdt_network_matrix_sym2', full.names=T),
       way=list.files(datadir, pattern='waytotal', full.names=T),
       size=list.files(datadir, pattern='sizes2.txt', full.names=T))
inds <- lapply(grps, function(x) covars.dti[Group == x, which=TRUE])

modality <- 'dti'
thresholds <- c(0.0000001, 0.0000002, 0.0000003, 0.0000004)
sub.thresh <- 0.2
divisor <- 'size'
my.mats <- create_mats(matfiles$A, modality=modality, divisor=divisor,
                       div.files=matfiles$way, threshold.by='consensus',
                       sub.thresh=sub.thresh, inds=inds)
A.norm.sub <- my.mats$A.norm.sub
A.norm.mean <- my.mats$A.norm.mean

atlas_d <- read.table(file = "filepath/AAL3v1_adapted_coordinates.txt", header = T)
atlas_m <- data.table(atlas_d)
atlas_m$hemi <- as.factor(atlas_m$hemi)
atlas_m$lobe <- as.factor(atlas_m$lobe)
atlas_AAL3 <-  create_atlas(coords =cbind(atlas_m$x.mni, atlas_m$y.mni,atlas_m$z.mni), lobes = c(atlas_m$lobe),
                            hemis = c(atlas_m$hemi), regions = atlas_m$name )
setkey(atlas_AAL3, index)

g <- g.group <- vector('list', length(thresholds))
for (j in seq_along(thresholds)) {
  g[[j]] <- make_brainGraphList(A.norm.sub[[j]], atlas = 'atlas_AAL3', modality=modality,
                                weighting='sld', threshold=thresholds[j],
                                weighted=TRUE, gnames=covars.dti$Study.ID,
                                grpNames=covars.dti$Group)
  g.group[[j]] <- make_brainGraphList(A.norm.mean[[j]], atlas = 'atlas_AAL3', modality=modality,
                                      weighting='sld', threshold=thresholds[j],
                                      weighted=TRUE, gnames=grps)
}

I receive the following error:

[1] "Start time: 2023-02-21 18:09:49"
  |                                                                                                                      |   0%Error in { :
  task 1 failed - "Length of new attribute value must be 1 or 162, the number of target vertices, not 0"

> traceback()
5: stop(simpleError(msg, call = expr))
4: e$fun(obj, substitute(ex), parent.frame(), e$data)
3: 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, ...)
   }
2: make_brainGraphList.array(A.norm.sub[[j]], atlas = "atlas_AAL3",
       modality = modality, weighting = "sld", threshold = thresholds[j],
       weighted = TRUE, gnames = covars.dti$Study.ID, grpNames = covars.dti$Group)
1: make_brainGraphList(A.norm.sub[[j]], atlas = "atlas_AAL3", modality = modality,
       weighting = "sld", threshold = thresholds[j], weighted = TRUE,
       gnames = covars.dti$Study.ID, grpNames = covars.dti$Group)



When I try to run make_brainGraph on a single subject, I receive the following error: 

> make_brainGraph(A.norm.sub[[1]][,,1], atlas = 'atlas_AAL3', modality=modality,
+                 weighting='sld', threshold=thresholds[1],
+                 weighted=TRUE, gnames=covars.dti$Study.ID,
+                 grpNames=covars.dti$Group )
Error in i_set_vertex_attr(x, attr(value, "name"), index = value, value = attr(value,  :
  Length of new attribute value must be 1 or 162, the number of target vertices, not 0
In addition: Warning message:
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
> traceback()
7: stop("Length of new attribute value must be ", if (length(index) !=
       1) "1 or ", length(index), ", the number of target vertices, not ",
       length(value))
6: i_set_vertex_attr(x, attr(value, "name"), index = value, value = attr(value,
       "value"), check = FALSE)
5: `V<-`(`*tmp*`, value = `*vtmp*`)
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 = "atlas_AAL3",
       modality = modality, weighting = "sld", threshold = thresholds[1],
       weighted = TRUE, gnames = covars.dti$Study.ID, grpNames = covars.dti$Group)
1: make_brainGraph(A.norm.sub[[1]][, , 1], atlas = "atlas_AAL3",
       modality = modality, weighting = "sld", threshold = thresholds[1],
       weighted = TRUE, gnames = covars.dti$Study.ID, grpNames = covars.dti$Group)


I attach my R script and the data I used 



Do you have any idea what went wrong and how I can fix this? Or do you need any additional information from my side? 

Thanks!! 
Melanie 



R-Skript_BrainGraph_subset.R
Message has been deleted
Message has been deleted

Melanie Ehrler

unread,
Feb 22, 2023, 4:02:00 AM2/22/23
to brainGraph-help
here is a subset of the data 
connectome_subset.zip
Reply all
Reply to author
Forward
0 new messages