I don't have experience with fMRI networks, but reference [3] discusses it.
I use consensus thresholding in my own work (probabilistic tractography). I have found that using density and consistency essentially remove any group differences (but I have not investigated this systematically, only at-a-glance). The mat.thresh values that I use are admittedly arbitrary, and I have chosen them to result in the networks having a similar increase in density from threshold_i to threshold_j. I should look into this for a more principled method, though.
I hope this answers your questions! Let me know if you have others.
Chris
References:
[1] https://doi.org/10.1016/j.neuroimage.2012.12.066
[2] https://doi.org/10.1523/JNEUROSCI.3539-11.2011
[3] https://doi.org/10.1016/j.neuroimage.2017.02.005
[4] https://doi.org/10.1523/JNEUROSCI.4793-12.2013
--
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-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/7c8cf7db-2288-45b5-b99e-08c0f5eb392e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
thresholds <- c(0.1, 0.3, 0.5)
atlas <- atlas.name #needs to be in path for `eval(parse(text=atlas))`
sub.thresh <- 0
modality <- 'fmri'
# creating graph matrices from files
my.mats <- create_mats(f.A,
modality = modality,
mat.thresh = thresholds,
sub.thresh = sub.thresh,
inds = inds)
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 unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/c3b49b13-dde0-48a4-8f00-04f570ffb160%40googlegroups.com.
# reading conmat 2 files
f.A <- list.files("~/Projects/thresh_test", '*.txt', full.names = T)
f.A
# initiating thresholds
thresholds <- c(0.1, 0.3, 0.5)
sub.thresh <- 0
modality <- 'fmri'
inds <- list(1:2)
# creating graph matrices from files
test.mats <- create_mats(f.A,
modality = modality,
mat.thresh = thresholds,
sub.thresh = sub.thresh,
inds = inds)
# comparing 2 original duplicated conmats from A
setdiff(test.mats$A[,,1], test.mats$A[,,2])
# comparing 2 original duplicated conmats from A.norm
setdiff(test.mats$A.norm[,,1], test.mats$A.norm[,,2])
# comparing original A to A.norm
setdiff(test.mats$A[,,1], test.mats$A.norm[,,1])
# comparing original A to A.norm.sub (/w threshold=0.1)
setdiff(test.mats$A[,,1], test.mats$A.norm.sub[[1]][,,1])
# finding element values smaller than threshold=0.1 in original conmat
which(test.mats$A[,,1] < 0.1)
# finding element values smaller than threshold=0.1 in original conmat
which(test.mats$A.norm.sub[[1]][,,1] < 0.1)
> # comparing 2 original duplicated conmats from A
> setdiff(test.mats$A[,,1], test.mats$A[,,2])
numeric(0)
>
> # comparing 2 original duplicated conmats from A.norm
> setdiff(test.mats$A.norm[,,1], test.mats$A.norm[,,2])
numeric(0)
>
> # comparing original A to A.norm
> setdiff(test.mats$A[,,1], test.mats$A.norm[,,1])
numeric(0)
>
> # comparing original A to A.norm.sub (/w threshold=0.1)
> setdiff(test.mats$A[,,1], test.mats$A.norm.sub[[1]][,,1])
[1] 0.007186012 0.087695136 0.010113229 0.052246395 0.059311042 0.049008269 0.084500544 0.015638971 0.072155727 0.034845783
[11] 0.899023654 0.041251892 0.052992066 0.067633726 0.181263116 0.029645438 0.088317549
>
> # finding element values smaller than threshold=0.1 in original conmat
> which(test.mats$A[,,1] < 0.1)
[1] 5 6 13 14 19 20 21 27 28 33 34 35 36 37 41 42 47 48 49 50 51 52 55 56 57 58 59 60 64 65
[31] 66 67 68 71 72 73 74 79 80 81 82 83 86 87 88 95 96 101 102 103 109 110 115 116 117 118 123 124 130 131
[61] 132 137 139 145 146 147 148 149 150 153 154 159 160 161 162 163 167 168 169 170 171 172 174 178 179 180 183 184 185 186
[91] 193 194
>
> # finding element values smaller than threshold=0.1 in original conmat
> which(test.mats$A.norm.sub[[1]][,,1] < 0.1)
[1] 5 6 13 14 19 20 21 27 28 33 34 35 36 37 41 42 47 48 49 50 51 52 55 56 57 58 59 60 64 65
[31] 66 67 68 71 72 73 74 79 80 81 82 83 86 87 88 95 96 101 102 103 109 110 115 116 117 118 123 124 130 131
[61] 132 137 139 145 146 147 148 149 150 153 154 159 160 161 162 163 167 168 169 170 171 172 174 178 179 180 183 184 185 186
[91] 193 194
)To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/e1d0f5cd-e300-4f86-b3e1-c85ef9eae018%40googlegroups.com.
# initiating thresholds
# thresholds <- c(0.1, 0.3, 0.5)
thresholds <- rev(seq(0.1, 0.95, 0.05))
sub.thresh <- 0
modality <- 'fmri'
# trying another way to define inds
groups <- c('Pre', 'Post')
covar <- data.frame(Study.ID = c('p21','p22','p32','p38'), Group = rep(groups, each = 4))
covar <- data.table::data.table(covar)
covar[, Group := as.factor(Group)]
setkey(covar, Group, Study.ID)
inds <- lapply(seq_along(groups), function(x) covar[, which(Group == groups[x])]) # group indicator; list
# creating graph matrices from files
test.mats <- brainGraph::create_mats(f.A,
modality = modality,
mat.thresh = thresholds,
sub.thresh = sub.thresh,
inds = inds)
> test.mats$A.norm.sub[[1]][,,1]
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
[1,] Inf 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0 0 0.0000000 0.0000000
[2,] 0 Inf 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0 0 0.0000000 0.0000000
[3,] 0 0 Inf 0.5943696 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0 0 0.0000000 0.0000000
[4,] 0 0 0.5943696 Inf 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0 0 0.0000000 0.0000000
[5,] 0 0 0.0000000 0.0000000 Inf 0.7173606 0.0000000 0.0000000 0.0000000 0.0000000 0 0 0.0000000 0.0000000
[6,] 0 0 0.0000000 0.0000000 0.7173606 Inf 0.0000000 0.0000000 0.0000000 0.0000000 0 0 0.0000000 0.0000000
[7,] 0 0 0.0000000 0.0000000 0.0000000 0.0000000 Inf 0.6354096 0.0000000 0.0000000 0 0 0.0000000 0.0000000
[8,] 0 0 0.0000000 0.0000000 0.0000000 0.0000000 0.6354096 Inf 0.0000000 0.0000000 0 0 0.0000000 0.0000000
[9,] 0 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 Inf 0.5459645 0 0 0.0000000 0.0000000
[10,] 0 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.5459645 Inf 0 0 0.0000000 0.0000000
[11,] 0 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 Inf 0 0.0000000 0.0000000
[12,] 0 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0 Inf 0.0000000 0.0000000
[13,] 0 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0 0 Inf 0.5847243
[14,] 0 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0 0 0.5847243 Inf
To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/c043af6d-1df2-4ad9-900c-43ca3e75e458%40googlegroups.com.
# Back to a list of arrays for all subjects
A.norm.sub <-
lapply(seq_along(mat.thresh), function(z)
lapply(seq_along(inds), function(x)
array(sapply(inds[[x]], function(y)
ifelse(A.inds[[z]][[x]] == 1, A.norm[, , y], 0)),
dim=dim(A.norm[, , inds[[x]]]))))
A.norm.sub <- lapply(A.norm.sub, function(x) do.call(abind, x))
To unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/338cd98d-e56f-4c03-b750-c04bd2cf919d%40googlegroups.com.
# restructured code for raw value thresholding
A.norm.sub <- lapply(seq_along(thresh), function(z) {
# cat("Current threshold: ", thresh[z], "\n")
lapply(seq_along(inds), function(x) {
array(sapply(inds[[x]], function(y) {
# cat(" --- current inds: ", inds[[x]][y], "\n")
ifelse(A[, , y] > thresh[z], A[, , y], 0)
})
,dim = dim(A[, , inds[[x]]]))
})
})
If I have a single directory with all "SID_mat.txt" files, then of course it is a moot point and a simple "setkey(covars, Study.ID)"
# calculating all graph metrics and setting graph attributes
g.tmp <- set_brainGraph_attr(g.tmp, atlas, modality = 'fmri',
weighting = 'pearson', threshold = thresholds[j],
subject = covar[groups[i], Study.ID[k]], group = groups[i],
#subject = covar$Study.ID[inds[[i]][k]], group = groups[i],
use.parallel = FALSE, A = A.norm.sub[[j]][, , inds[[i]][k]])
# Double checking `Study.ID` for individual subject graph and removing it if found same.
for (i in seq_along(groups)) {
g.norm[[i]] <- fnames[[i]] <- vector('list', length = length(thresholds))
for (j in seq_along(thresholds)) {
fnames[[i]][[j]] <- list.files(savedir, sprintf('g%i_thr%02i.*', i, j), full.names = T)
g.norm[[i]][[j]] <- lapply(fnames[[i]][[j]], readRDS)
}
x <- all.equal(sapply(g.norm[[i]][[1]], graph_attr, 'name'), covar[groups[i], Study.ID])
if (isTRUE(x)) lapply(fnames[[i]], file.remove)
}
saveRDS(g.norm, file = file.path(savedir, 'g.norm.rds'))
A.norm.sub[[j]][, , inds[[i]][k]])
...
[Message clipped]
--
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-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/bd52ec1e-c3bf-49a2-942a-07439e491933%40googlegroups.com.
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 unsubscribe from this group and stop receiving emails from it, send an email to brainGraph-help+unsubscribe@googlegroups.com.
To post to this group, send email to brainGraph-help@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brainGraph-help/3672f088-cda8-4c61-aae0-85f7b298c606%40googlegroups.com.