Skip to content

Commit 4f024f3

Browse files
committed
0.8.1: added cwp_thr
1 parent dc81b89 commit 4f024f3

File tree

5 files changed

+47
-46
lines changed

5 files changed

+47
-46
lines changed

R/qdecr.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ qdecr <- function(id,
3636
"w_g.pct", "white.H", "white.K"),
3737
fwhm = ifelse(measure == "pial_lgi", 5, 10),
3838
mcz_thr = 30,
39+
cwp_thr = 0.025,
3940
mgh = NULL,
4041
mask = NULL,
4142
mask_path = system.file("extdata", paste0(hemi, ".fsaverage.cortex.mask.mgh"), package = "QDECR"),
@@ -187,7 +188,7 @@ qdecr <- function(id,
187188
for ( i in seq_along(vw$stack$names)){
188189
message2("\n", verbose = verbose)
189190
runMriSurfCluster(vw$paths$final_path, vw$paths$dir_fshome, vw$input$hemi, vw$stack$p[[i]], vw$post$fwhm_est,
190-
mask_path = vw$paths$final_mask_path, verbose = verbose, mczThr = mcz_thr,
191+
mask_path = vw$paths$final_mask_path, verbose = verbose, mcz_thr = mcz_thr, cwp_thr = cwp_thr,
191192
stack = i, stack_name = vw$stack$names[i])
192193
}
193194
vw$post$final_mask <- load.mgh(vw$paths$final_mask_path)$x

R/qdecr_fastlm.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#' @param target the target template (usually "fsaverage")
1111
#' @param fwhm full width half max (default = 10 mm, for pial_lgi it is 5 mm)
1212
#' @param mcz_thr the Monte Carlo simulation threshold times 10 (13 = 0.05, 20 = 0.01, 23 = 0.005 30 = 0.001, etc..)
13+
#' @param cwp_thr the cluster-wise p-value threshold on top of all correction (default = 0.025, as there are 2 hemispheres)
1314
#' @param mgh NOT IMPLEMENTED; path to existing merged mgh file, default is NULL
1415
#' @param mask mgh file to mask analysis; default is to use the cortex label from the target
1516
#' @param mask_path path to the mask; default is the cortex mask that is provided with the QDECR package
@@ -40,6 +41,7 @@ qdecr_fastlm <- function(formula,
4041
target = "fsaverage",
4142
fwhm = ifelse(measure == "pial_lgi", 5, 10),
4243
mcz_thr = 30,
44+
cwp_thr = 0.025,
4345
mgh = NULL,
4446
mask = NULL,
4547
mask_path = system.file("extdata", paste0(hemi, ".fsaverage.cortex.mask.mgh"), package = "QDECR"),
@@ -85,6 +87,7 @@ vw <- qdecr(id = id,
8587
target = target,
8688
fwhm = fwhm,
8789
mcz_thr = mcz_thr,
90+
cwp_thr = cwp_thr,
8891
measure = qqt2,
8992
mgh = mgh,
9093
mask = mask,

R/qdecr_post.R

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,38 @@
1-
2-
3-
4-
calc_fwhm <- function(final_path, final_mask_path, est_fwhm_path, hemi, eres, mask = NULL, target = "fsaverage", verbose = FALSE) {
5-
cmdStr <- paste("mris_fwhm", "--i", eres, "--hemi", hemi, "--subject", target, "--prune", "--cortex", "--dat", est_fwhm_path, "--out-mask", final_mask_path)
6-
if (!is.null(mask)) paste(cmdStr, "--mask", mask)
7-
message2(verbose = verbose, cmdStr)
8-
system(cmdStr, ignore.stdout = !verbose)
9-
fwhm <- read.table(est_fwhm_path)
10-
fwhm <- round(fwhm)
11-
return(fwhm)
12-
}
13-
14-
runMriSurfCluster <- function(final_path, dir_fshome, hemi, pval, fwhm, mask_path = NULL, cwpThr = 0.025, mczThr = NULL, csdSign = "abs", verbose = FALSE, stack, stack_name) {
15-
16-
if (is.null(mczThr)){
17-
mczThr = paste0("th", as.character(30))
18-
}
19-
else {
20-
mczThr = paste0("th", as.character(mczThr))
21-
}
22-
23-
oBaseName <- paste0(final_path, ".stack", stack, ".cache.", mczThr, '.', csdSign, ".sig")
24-
if (fwhm < 10) fwhm <- paste0('0', fwhm)
25-
csd <- file.path(dir_fshome, "average/mult-comp-cor/fsaverage", hemi, paste0("cortex/fwhm", fwhm), csdSign, mczThr, "mc-z.csd")
26-
cmdStr <- paste("mri_surfcluster",
27-
"--in", pval,
28-
"--csd", csd,
29-
"--cwsig", paste0(oBaseName, ".cluster.mgh"),
30-
"--vwsig", paste0(oBaseName, ".voxel.mgh"),
31-
"--sum", paste0(oBaseName, ".cluster.summary"),
32-
"--ocn", paste0(oBaseName, ".ocn.mgh"),
33-
"--oannot", paste0(oBaseName, ".ocn.annot"),
34-
"--annot", "aparc",
35-
"--csdpdf", paste0(oBaseName, ".pdf.dat"),
36-
"--cwpvalthresh", cwpThr,
37-
"--o", paste0(oBaseName, ".masked.mgh"),
38-
"--no-fixmni",
39-
"--surf", "white")
40-
cmdStr <- if (!is.null(mask_path)) paste(cmdStr, "--mask", mask_path) else paste(cmdStr, "--cortex")
41-
system(cmdStr, ignore.stdout = !verbose)
42-
NULL
1+
2+
3+
4+
calc_fwhm <- function(final_path, final_mask_path, est_fwhm_path, hemi, eres, mask = NULL, target = "fsaverage", verbose = FALSE) {
5+
cmdStr <- paste("mris_fwhm", "--i", eres, "--hemi", hemi, "--subject", target, "--prune", "--cortex", "--dat", est_fwhm_path, "--out-mask", final_mask_path)
6+
if (!is.null(mask)) paste(cmdStr, "--mask", mask)
7+
message2(verbose = verbose, cmdStr)
8+
system(cmdStr, ignore.stdout = !verbose)
9+
fwhm <- read.table(est_fwhm_path)
10+
fwhm <- round(fwhm)
11+
return(fwhm)
12+
}
13+
14+
runMriSurfCluster <- function(final_path, dir_fshome, hemi, pval, fwhm, mask_path = NULL, cwp_thr = 0.025, mcz_thr = 30, csd_sign = "abs", verbose = FALSE, stack, stack_name) {
15+
16+
mcz_thr2 <- paste0("th", mcz_thr)
17+
18+
o_base_name <- paste0(final_path, ".stack", stack, ".cache.", mcz_thr2, '.', csd_sign, ".sig")
19+
if (fwhm < 10) fwhm <- paste0("0", fwhm)
20+
csd <- file.path(dir_fshome, "average/mult-comp-cor/fsaverage", hemi, paste0("cortex/fwhm", fwhm), csd_sign, mcz_thr2, "mc-z.csd")
21+
cmd_str <- paste("mri_surfcluster",
22+
"--in", pval,
23+
"--csd", csd,
24+
"--cwsig", paste0(o_base_name, ".cluster.mgh"),
25+
"--vwsig", paste0(o_base_name, ".voxel.mgh"),
26+
"--sum", paste0(o_base_name, ".cluster.summary"),
27+
"--ocn", paste0(o_base_name, ".ocn.mgh"),
28+
"--oannot", paste0(o_base_name, ".ocn.annot"),
29+
"--annot", "aparc",
30+
"--csdpdf", paste0(o_base_name, ".pdf.dat"),
31+
"--cwpvalthresh", cwp_thr,
32+
"--o", paste0(o_base_name, ".masked.mgh"),
33+
"--no-fixmni",
34+
"--surf", "white")
35+
cmd_str <- if (!is.null(mask_path)) paste(cmd_str, "--mask", mask_path) else paste(cmd_str, "--cortex")
36+
system(cmd_str, ignore.stdout = !verbose)
37+
NULL
4338
}

man/qdecr.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/qdecr_fastlm.Rd

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)