Density=1, unthresholded networks

15 views
Skip to first unread message

Daniel J. King

unread,
Jun 17, 2019, 4:48:27 PM6/17/19
to brainGraph-help
Hi,

I’ve been using Braingraph for a while and have come to realise I can’t get an unthresholded structural covariance network? I have tried using density as 1 but that seems to fail. Is there a way of achieving this, or editing the function that generates the networks to allow it?

Many thanks
Dan

Chris Watson

unread,
Jun 17, 2019, 5:13:40 PM6/17/19
to brainGr...@googlegroups.com
Hi Daniel,

Thanks for discovering this... I hadn't realized that either!
The fix should be pretty simple; you can edit corr.matrix, in particular the line defining the variable thresholds. Something like this should work:

if (densities == 1) {
  thresholds <- 0
} else {
  # Old code goes here
}

If your input densities is a vector, I think you can keep the old line, and then afterwards:
if (any(densities == 1)) {
  thresholds[which(densities == 1)] <- 0
}


Let me know if you have any issues.
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 post to this group, send email to brainGr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/06c29e2a-f9de-4460-a24b-c168d9ccb1be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel J. King

unread,
Jun 21, 2019, 7:08:09 AM6/21/19
to brainGraph-help
Hi Chris, 
I do seem to be having some issues with this.
I made some slight edits to the corr.matrix function, on the basis that it was still cutting out negative edges as it taking any r > 0. This I have managed to fix and I thus have an undirected, weighted graph (308*308) with both positive and negative edge weights.
However, when I try ad apply the graph attributed to the object, this seems to fail at the stage of shortest paths. The input and resultant error is :

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

Error in { : 
  task 1 failed - "At structural_properties.c:5313 : cannot run Bellman-Ford algorithm, Negative loop detected while calculating shortest paths"
In addition: Warning message:
In .fun(piece, ...) :


I am also able to replicate this error with the original corr.matrix function if I proceed to give it a similarly high density (i.e. .95 and .9). 

Is there a way to get past this issue. The only graph attributes I am interested in at the moment are the global and nodal strength.

Thanks again
Dan

On Monday, June 17, 2019 at 10:13:40 PM UTC+1, Chris Watson wrote:
Hi Daniel,

Thanks for discovering this... I hadn't realized that either!
The fix should be pretty simple; you can edit corr.matrix, in particular the line defining the variable thresholds. Something like this should work:

if (densities == 1) {
  thresholds <- 0
} else {
  # Old code goes here
}

If your input densities is a vector, I think you can keep the old line, and then afterwards:
if (any(densities == 1)) {
  thresholds[which(densities == 1)] <- 0
}


Let me know if you have any issues.
Chris

On Mon, Jun 17, 2019 at 3:48 PM Daniel J. King <daniel...@gmail.com> wrote:
Hi,

I’ve been using Braingraph for a while and have come to realise I can’t get an unthresholded structural covariance network? I have tried using density as 1 but that seems to fail. Is there a way of achieving this, or editing the function that generates the networks to allow it?

Many thanks
Dan

--
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 brainGr...@googlegroups.com.

Chris Watson

unread,
Jun 21, 2019, 12:57:40 PM6/21/19
to brainGr...@googlegroups.com
Yes, that error occurs in the "distances" function because there are
negative edge weights. I am not aware of an algorithm that can get
around this.

If you are only interested in "strength", then you don't have to run
"set_brainGraph_attrs"; this is just a convenience function that
calculates multiple graph metrics in one go. So you can just assign
the appropriate graph- and vertex-level attributes with the "strength"
function.

A future version of "set_brainGraph_attrs" will allow for these edge
cases so that the whole thing doesn't fail.

Chris
>>> email to brainGr...@googlegroups.com <javascript:>.
>>> To post to this group, send email to brainGr...@googlegroups.com
>>> <javascript:>.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/brainGraph-help/06c29e2a-f9de-4460-a24b-c168d9ccb1be%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>
> --
> 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 post to this group, send email to brainGr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/brainGraph-help/8dfaa487-ff79-43b9-bf19-8752beda07c5%40googlegroups.com.

Daniel J. King

unread,
Jun 26, 2019, 9:46:12 AM6/26/19
to brainGraph-help
Thanks Chris, that is really helpful. On an unrelated note, ever since updating to the most recent version (2.7.0) I have been unable to get the brain_Graph permute function to work correctly.

When running:
 perms.all <- brainGraph_permute(densities, all.dat.resids, p, level='graph', atlas=atlas)

I get the error of:
Error in { : task 1 failed - "is_igraph(g) is not TRUE"

From looking under the hood, I don't think the current brainGraph permute is accessing the graph objects that are inside the g list, i.e. the graphs for each group. I have tested this with the standard graph construction techniques from the manual, but I still cannot get it to work for the life of me! Is this a current issue or just me?

BW
Dan

Chris Watson

unread,
Jun 26, 2019, 9:23:06 PM6/26/19
to brainGr...@googlegroups.com
Hi Dan, I don't recall any other reports of that error. I also have
not seen in my own data. "brainGraph_permute" was last updated in
v2.3.1, which was a bugfix update. Prior to that, the function was
changed in v2.1.0.

So unless you had previously used v2.3.0 or earlier, I am not sure why
you would be seeing that error. If you send me the relevant data, I
could check it out.

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 post to this group, send email to brainGr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/brainGraph-help/72e8bacd-3bf1-48f8-8fa4-eca0124abe56%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages