cwatson / brainGraph

Graph theory analysis of brain MRI data
166 stars 48 forks source link

Called from: e$fun(obj, substitute(ex), parent.frame(), e$data) #21

Closed EunyoungL closed 3 years ago

EunyoungL commented 3 years ago

Dear Chris!! when I ran the code below, I got this error. I think the part of "graph_from_adjacency_matrix" was ok. I got the list of iGraph class object. but "set_brainGraph_attr" was the problem where I got an error. is there any thoughts or comments? what am I getting this error?? Please help me out!!!

atlas <- "aal116" modality <- "fmri" allg <- apply(allmats, 1, function(sub) { g <- graph_from_adjacency_matrix(sub, mode="undirected", weighted=TRUE, diag=FALSE) g <- set_brainGraph_attr(g, atlas = atlas, modality = modality) return(g) })

Error in { : task 1 failed - "argument is of length zero" In addition: Warning message: executing %dopar% sequentially: no parallel backend registered Called from: e$fun(obj, substitute(ex), parent.frame(), e$data) Browse[1]>

cwatson commented 3 years ago

You should not use the apply function; you probably want to use sapply instead. Unless allmats is a 3-D array; in that case, you should change the 1 to 3. Either way, you don't need the line return(g), nor do you need the second g <-. (In the next version, graph creation and attribute calculation will be done with one function in the package; I am close to finishing that version.)

Second, you should register a parallel backend, so please read this section and execute the code before your scripts: https://github.com/cwatson/brainGraph#multi-core-processing

Third, you can try running set_brainGraph_attr with the argument use.parallel=FALSE.

If you still see an error, please report the output of traceback(). Also let me know if there are negative edge weights, as these can cause problems (which will also be identified in the next version).

cwatson commented 3 years ago

Closing due to inactivity.