From 721d961fcc4dc5818076d78f7f8111f18ef2c64c Mon Sep 17 00:00:00 2001 From: cfhammill Date: Wed, 3 Jul 2019 14:10:38 -0400 Subject: [PATCH 01/31] Proposed fix for #261 --- R/minc_lmer.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/minc_lmer.R b/R/minc_lmer.R index cc8a24e4..7555e2f6 100644 --- a/R/minc_lmer.R +++ b/R/minc_lmer.R @@ -354,7 +354,7 @@ mincLmerOptimizeCore <- function(rho, lmod, REMLpass, verbose, control, mcout, s # time it can stay outside the loop, but occasionally gives weird errors # if inside. So wrapped inside that reinit bit: if (reinit) { - form <- mcout[[2]] + form <- lmod$formula lmod$reTrms <- mkReTrms(findbars(form[[length(form)]]), lmod$fr) rho$pp <- do.call(merPredD$new, c(lmod$reTrms[c("Zt", "theta", "Lambdat", "Lind")], From 10455bff48ef50b701c7fae91fba6f18cf72619a Mon Sep 17 00:00:00 2001 From: cfhammill Date: Tue, 8 Oct 2019 14:58:15 -0400 Subject: [PATCH 02/31] Extra install notes for macOS --- INSTALL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 3b1e966b..98423ccd 100644 --- a/INSTALL +++ b/INSTALL @@ -59,7 +59,7 @@ you can use homebrew to install the Gnu Compiler Collection which comes with gfortran ``` -brew install gcc +brew install gcc libssh2 libgit2 libomp ``` Regardless of how you install gfortran you will need to tell From 359e8f37358b28fc8e98f0d8a7c4925f6a3a7e19 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Tue, 8 Oct 2019 14:58:45 -0400 Subject: [PATCH 03/31] Default RMINC_LABEL_DEFINITIONS to NULL --- R/RMINC.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/RMINC.R b/R/RMINC.R index 56b5c33c..aa5ebc35 100644 --- a/R/RMINC.R +++ b/R/RMINC.R @@ -77,6 +77,9 @@ NULL ### Package initialization function, syncs environment vars and defines defaults .onLoad <- function(libname, pkgname){ + empty_to_null <- function(x){ + `if`(x == "", NULL, x) + } #Set default options taken from Hadley's r-packages book op <- options() @@ -85,7 +88,7 @@ NULL RMINC_MASKED_VALUE = structure(0, class = "RMINC_MASKED_VALUE") , RMINC_LABEL_DEFINITIONS = - Sys.getenv("RMINC_LABEL_DEFINITIONS") + empty_to_null(Sys.getenv("RMINC_LABEL_DEFINITIONS")) , RMINC_BATCH_CONF = `if`(Sys.getenv("RMINC_BATCH_CONF") == "" , system.file("parallel/pbs_batchtools.R", package = "RMINC") From bd3269851e9667c70ca1b6c776b88e6768afd17b Mon Sep 17 00:00:00 2001 From: cfhammill Date: Tue, 8 Oct 2019 15:16:28 -0400 Subject: [PATCH 04/31] Allow anatGetAll to fail fast Following suggestion in #260 --- R/minc_anatomy.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/R/minc_anatomy.R b/R/minc_anatomy.R index 2960382a..9bef7f2b 100644 --- a/R/minc_anatomy.R +++ b/R/minc_anatomy.R @@ -178,6 +178,9 @@ anatGetAll <- atlas <- character(0) } + if(!is.null(defs)) #Read early to allow quick fail out + label_frame <- create_labels_frame(defs, side = side) + compute_summary <- function(file_atlas_pairs){ atlas_get_all(file_atlas_pairs[[1]], file_atlas_pairs[[2]] , method = method) @@ -252,10 +255,9 @@ anatGetAll <- .[order(as.numeric(rownames(.))),,drop=FALSE] missing_labels <- abs(rowSums(out)) == 0 - ## Handle creating the label frame - if(!is.null(defs)){ - label_frame <- create_labels_frame(defs, side = side) - } else { + + ## Handle creating the label frame if no defs was provided + if(is.null(defs)){ warning("No definitions provided, using indices from atlas \n", "to set a default label set options(RMINC_LABEL_DEFINITIONS),", " or set it as an environment variable") From f83f1f2db4cc6a93362f70df6a5033fe5fd3aeac Mon Sep 17 00:00:00 2001 From: cfhammill Date: Tue, 8 Oct 2019 15:45:19 -0400 Subject: [PATCH 05/31] Add warning expectations for anatGetAll tests The need for this was triggered by reordering the label file reading --- tests/testthat/test_anatGet.R | 60 +++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/tests/testthat/test_anatGet.R b/tests/testthat/test_anatGet.R index 86aca844..f64a5a7d 100644 --- a/tests/testthat/test_anatGet.R +++ b/tests/testthat/test_anatGet.R @@ -148,30 +148,50 @@ test_that("AnatGetAll multi-atlas works", { , ~ mincWriteVolume(.x, output.filename = .y , like.filename = gf$jacobians_0.2[1])) }) - + + # Test labels label_volume <- - verboseRun(anatGetAll(seg_files, method = "labels", defs = NULL)) + expect_warning( + verboseRun(anatGetAll(seg_files, method = "labels", defs = NULL)) + , "No definitions provided" + ) + gold_volumes <- map2(segs, segs, ~ tapply(.x, .y, function(s) length(s) * (.1)^3)[-1]) %>% reduce(rbind) expect_equivalent(unanat(label_volume), gold_volumes) - + + # Test means label_means <- - verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "means")) + expect_warning( + verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "means")) + , "No definitions provided" + ) + gold_means <- map2(vals, segs, ~ tapply(.x,.y, function(s) mean(s))[-1]) %>% reduce(rbind) expect_equivalent(unanat(label_means), gold_means, tolerance = 10e-5) + # Test sums label_sums <- - verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "sums")) + expect_warning( + verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "sums")) + , "No definitions provided" + ) + gold_sums <- map2(vals, segs, ~ tapply(.x,.y, function(s) sum(s))[-1]) %>% reduce(rbind) expect_equivalent(unanat(label_sums), gold_sums, tolerance = 10e-5) + # Test jacobians label_jacobians <- - verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "jacobians")) + expect_warning( + verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "jacobians")) + , "No definitions provided" + ) + gold_jacobians <- map2(vals, segs, ~ tapply(.x,.y, function(s) sum(exp(s) * .1^3))[-1]) %>% reduce(rbind) @@ -183,23 +203,35 @@ test_that("AnatGetAll multi-atlas works", { test_that("AnatGetAll local parallel works", { evalq({ label_volume <- - verboseRun(anatGetAll(seg_files, method = "labels", defs = NULL - , parallel = c("local", 2))) + expect_warning( + verboseRun(anatGetAll(seg_files, method = "labels", defs = NULL + , parallel = c("local", 2))) + , "No definitions provided") + expect_equivalent(unanat(label_volume), gold_volumes) label_means <- - verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "means" - , parallel = c("local", 2))) + expect_warning( + verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "means" + , parallel = c("local", 2))) + , "No definitions provided") + expect_equivalent(unanat(label_means), gold_means, tolerance = 10e-5) label_sums <- - verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "sums" - , parallel = c("local", 2))) + expect_warning( + verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "sums" + , parallel = c("local", 2))) + , "No definitions provided") + expect_equivalent(unanat(label_sums), gold_sums, tolerance = 10e-5) label_jacobians <- - verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "jacobians" - , parallel = c("local", 2))) + expect_warning( + verboseRun(anatGetAll(val_files, seg_files, defs = NULL, method = "jacobians" + , parallel = c("local", 2))) + , "No definitions provided") + expect_equivalent(unanat(label_jacobians), gold_jacobians, tolerance = 10e-5) } , envir = test_env) From 81b60ddb9acb84df213101a4117ea00725a75f35 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Wed, 12 Feb 2020 16:13:46 -0500 Subject: [PATCH 06/31] Roxygen version upgrade --- DESCRIPTION | 2 +- man/add_colour_bar.Rd | 6 +++--- man/civet.CreateBrainViewFile.Rd | 4 ++-- man/civet.getFilename.Rd | 20 ++++++++++---------- man/colour_mesh.Rd | 5 +++-- man/getRMINCTestData.Rd | 7 +++++-- man/hanatToVisGraph.Rd | 4 ++-- man/launch_shinyRMINC.Rd | 7 ++++--- man/lut_to_palette.Rd | 4 ++-- man/map_to_colours.Rd | 5 +++-- man/mcMincApply.Rd | 7 ++++--- man/minc.ray.trace.Rd | 5 +++-- man/mincApplyRCPP.Rd | 4 ++-- man/mincFDR.Rd | 4 ++-- man/mincImage.Rd | 4 ++-- man/mincLm.Rd | 4 ++-- man/mincPlotAnatAndStatsSlice.Rd | 11 ++++++----- man/mincRandomize.Rd | 4 ++-- man/mincRayTraceStats.Rd | 6 +++--- man/mincSelectRandomVoxels.Rd | 3 ++- man/mincTFCE.Rd | 12 ++++++------ man/mincWriteVolume.Rd | 4 ++-- man/pMincApply.Rd | 3 ++- man/plot.bic_obj.Rd | 5 +++-- man/qMincApply.Rd | 12 ++++++------ man/runRMINCTestbed.Rd | 8 +++++--- man/thresholds.Rd | 4 ++-- man/vertexAtlasApply.Rd | 5 +++-- man/vertexFindPeaks.Rd | 3 ++- man/vertexTFCE.Rd | 17 +++++++++-------- 30 files changed, 103 insertions(+), 86 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ed533a96..89f26ad1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,4 +60,4 @@ OS_type: unix BugReports: https://github.com/Mouse-Imaging-Centre/RMINC/issues URL: https://github.com/Mouse-Imaging-Centre/RMINC, https://wiki.mouseimaging.ca/display/MICePub/RMINC -RoxygenNote: 6.1.0 +RoxygenNote: 6.1.1 diff --git a/man/add_colour_bar.Rd b/man/add_colour_bar.Rd index e0c37d55..e7e88c92 100644 --- a/man/add_colour_bar.Rd +++ b/man/add_colour_bar.Rd @@ -4,9 +4,9 @@ \alias{add_colour_bar} \title{Add a colour bar for a mesh} \usage{ -add_colour_bar(mesh, title = "", lpos = 0.97, rpos = 0.99, bpos = NULL, - tpos = NULL, bpos2 = NULL, tpos2 = NULL, nudge_title_y = 0.5, - nudge_title_x = 0.82, vertical = TRUE, ...) +add_colour_bar(mesh, title = "", lpos = 0.97, rpos = 0.99, + bpos = NULL, tpos = NULL, bpos2 = NULL, tpos2 = NULL, + nudge_title_y = 0.5, nudge_title_x = 0.82, vertical = TRUE, ...) } \arguments{ \item{mesh}{A \code{obj_mesh} object created with \link{colour_mesh}} diff --git a/man/civet.CreateBrainViewFile.Rd b/man/civet.CreateBrainViewFile.Rd index 60bcbe5f..e8d722b7 100644 --- a/man/civet.CreateBrainViewFile.Rd +++ b/man/civet.CreateBrainViewFile.Rd @@ -4,8 +4,8 @@ \alias{civet.CreateBrainViewFile} \title{Create a brain view file} \usage{ -civet.CreateBrainViewFile(dataFile, atlasFile, atlasVertices, outputFileName, - civetVersion = "1.1.12") +civet.CreateBrainViewFile(dataFile, atlasFile, atlasVertices, + outputFileName, civetVersion = "1.1.12") } \arguments{ \item{dataFile}{Either the name of a file with atlas labeling or an R array with atlas labeling} diff --git a/man/civet.getFilename.Rd b/man/civet.getFilename.Rd index 3f1741bd..68009468 100644 --- a/man/civet.getFilename.Rd +++ b/man/civet.getFilename.Rd @@ -41,17 +41,17 @@ civet.getFilenameCerebrumMask(scanID, baseDir, civetVersion = "1.1.9", civet.getFilenameSkullMask(scanID, baseDir, civetVersion = "1.1.9", fullPath = TRUE) -civet.getFilenameGrayMatterSurfaces(scanID, baseDir, civetVersion = "1.1.9", - fullPath = TRUE) +civet.getFilenameGrayMatterSurfaces(scanID, baseDir, + civetVersion = "1.1.9", fullPath = TRUE) -civet.getFilenameWhiteMatterSurfaces(scanID, baseDir, civetVersion = "1.1.9", - fullPath = TRUE) +civet.getFilenameWhiteMatterSurfaces(scanID, baseDir, + civetVersion = "1.1.9", fullPath = TRUE) civet.getFilenameMidSurfaces(scanID, baseDir, civetVersion = "1.1.9", fullPath = TRUE) -civet.getFilenamesCorticalThickness(scanID, baseDir, civetVersion = "1.1.9", - smoothing = "20mm", fullPath = TRUE) +civet.getFilenamesCorticalThickness(scanID, baseDir, + civetVersion = "1.1.9", smoothing = "20mm", fullPath = TRUE) civet.getFilenamesCorticalArea(scanID, baseDir, civetVersion = "1.1.9", smoothing = "40mm", fullPath = TRUE) @@ -59,14 +59,14 @@ civet.getFilenamesCorticalArea(scanID, baseDir, civetVersion = "1.1.9", civet.getFilenamesCorticalVolume(scanID, baseDir, civetVersion = "1.1.9", smoothing = "40mm", fullPath = TRUE) -civet.getFilenameMeanSurfaceCurvature(scanID, baseDir, civetVersion = "1.1.9", - fullPath = TRUE) +civet.getFilenameMeanSurfaceCurvature(scanID, baseDir, + civetVersion = "1.1.9", fullPath = TRUE) civet.getFilenameLinearTransform(scanID, baseDir, civetVersion = "1.1.9", fullPath = TRUE) -civet.getFilenameNonlinearTransform(scanID, baseDir, civetVersion = "1.1.9", - fullPath = TRUE) +civet.getFilenameNonlinearTransform(scanID, baseDir, + civetVersion = "1.1.9", fullPath = TRUE) } \arguments{ \item{scanID}{A string specifying the unique scan-id (and thus diff --git a/man/colour_mesh.Rd b/man/colour_mesh.Rd index 05c3648c..05344130 100644 --- a/man/colour_mesh.Rd +++ b/man/colour_mesh.Rd @@ -4,8 +4,9 @@ \alias{colour_mesh} \title{Colourize a mesh} \usage{ -colour_mesh(mesh, colour_map, colour_range = NULL, colour_default = "grey", - symmetric = NULL, labels = FALSE, palette = heat.colors(255)) +colour_mesh(mesh, colour_map, colour_range = NULL, + colour_default = "grey", symmetric = NULL, labels = FALSE, + palette = heat.colors(255)) } \arguments{ \item{mesh}{\link[rgl]{mesh3d} object ideally produced by \link{create_mesh}} diff --git a/man/getRMINCTestData.Rd b/man/getRMINCTestData.Rd index c850b3ac..def03005 100644 --- a/man/getRMINCTestData.Rd +++ b/man/getRMINCTestData.Rd @@ -4,11 +4,14 @@ \alias{getRMINCTestData} \title{Download Example Data} \usage{ -getRMINCTestData(dataPath = tempdir(), method = "libcurl") +getRMINCTestData(dataPath = getOption("RMINC_DATA_DIR", tempdir()), + method = "libcurl") } \arguments{ \item{dataPath}{The directory to download and unpack the test data -(unpacks in dataPath/rminctestdata)} +(unpacks in dataPath/rminctestdata). Default can be set with the option RMINC_DATA_DIR which +can in turn be set with the environment variable RMINC_DATA_DIR. If unset a temporary directory +is created.} \item{method}{Argument to pass to \link{download.file} typical options are \code{libcurl} and \code{wget}} diff --git a/man/hanatToVisGraph.Rd b/man/hanatToVisGraph.Rd index 912491cd..6d41b0f8 100644 --- a/man/hanatToVisGraph.Rd +++ b/man/hanatToVisGraph.Rd @@ -7,8 +7,8 @@ \usage{ hanatToVisGraph(hanatTree, colourVariable = "color_hex_triplet", colourScale = colorRampPalette(c("red", "yellow"))(255), - rColourScale = colorRampPalette(c("blue", "turquoise1"))(255), low = NULL, - high = NULL, symmetric = F, transparent = "#FDFDFD", + rColourScale = colorRampPalette(c("blue", "turquoise1"))(255), + low = NULL, high = NULL, symmetric = F, transparent = "#FDFDFD", edgeColourFromABI = F) hanatView(..., fontsize = 14, levelSeparation = 500) diff --git a/man/launch_shinyRMINC.Rd b/man/launch_shinyRMINC.Rd index 47a611ce..0669e45e 100644 --- a/man/launch_shinyRMINC.Rd +++ b/man/launch_shinyRMINC.Rd @@ -4,9 +4,10 @@ \alias{launch_shinyRMINC} \title{launch a shiny based inspector} \usage{ -launch_shinyRMINC(statsoutput, anatVol, volumes = NULL, keepBetas = FALSE, - plotcolumns = NULL, modelfunc = NULL, singleStatType = NULL, - fdr = NULL, anatLow = 700, anatHigh = 1400) +launch_shinyRMINC(statsoutput, anatVol, volumes = NULL, + keepBetas = FALSE, plotcolumns = NULL, modelfunc = NULL, + singleStatType = NULL, fdr = NULL, anatLow = 700, + anatHigh = 1400) } \arguments{ \item{statsoutput}{the output of mincLm, mincAnova, or mincLmer. Alternatively diff --git a/man/lut_to_palette.Rd b/man/lut_to_palette.Rd index 83e223c1..e52f46ed 100644 --- a/man/lut_to_palette.Rd +++ b/man/lut_to_palette.Rd @@ -4,8 +4,8 @@ \alias{lut_to_palette} \title{A tool that returns a color function/palette from color lookup files} \usage{ -lut_to_palette(lookup_table = system.file("luts/spectral", package = "RMINC"), - alpha = 1) +lut_to_palette(lookup_table = system.file("luts/spectral", package = + "RMINC"), alpha = 1) } \arguments{ \item{lookup_table}{Either a path to the lookup table file, or the table itself} diff --git a/man/map_to_colours.Rd b/man/map_to_colours.Rd index c5680144..15914233 100644 --- a/man/map_to_colours.Rd +++ b/man/map_to_colours.Rd @@ -4,8 +4,9 @@ \alias{map_to_colours} \title{Generate a vector of colours from a map} \usage{ -map_to_colours(colour_map, colour_range = NULL, colour_default = "grey", - symmetric = NULL, labels = FALSE, palette = heat.colors(255)) +map_to_colours(colour_map, colour_range = NULL, + colour_default = "grey", symmetric = NULL, labels = FALSE, + palette = heat.colors(255)) } \arguments{ \item{colour_map}{either a vector with a label/measure/statistic for every vertex diff --git a/man/mcMincApply.Rd b/man/mcMincApply.Rd index ecbff18a..c270890e 100644 --- a/man/mcMincApply.Rd +++ b/man/mcMincApply.Rd @@ -5,9 +5,10 @@ \title{Local multicore mincApply} \usage{ mcMincApply(filenames, fun, ..., mask = NULL, tinyMask = FALSE, - slab_sizes = NULL, temp_dir = getwd(), cores = getOption("mc.cores", - parallel::detectCores() - 1), return_raw = FALSE, cleanup = TRUE, - mask_vals = NULL, collate = simplify2minc) + slab_sizes = NULL, temp_dir = getwd(), + cores = getOption("mc.cores", parallel::detectCores() - 1), + return_raw = FALSE, cleanup = TRUE, mask_vals = NULL, + collate = simplify2minc) } \arguments{ \item{filenames}{Paths to the minc files to apply accross} diff --git a/man/minc.ray.trace.Rd b/man/minc.ray.trace.Rd index 54c75d30..973315f6 100644 --- a/man/minc.ray.trace.Rd +++ b/man/minc.ray.trace.Rd @@ -6,8 +6,9 @@ \usage{ minc.ray.trace(volume, output = "slice.rgb", size = c(400, 400), slice = list(pos = 0, wv = "w", axis = "z"), threshold = NULL, - colourmap = "-spectral", background = NULL, background.threshold = NULL, - background.colourmap = "-gray", display = TRUE) + colourmap = "-spectral", background = NULL, + background.threshold = NULL, background.colourmap = "-gray", + display = TRUE) } \arguments{ \item{volume}{The filename of a volume to render.} diff --git a/man/mincApplyRCPP.Rd b/man/mincApplyRCPP.Rd index 07d28a01..06b726d7 100644 --- a/man/mincApplyRCPP.Rd +++ b/man/mincApplyRCPP.Rd @@ -5,8 +5,8 @@ \title{Perform Arbitrary calculations on a collection of mincVolumes} \usage{ mincApplyRCPP(filenames, fun, ..., mask = NULL, maskval = NULL, - filter_masked = FALSE, slab_sizes = c(1, 1, 1), return_indices = FALSE, - collate = simplify2minc) + filter_masked = FALSE, slab_sizes = c(1, 1, 1), + return_indices = FALSE, collate = simplify2minc) } \arguments{ \item{filenames}{The name of the files to apply over} diff --git a/man/mincFDR.Rd b/man/mincFDR.Rd index 4114bbee..dc0d31cd 100644 --- a/man/mincFDR.Rd +++ b/man/mincFDR.Rd @@ -10,8 +10,8 @@ \usage{ mincFDR(buffer, ...) -\method{mincFDR}{mincSingleDim}(buffer, df, mask = NULL, method = "fdr", - ...) +\method{mincFDR}{mincSingleDim}(buffer, df, mask = NULL, + method = "fdr", ...) \method{mincFDR}{mincLogLikRatio}(buffer, mask = NULL, ...) diff --git a/man/mincImage.Rd b/man/mincImage.Rd index af89ca2e..77d33818 100644 --- a/man/mincImage.Rd +++ b/man/mincImage.Rd @@ -4,8 +4,8 @@ \alias{mincImage} \title{Plot a slice from a MINC volume} \usage{ -mincImage(volume, dimension = 2, slice = NULL, low = min(volume, na.rm = - TRUE), high = max(volume, na.rm = TRUE), reverse = FALSE, +mincImage(volume, dimension = 2, slice = NULL, low = min(volume, + na.rm = TRUE), high = max(volume, na.rm = TRUE), reverse = FALSE, underTransparent = FALSE, col = gray.colors(255), add = FALSE, ...) } \arguments{ diff --git a/man/mincLm.Rd b/man/mincLm.Rd index aba38fea..ca81c530 100644 --- a/man/mincLm.Rd +++ b/man/mincLm.Rd @@ -4,8 +4,8 @@ \alias{mincLm} \title{Linear model at Every Voxel} \usage{ -mincLm(formula, data = NULL, subset = NULL, mask = NULL, maskval = NULL, - parallel = NULL, cleanup = TRUE, +mincLm(formula, data = NULL, subset = NULL, mask = NULL, + maskval = NULL, parallel = NULL, cleanup = TRUE, conf_file = getOption("RMINC_BATCH_CONF")) } \arguments{ diff --git a/man/mincPlotAnatAndStatsSlice.Rd b/man/mincPlotAnatAndStatsSlice.Rd index 92b28bcc..6b8d7d29 100644 --- a/man/mincPlotAnatAndStatsSlice.Rd +++ b/man/mincPlotAnatAndStatsSlice.Rd @@ -4,11 +4,12 @@ \alias{mincPlotAnatAndStatsSlice} \title{Anatomy and Statistics Slice} \usage{ -mincPlotAnatAndStatsSlice(anatomy, statistics, slice = NULL, dimension = 2, - low = min(statistics, na.rm = TRUE), high = max(statistics, na.rm = TRUE), - anatLow = min(anatomy, na.rm = TRUE), anatHigh = max(anatomy, na.rm = - TRUE), symmetric = FALSE, col = NULL, rcol = NULL, legend = NULL, - acol = gray.colors(255, start = 0), legendTextColour = "black") +mincPlotAnatAndStatsSlice(anatomy, statistics, slice = NULL, + dimension = 2, low = min(statistics, na.rm = TRUE), + high = max(statistics, na.rm = TRUE), anatLow = min(anatomy, na.rm = + TRUE), anatHigh = max(anatomy, na.rm = TRUE), symmetric = FALSE, + col = NULL, rcol = NULL, legend = NULL, acol = gray.colors(255, + start = 0), legendTextColour = "black") } \arguments{ \item{anatomy}{A minc array of the anatomy volume to plot} diff --git a/man/mincRandomize.Rd b/man/mincRandomize.Rd index 63385893..bf741656 100644 --- a/man/mincRandomize.Rd +++ b/man/mincRandomize.Rd @@ -11,8 +11,8 @@ mincRandomize(x, R = 500, alternative = c("two.sided", "greater"), conf_file = getOption("RMINC_BATCH_CONF")) \method{mincRandomize}{mincLm}(x, R = 500, alternative = c("two.sided", - "greater"), replace = FALSE, parallel = NULL, columns = grep("tvalue-", - colnames(x)), resources = list(), + "greater"), replace = FALSE, parallel = NULL, + columns = grep("tvalue-", colnames(x)), resources = list(), conf_file = getOption("RMINC_BATCH_CONF")) } \arguments{ diff --git a/man/mincRayTraceStats.Rd b/man/mincRayTraceStats.Rd index 6924f2b2..4820d2d2 100644 --- a/man/mincRayTraceStats.Rd +++ b/man/mincRayTraceStats.Rd @@ -9,9 +9,9 @@ mincRayTraceStats(v, anatomy.volume, statsbuffer, column = 1, image.max = 4000, output.width = 800, output.height = 800, place.inset = FALSE, inset = NULL, stats.largest.pos = NULL, stats.largest.neg = NULL, caption = "t-statistic", fdr = NULL, - slice.direction = "transverse", outputfile = "ray_trace_crosshair.png", - show.pos.and.neg = FALSE, display = TRUE, clobber = NULL, - tmpdir = "/tmp") + slice.direction = "transverse", + outputfile = "ray_trace_crosshair.png", show.pos.and.neg = FALSE, + display = TRUE, clobber = NULL, tmpdir = "/tmp") } \arguments{ \item{v}{A mincVoxel indicating the voxel of interest.} diff --git a/man/mincSelectRandomVoxels.Rd b/man/mincSelectRandomVoxels.Rd index ae68d4b8..5d04ab44 100644 --- a/man/mincSelectRandomVoxels.Rd +++ b/man/mincSelectRandomVoxels.Rd @@ -4,7 +4,8 @@ \alias{mincSelectRandomVoxels} \title{selects a few random indices from a volume} \usage{ -mincSelectRandomVoxels(volumeFileName, nvoxels = 50, convert = TRUE, ...) +mincSelectRandomVoxels(volumeFileName, nvoxels = 50, convert = TRUE, + ...) } \arguments{ \item{volumeFileName}{the filename for a MINC volume} diff --git a/man/mincTFCE.Rd b/man/mincTFCE.Rd index ebd67452..bd5ecc27 100644 --- a/man/mincTFCE.Rd +++ b/man/mincTFCE.Rd @@ -12,15 +12,15 @@ mincTFCE(x, ...) \method{mincTFCE}{mincSingleDim}(x, d = 0.1, E = 0.5, H = 2, side = c("both", "positive", "negative"), output_file = NULL, - keep = is.null(output_file), conf_file = getOption("RMINC_BATCH_CONF"), - ...) + keep = is.null(output_file), + conf_file = getOption("RMINC_BATCH_CONF"), ...) -\method{mincTFCE}{matrix}(x, d = 0.1, E = 0.5, H = 2, side = c("both", - "positive", "negative"), like_volume, ...) +\method{mincTFCE}{matrix}(x, d = 0.1, E = 0.5, H = 2, + side = c("both", "positive", "negative"), like_volume, ...) \method{mincTFCE}{mincMultiDim}(x, d = 0.1, E = 0.5, H = 2, - side = c("both", "positive", "negative"), like_volume = likeVolume(x), - ...) + side = c("both", "positive", "negative"), + like_volume = likeVolume(x), ...) \method{mincTFCE}{mincLm}(x, R = 500, alternative = c("two.sided", "greater"), d = 0.1, E = 0.5, H = 2, side = c("both", "positive", diff --git a/man/mincWriteVolume.Rd b/man/mincWriteVolume.Rd index 8d482e4f..493b3a50 100644 --- a/man/mincWriteVolume.Rd +++ b/man/mincWriteVolume.Rd @@ -12,8 +12,8 @@ mincWriteVolume(buffer, ...) \method{mincWriteVolume}{mincSingleDim}(buffer, output.filename, clobber = NULL, ...) -\method{mincWriteVolume}{mincMultiDim}(buffer, output.filename, column = 1, - like.filename = NULL, clobber = NULL, ...) +\method{mincWriteVolume}{mincMultiDim}(buffer, output.filename, + column = 1, like.filename = NULL, clobber = NULL, ...) \method{mincWriteVolume}{default}(buffer, output.filename, like.filename, clobber = NULL, ...) diff --git a/man/pMincApply.Rd b/man/pMincApply.Rd index fc490117..98a63eb2 100644 --- a/man/pMincApply.Rd +++ b/man/pMincApply.Rd @@ -10,7 +10,8 @@ pMincApply(filenames, fun, ..., mask = NULL, tinyMask = FALSE, walltime = NULL, workers = batches, temp_dir = getwd(), cleanup = TRUE, collate = simplify2minc, conf_file = getOption("RMINC_BATCH_CONF"), - registry_name = new_file("pMincApply_registry"), registry_dir = getwd()) + registry_name = new_file("pMincApply_registry"), + registry_dir = getwd()) } \arguments{ \item{filenames}{Paths to the minc files to be applied accross} diff --git a/man/plot.bic_obj.Rd b/man/plot.bic_obj.Rd index b034ca6a..3b688927 100644 --- a/man/plot.bic_obj.Rd +++ b/man/plot.bic_obj.Rd @@ -5,8 +5,9 @@ \title{Plot a BIC obj} \usage{ \method{plot}{bic_obj}(x, colour_map = NULL, colour_range = NULL, - colour_default = "grey", symmetric = FALSE, palette = heat.colors(255), - labels = FALSE, colour_bar = TRUE, add = FALSE, par = list(), ...) + colour_default = "grey", symmetric = FALSE, + palette = heat.colors(255), labels = FALSE, colour_bar = TRUE, + add = FALSE, par = list(), ...) } \arguments{ \item{x}{A \code{bic_obj} probably created by \link{read_obj}} diff --git a/man/qMincApply.Rd b/man/qMincApply.Rd index 4bb87433..747685f1 100644 --- a/man/qMincApply.Rd +++ b/man/qMincApply.Rd @@ -10,13 +10,13 @@ qMincApply(filenames, fun, ..., mask = NULL, batches = 4, tinyMask = FALSE, slab_sizes = NULL, resources = list(), packages = c("RMINC"), registry_dir = getwd(), - registry_name = "qMincApply_registry", temp_dir = getwd(), cores = 1, - wait = TRUE, cleanup = TRUE, clobber = FALSE, collate = simplify2minc, - conf_file = getOption("RMINC_BATCH_CONF")) + registry_name = "qMincApply_registry", temp_dir = getwd(), + cores = 1, wait = TRUE, cleanup = TRUE, clobber = FALSE, + collate = simplify2minc, conf_file = getOption("RMINC_BATCH_CONF")) -qMincRegistry(registry_name = "qMincApply_registry", packages = c("RMINC"), - registry_dir = getwd(), clobber = FALSE, resources = list(), - conf_file = getOption("RMINC_BATCH_CONF")) +qMincRegistry(registry_name = "qMincApply_registry", + packages = c("RMINC"), registry_dir = getwd(), clobber = FALSE, + resources = list(), conf_file = getOption("RMINC_BATCH_CONF")) qMincMap(registry, filenames, fun, ..., mask = NULL, slab_sizes = NULL, batches = 4, tinyMask = FALSE, temp_dir = getwd(), cores = 1) diff --git a/man/runRMINCTestbed.Rd b/man/runRMINCTestbed.Rd index 5fe34951..b548e52e 100644 --- a/man/runRMINCTestbed.Rd +++ b/man/runRMINCTestbed.Rd @@ -4,14 +4,16 @@ \alias{runRMINCTestbed} \title{Run Testbed} \usage{ -runRMINCTestbed(..., dataPath = tempdir(), method = "libcurl", - verboseTest = FALSE) +runRMINCTestbed(..., dataPath = getOption("RMINC_DATA_DIR", tempdir()), + method = "libcurl", verboseTest = FALSE) } \arguments{ \item{...}{additional parameter for \link[testthat]{test_dir}} \item{dataPath}{The directory to download and unpack the test data -(unpacks in dataPath/rminctestdata)} +(unpacks in dataPath/rminctestdata). Default can be set with the option RMINC_DATA_DIR which +can in turn be set with the environment variable RMINC_DATA_DIR. If unset a temporary directory +is created.} \item{method}{Argument to pass to \link{download.file} typical options are \code{libcurl}} diff --git a/man/thresholds.Rd b/man/thresholds.Rd index 836a72fc..4523b193 100644 --- a/man/thresholds.Rd +++ b/man/thresholds.Rd @@ -10,8 +10,8 @@ thresholds(x, ...) \method{thresholds}{mincQvals}(x, ...) -\method{thresholds}{minc_randomization}(x, probs = c(0.01, 0.05, 0.1, 0.2), - ...) +\method{thresholds}{minc_randomization}(x, probs = c(0.01, 0.05, 0.1, + 0.2), ...) } \arguments{ \item{x}{A \code{mincQvals} object, typically computed with \code{mincFDR} or a diff --git a/man/vertexAtlasApply.Rd b/man/vertexAtlasApply.Rd index f0a18e60..e54127f6 100644 --- a/man/vertexAtlasApply.Rd +++ b/man/vertexAtlasApply.Rd @@ -4,8 +4,9 @@ \alias{vertexAtlasApply} \title{Apply a structure summary function across vertices} \usage{ -vertexAtlasApply(filenames, atlas, fun, ..., mask = NULL, parallel = NULL, - collate = simplify_masked, column = 1, atlas_column = 1) +vertexAtlasApply(filenames, atlas, fun, ..., mask = NULL, + parallel = NULL, collate = simplify_masked, column = 1, + atlas_column = 1) } \arguments{ \item{filenames}{vertex file names} diff --git a/man/vertexFindPeaks.Rd b/man/vertexFindPeaks.Rd index 064e2184..22c865a3 100644 --- a/man/vertexFindPeaks.Rd +++ b/man/vertexFindPeaks.Rd @@ -5,7 +5,8 @@ \title{Vertex find peaks} \usage{ vertexFindPeaks(data_map, graph, mindist = 1, direction = c("both", - "positive", "negative"), threshold = 0, output = c("mask", "indices")) + "positive", "negative"), threshold = 0, output = c("mask", + "indices")) } \arguments{ \item{data_map}{A vector or text file of values to search for peaks} diff --git a/man/vertexTFCE.Rd b/man/vertexTFCE.Rd index 55d6173c..c65f7102 100644 --- a/man/vertexTFCE.Rd +++ b/man/vertexTFCE.Rd @@ -10,20 +10,21 @@ \usage{ vertexTFCE(x, ...) -\method{vertexTFCE}{numeric}(x, surface, E = 0.5, H = 2, nsteps = 100, - side = c("both", "positive", "negative"), weights = NULL, ...) +\method{vertexTFCE}{numeric}(x, surface, E = 0.5, H = 2, + nsteps = 100, side = c("both", "positive", "negative"), + weights = NULL, ...) \method{vertexTFCE}{matrix}(x, surface, E = 0.5, H = 2, nsteps = 100, side = c("both", "positive", "negative"), weights = NULL, ...) \method{vertexTFCE}{vertexLm}(x, surface, R = 500, - alternative = c("two.sided", "greater"), E = 0.5, H = 2, nsteps = 100, - weights = NULL, side = c("both", "positive", "negative"), - replace = FALSE, parallel = NULL, ...) + alternative = c("two.sided", "greater"), E = 0.5, H = 2, + nsteps = 100, weights = NULL, side = c("both", "positive", + "negative"), replace = FALSE, parallel = NULL, ...) -\method{vertexTFCE}{character}(x, surface, E = 0.5, H = 2, nsteps = 100, - side = c("both", "positive", "negative"), weights = NULL, column = 1, - ...) +\method{vertexTFCE}{character}(x, surface, E = 0.5, H = 2, + nsteps = 100, side = c("both", "positive", "negative"), + weights = NULL, column = 1, ...) } \arguments{ \item{x}{A numeric vector, a filepath to a set of values, From 1e9d42a496f826dc5cda91be1669af51073bd6fd Mon Sep 17 00:00:00 2001 From: cfhammill Date: Wed, 12 Feb 2020 16:21:41 -0500 Subject: [PATCH 07/31] Allow `civet.readCBrain` to pass `columnsToKeep` to flattener Works around hard-coded columns of interest in `civet.flattenFoDplyr` --- R/civet.R | 4 ++-- man/civet.readCBRAIN.Rd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/civet.R b/R/civet.R index 4760c8bc..b2ef573c 100644 --- a/R/civet.R +++ b/R/civet.R @@ -651,7 +651,7 @@ civet_filenames_2_0_0 <- #' @seealso \link{civet.getAllFilenames} \link{civet.readAllCivetFiles} \link{civet.flattenForDplyr} #' @export civet.readCBRAIN <- - function(path, prefix, subjects = NULL, atlas = "AAL", civetVersion = "2.1.0", readFiles = TRUE, readQC = TRUE, flatten = TRUE, QCDir = "QC"){ + function(path, prefix, subjects = NULL, atlas = "AAL", civetVersion = "2.1.0", readFiles = TRUE, readQC = TRUE, flatten = TRUE, QCDir = "QC", columnsToKeep = "subject"){ ## Check bad arguments if(readQC && readFiles && !flatten) stop("Can't merge QC when readFiles is TRUE and flatten is FALSE") @@ -678,7 +678,7 @@ civet.readCBRAIN <- if(readFiles){ results <- civet.readAllCivetFiles(atlas, results, civetVersion) if(flatten) - results <- civet.flattenForDplyr(results, "subject") + results <- civet.flattenForDplyr(results, columnsToKeep = columnsToKeep) } if(readQC){ diff --git a/man/civet.readCBRAIN.Rd b/man/civet.readCBRAIN.Rd index 24a9b956..0a9a4474 100644 --- a/man/civet.readCBRAIN.Rd +++ b/man/civet.readCBRAIN.Rd @@ -6,7 +6,7 @@ \usage{ civet.readCBRAIN(path, prefix, subjects = NULL, atlas = "AAL", civetVersion = "2.1.0", readFiles = TRUE, readQC = TRUE, - flatten = TRUE, QCDir = "QC") + flatten = TRUE, QCDir = "QC", columnsToKeep = "subject") } \arguments{ \item{path}{Path to the civet project} From 438526465a8b0e5ca250f7b3262078436e1746d3 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Wed, 12 Feb 2020 16:26:11 -0500 Subject: [PATCH 08/31] Add environment variable and option for test data Resolves #272 --- R/RMINC.R | 4 +++- R/minc_interface.R | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/R/RMINC.R b/R/RMINC.R index aa5ebc35..e402d507 100644 --- a/R/RMINC.R +++ b/R/RMINC.R @@ -88,11 +88,13 @@ NULL RMINC_MASKED_VALUE = structure(0, class = "RMINC_MASKED_VALUE") , RMINC_LABEL_DEFINITIONS = - empty_to_null(Sys.getenv("RMINC_LABEL_DEFINITIONS")) + empty_to_null(Sys.getenv("RMINC_LABEL_DEFINITIONS")) , RMINC_BATCH_CONF = `if`(Sys.getenv("RMINC_BATCH_CONF") == "" , system.file("parallel/pbs_batchtools.R", package = "RMINC") , Sys.getenv("RMINC_BATCH_CONF")) + , RMINC_DATA_DIR = + empty_to_null(Sys.getenv("RMINC_DATA_DIR")) ) toset <- !(names(op.RMINC) %in% names(op)) diff --git a/R/minc_interface.R b/R/minc_interface.R index b61407ec..4ef3888a 100644 --- a/R/minc_interface.R +++ b/R/minc_interface.R @@ -1234,12 +1234,14 @@ setNaN <- function(x, val){ x[is.nan(x)] <- val; x} #' Whether or not to verbosely print test output, default is #' to print simplified results #' @param dataPath The directory to download and unpack the test data -#' (unpacks in dataPath/rminctestdata) +#' (unpacks in dataPath/rminctestdata). Default can be set with the option RMINC_DATA_DIR which +#' can in turn be set with the environment variable RMINC_DATA_DIR. If unset a temporary directory +#' is created. #' @param method Argument to pass to \link{download.file} typical options are \code{libcurl} #' @param ... additional parameter for \link[testthat]{test_dir} #' @return invisibly return the test results #' @export -runRMINCTestbed <- function(..., dataPath = tempdir(), method = "libcurl", verboseTest = FALSE) { +runRMINCTestbed <- function(..., dataPath = getOption("RMINC_DATA_DIR", tempdir()), method = "libcurl", verboseTest = FALSE) { original_opts <- options() old_env_vars <- Sys.getenv(c("TEST_Q_MINC", "NOT_CRAN", "TRAVIS")) @@ -1276,11 +1278,13 @@ runRMINCTestbed <- function(..., dataPath = tempdir(), method = "libcurl", verbo #' The data can be downloaded manually from #' \url{https://wiki.mouseimaging.ca/download/attachments/1654/rminctestdata.tar.gz} #' @param dataPath The directory to download and unpack the test data -#' (unpacks in dataPath/rminctestdata) +#' (unpacks in dataPath/rminctestdata). Default can be set with the option RMINC_DATA_DIR which +#' can in turn be set with the environment variable RMINC_DATA_DIR. If unset a temporary directory +#' is created. #' @param method Argument to pass to \link{download.file} typical options are \code{libcurl} #' and \code{wget} #' @export -getRMINCTestData <- function(dataPath = tempdir(), method = "libcurl") { +getRMINCTestData <- function(dataPath = getOption("RMINC_DATA_DIR", tempdir()), method = "libcurl") { downloadPath <- file.path(dataPath, "rminctestdata.tar.gz") extractedPath <- file.path(dataPath, "rminctestdata/") From 1e96d259178cdcd87655e7630e59d7645f4664d0 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Wed, 12 Feb 2020 16:40:47 -0500 Subject: [PATCH 09/31] Upgrade bioconductor dependency Should partially fix the travis build on mac. --- .travis.yml | 2 -- DESCRIPTION | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d205cc7c..76943c89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,5 +26,3 @@ before_install: | source /opt/minc/1.9.16/minc-toolkit-config.sh fi -repos: - bioCsoft: http://bioconductor.org/packages/3.8/bioc diff --git a/DESCRIPTION b/DESCRIPTION index 89f26ad1..9e42de37 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,7 +11,7 @@ Authors@R: c(person("Jason", "Lerch", role = "aut", email = "jason.lerch@sickkid person("Miriam", "Friedel", role = "ctb")) Description: Tools for reading, writing, analyzing, and visualizing Medical Imaging NetCDF (MINC) files with R. -Additional_repositories: http://bioconductor.org/packages/3.6/bioc +Additional_repositories: http://bioconductor.org/packages/3.10/bioc Depends: R (>= 3.2) Imports: From 210f3cc167c20741209055d983ee51a878bb7c1a Mon Sep 17 00:00:00 2001 From: cfhammill Date: Wed, 12 Feb 2020 17:27:57 -0500 Subject: [PATCH 10/31] Fix broken FDR selector and spurious % in shinyRMINC Fixes #270 --- etc/shiny_testing.R | 16 ++++++++++++++++ inst/shinyRMINC/server.R | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 etc/shiny_testing.R diff --git a/etc/shiny_testing.R b/etc/shiny_testing.R new file mode 100644 index 00000000..99e95e61 --- /dev/null +++ b/etc/shiny_testing.R @@ -0,0 +1,16 @@ +#/hpf/largeprojects/MICe/matthijs/2016-06-Boughner-embryos/2017-03-TFCE + +library(RMINC) + +gfE14.0 <- read.csv("/hpf/largeprojects/MICe/matthijs/2016-06-Boughner-embryos/Boughner-to-E14.0_analysis/filename_mapping.csv") +gfE14.0_no_outlier <- gfE14.0[-c(8),] +gfE14.0_no_outlier$abs_jac_fwhm0.2 <- sub(".mnc", "_fwhm0.2.mnc", gfE14.0_no_outlier$abs_jac_no_blur) +gfE14.0_no_outlier$rel_jac_fwhm0.2 <- sub("_with_additional_inverted_absolute", "_inverted_pure_nlin_relative", gfE14.0_no_outlier$abs_jac_fwhm0.2) + +vs <- mincLm(rel_jac_fwhm0.2 ~ genotype, gfE14.0_no_outlier + , mask="/hpf/largeprojects/MICe/matthijs/2016-06-Boughner-embryos/Boughner-to-E14.0/minctracc_nlin/minctracc-nlin-6_rough_mask_fix_zyx.mnc") + +vs_fdr <- mincFDR(vs) +ex <- mincGetVolume(gfE14.0$abs_jac_no_blur[1]) +options("shiny.port" = 8000) +launch_shinyRMINC(vs, mincArray(ex), fdr = vs_fdr) diff --git a/inst/shinyRMINC/server.R b/inst/shinyRMINC/server.R index 6521f95b..520ede54 100644 --- a/inst/shinyRMINC/server.R +++ b/inst/shinyRMINC/server.R @@ -202,14 +202,14 @@ shinyServer(function(input, output, clientData, session) { , c("none" , paste(rownames(tholds), sprintf("%.3f", tholds[,input$statistic]) - , sep = "% - ")) + , sep = " - ")) , selected = "none") }) observeEvent(input$fdr_thresh, { if(!is.null(fdr) && input$fdr_thresh != "none"){ - thresh <- sub("% - .*", "", input$fdr_thresh) - updateSliderInput(session, "high", value = tholds[thresh, input$statistic]) + thresh <- sub(" - .*", "", input$fdr_thresh) + updateSliderInput(session, "range", value = c(tholds[thresh, input$statistic], input$range[2])) } }) From 00e3e0546796e50bfdfdcb514670870aa2b8918f Mon Sep 17 00:00:00 2001 From: cfhammill Date: Wed, 12 Feb 2020 17:30:52 -0500 Subject: [PATCH 11/31] Remove suggests BiocInstaller This has been replaced by BiocManager, https://support.bioconductor.org/p/126377/#126379 I don't think it's necessary anyway. --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9e42de37..1d04d5da 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -43,7 +43,6 @@ Suggests: rgl, plotrix, lmerTest, - BiocInstaller, qvalue, testthat, igraph From 5a9d7a11ae715731b0f13bde6e74ebd1d6fa6453 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Wed, 12 Feb 2020 18:16:56 -0500 Subject: [PATCH 12/31] Attempt to fix travis build on mac For some reason the dependencies are getting build out of order on mac - rgl depends on digest but rgl is built first. The commit attempts to build digest first --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76943c89..89214e8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,13 +16,11 @@ before_install: | fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - ## brew install gcc - ## mkdir $HOME/.R/; touch $HOME/.R/Makevars - ## echo 'FLIBS=-L/usr/local/Cellar/gcc/5.3.0/lib/gcc/5' > $HOME/.R/Makevars (cd ../ ; wget http://packages.bic.mni.mcgill.ca/minc-toolkit/MacOSX/minc-toolkit-1.9.16-20180117-Darwin-10.8-x86_64.dmg) sudo hdiutil attach ../minc-toolkit-1.9.16-20180117-Darwin-10.8-x86_64.dmg sudo installer -package /Volumes/minc-toolkit-1.9.16-20180117-Darwin-x86_64/minc-toolkit-1.9.16-20180117-Darwin-x86_64.pkg -target / source /opt/minc/1.9.16/minc-toolkit-config.sh + Rscript -e "install.packages('digest')" fi From fe685205003879f7e3b4a32be17bed316d58e753 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 21 Feb 2020 11:35:34 -0500 Subject: [PATCH 13/31] [WIP] Add experimental mincTable function with file backing Partially solves #271 --- R/minc_interface.R | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/R/minc_interface.R b/R/minc_interface.R index 4ef3888a..fb3f23f6 100644 --- a/R/minc_interface.R +++ b/R/minc_interface.R @@ -889,6 +889,58 @@ mincGetMask <- function(mask) { } +#' Read a collection of minc volumes +#' +#' This reads a collection of `mincVolumes` into an optionally file-backed matrix +#' @param filenames A character vector of minc filenames. All minc files must have the +#' same shape. +#' @param mask Either a character vector with a path to a mask file, a mincVolume, or a +#' numeric/logical vector indicating which voxels to include in the table. +#' @param file_backed logical, whether to use a file backed matrix for storing the table. +#' @param ... Additional arguments to `bigstatr::FBM` +#' @return If `file_backed` is `FALSE` return a matrix with ncol equal to the number of files. +#' The number of rows is either the product of the volume dimensions, or if a mask is supplied, +#' the number of voxels where the mask > 0.5. If `file_backed` is `TRUE` return an `FBM` object +#' from the `bigstatr` package. +#' @export +mincTable <- function(filenames, mask = NULL, file_backed = FALSE, ...){ + mask <- mincGetMask(filenames) + nfiles <- length(mask) + sizes <- lapply(c(mask, filenames), minc.dimensions.sizes) + not_equals_first <- sapply(sizes, function(s) s != sizes[[1]]) + + if(any(not_equals_first)){ + stop("Some minc files supplied to mincTable are the wrong size:\n" + , paste(files[not_equals_first], collapse = ", ") + , "\n These don't match the reference volume:\n" + , filesnames[1]) + } + + if(!is.null(mask)){ + mask_vol <- mincGetMask(mask) + nvox <- sum(mask_vol > 0.5) + } else { + mask_vol <- NULL + nvox <- prod(sizes[[1]]) + } + + if(file_backed){ + outmat <- bigstatsr::FBM(nrow = nvox, ncol = nfiles, ...) + } else { + outmat <- matrix(nrow = nvox, ncol = nfiles) + } + + for(i in seq_len(nfiles)){ + vol <- mincGetVolume(filnames[i]) + if(!is.null(mask_vol)) + vol <- vol[mask_vol > 0.5] + + outmat[,i] <- vol + } + + outmat +} + # create a 2D array of full volumes of all files specified. minc.get.volumes <- function(filenames) { sizes <- minc.dimensions.sizes(filenames[1]) From bf7d623fd57b207c174bf13108c41c6a8c62b604 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 21 Feb 2020 13:15:16 -0500 Subject: [PATCH 14/31] Working version of mincTable Complete with tests and functional file backing. --- DESCRIPTION | 3 ++- NAMESPACE | 1 + R/minc_interface.R | 27 ++++++++++++++++----------- inst/user_tests/test_mincTable.R | 1 + man/mincTable.Rd | 28 ++++++++++++++++++++++++++++ tests/testthat/test_mincTable.R | 30 ++++++++++++++++++++++++++++++ 6 files changed, 78 insertions(+), 12 deletions(-) create mode 120000 inst/user_tests/test_mincTable.R create mode 100644 man/mincTable.Rd create mode 100644 tests/testthat/test_mincTable.R diff --git a/DESCRIPTION b/DESCRIPTION index 1d04d5da..b146065b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,7 +38,8 @@ Imports: visNetwork (>= 2.0.4), rjson (>= 0.2.20), DT (>= 0.4), - rlang (>= 0.2.1) + rlang (>= 0.2.1), + bigstatsr Suggests: rgl, plotrix, diff --git a/NAMESPACE b/NAMESPACE index 01426338..788d7f92 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -179,6 +179,7 @@ export(mincSelectRandomVoxels) export(mincSum) export(mincSummary) export(mincTFCE) +export(mincTable) export(mincTriplanarSlicePlot) export(mincTtest) export(mincVar) diff --git a/R/minc_interface.R b/R/minc_interface.R index fb3f23f6..0bed5f5e 100644 --- a/R/minc_interface.R +++ b/R/minc_interface.R @@ -880,7 +880,7 @@ pt2 <- function(q, df,log.p=FALSE) { #' @param mask Either the path to a mask file or a numeric vector representing the mask #' @return a numeric mask vector mincGetMask <- function(mask) { - if (class(mask) == "character") { + if (inherits(mask, "character")) { return(mincGetVolume(mask)) } else { @@ -904,24 +904,28 @@ mincGetMask <- function(mask) { #' from the `bigstatr` package. #' @export mincTable <- function(filenames, mask = NULL, file_backed = FALSE, ...){ - mask <- mincGetMask(filenames) - nfiles <- length(mask) - sizes <- lapply(c(mask, filenames), minc.dimensions.sizes) + + nfiles <- length(filenames) + sizes <- lapply(filenames, minc.dimensions.sizes) + total_vox <- prod(sizes[[1]]) not_equals_first <- sapply(sizes, function(s) s != sizes[[1]]) if(any(not_equals_first)){ stop("Some minc files supplied to mincTable are the wrong size:\n" - , paste(files[not_equals_first], collapse = ", ") + , paste(filenames[not_equals_first], collapse = ", ") , "\n These don't match the reference volume:\n" - , filesnames[1]) + , filenames[1]) } if(!is.null(mask)){ - mask_vol <- mincGetMask(mask) - nvox <- sum(mask_vol > 0.5) + mask_vol <- mincGetMask(mask) > 0.5 + if(length(mask_vol) != total_vox) + stop("Your mask is not the same size as your input files, ensure it has" + , "the same dimensions as ", filenames[1]) + nvox <- sum(mask_vol) } else { mask_vol <- NULL - nvox <- prod(sizes[[1]]) + nvox <- total_vox } if(file_backed){ @@ -930,10 +934,11 @@ mincTable <- function(filenames, mask = NULL, file_backed = FALSE, ...){ outmat <- matrix(nrow = nvox, ncol = nfiles) } + for(i in seq_len(nfiles)){ - vol <- mincGetVolume(filnames[i]) + vol <- mincGetVolume(filenames[i]) if(!is.null(mask_vol)) - vol <- vol[mask_vol > 0.5] + vol <- vol[mask_vol] outmat[,i] <- vol } diff --git a/inst/user_tests/test_mincTable.R b/inst/user_tests/test_mincTable.R new file mode 120000 index 00000000..8840a2ca --- /dev/null +++ b/inst/user_tests/test_mincTable.R @@ -0,0 +1 @@ +tests/testthat/test_mincTable.R \ No newline at end of file diff --git a/man/mincTable.Rd b/man/mincTable.Rd new file mode 100644 index 00000000..59f39031 --- /dev/null +++ b/man/mincTable.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/minc_interface.R +\name{mincTable} +\alias{mincTable} +\title{Read a collection of minc volumes} +\usage{ +mincTable(filenames, mask = NULL, file_backed = FALSE, ...) +} +\arguments{ +\item{filenames}{A character vector of minc filenames. All minc files must have the +same shape.} + +\item{mask}{Either a character vector with a path to a mask file, a mincVolume, or a +numeric/logical vector indicating which voxels to include in the table.} + +\item{file_backed}{logical, whether to use a file backed matrix for storing the table.} + +\item{...}{Additional arguments to `bigstatr::FBM`} +} +\value{ +If `file_backed` is `FALSE` return a matrix with ncol equal to the number of files. +The number of rows is either the product of the volume dimensions, or if a mask is supplied, +the number of voxels where the mask > 0.5. If `file_backed` is `TRUE` return an `FBM` object +from the `bigstatr` package. +} +\description{ +This reads a collection of `mincVolumes` into an optionally file-backed matrix +} diff --git a/tests/testthat/test_mincTable.R b/tests/testthat/test_mincTable.R new file mode 100644 index 00000000..c4305e71 --- /dev/null +++ b/tests/testthat/test_mincTable.R @@ -0,0 +1,30 @@ +library(testthat) +context("mincTable") + +if(!exists("dataPath")) + dataPath <- tempdir() + +getRMINCTestData(dataPath) +dataPath <- file.path(dataPath, "rminctestdata/") + +gf <- read.csv(file.path(dataPath, "test_data_set.csv")) +maskfile <- file.path(dataPath, "testminc-mask.mnc") + +ref <- sapply(gf$jacobians_fixed, function(f) mincGetVolume(f)) +ref_masked <- ref[mincGetVolume(maskfile) > 0.5,] + +mt <- mincTable(gf$jacobians_fixed) +mt_masked <- mincTable(gf$jacobians_fixed, mask = maskfile) + +mt_back <- mincTable(gf$jacobians_fixed, file_backed = TRUE) +mt_back_masked <- mincTable(gf$jacobians_fixed, mask = maskfile, file_backed = TRUE) + +test_that("Unmasked mincTable works", { + expect_equal(ref, mt) + expect_equal(ref, mt_back[,]) +}) + +test_that("Masked mincTable works", { + expect_equal(ref_masked, mt_masked) + expect_equal(ref_masked, mt_back_masked[,]) +}) From 6e01f054fa6d5ad676d7b09bc8a633567b834c1c Mon Sep 17 00:00:00 2001 From: cfhammill Date: Thu, 27 Feb 2020 16:32:37 -0500 Subject: [PATCH 15/31] [INFRA] Add tmp/ to Rbuildignore Handy for storing transient files, doesn't belong in the build tarballs. --- .Rbuildignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.Rbuildignore b/.Rbuildignore index 926cd45d..ddb058d3 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -14,3 +14,4 @@ ^_config.yml$ ^_pkgdown\.yml$ ^docs$ +^tmp/.*$ \ No newline at end of file From 48aa3ad3e9b4a1455d3e1dae5663afd411bc5fa1 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Thu, 27 Feb 2020 16:35:33 -0500 Subject: [PATCH 16/31] [FIX] Remove all deprecated underscore verbs At least the ones throwing warnings in our tests. See #273 --- R/civet.R | 144 +++++++++++++++++---------------------- R/minc_anatomy.R | 53 +++++++------- R/minc_interface.R | 6 +- R/minc_lmer.R | 8 +-- R/minc_model_selection.R | 8 +-- 5 files changed, 98 insertions(+), 121 deletions(-) diff --git a/R/civet.R b/R/civet.R index b2ef573c..5ebd4ff7 100644 --- a/R/civet.R +++ b/R/civet.R @@ -589,42 +589,41 @@ civet_filenames_2_0_0 <- thickness_method <- last(cnf$thickness_method) #not sure why config produces a vector of length two here thickness_dist <- cnf$thickness_kernel atlas <- cnf$atlas - + gf %>% - mutate_( #very iritating R CMD check can't handle dplyr code... - subject_prefixed = ~paste0(prefix, gf[,idvar]) - , subject_path = ~file.path(basedir, gf[,idvar]) - , leftGIFiles = ~sprintf("%s/surfaces/%s_gi_left.dat", subject_path, subject_prefixed) - , rightGIFiles = ~sprintf("%s/surfaces/%s_gi_right.dat", subject_path, subject_prefixed) - - , leftlobeArea40mmFiles = ~sprintf("%s/surfaces/%s_%s_lobe_areas_40mm_left.dat", subject_path, subject_prefixed, atlas) - , rightlobeArea40mmFiles = ~sprintf("%s/surfaces/%s_%s_lobe_areas_40mm_right.dat", subject_path, subject_prefixed, atlas) + mutate( #very iritating R CMD check can't handle dplyr code... + subject_prefixed = paste0(prefix, gf[,idvar]) + , subject_path = file.path(basedir, gf[,idvar]) + , leftGIFiles = sprintf("%s/surfaces/%s_gi_left.dat", .data$subject_path, .data$subject_prefixed) + , rightGIFiles = sprintf("%s/surfaces/%s_gi_right.dat", .data$subject_path, .data$subject_prefixed) + , leftlobeArea40mmFiles = sprintf("%s/surfaces/%s_%s_lobe_areas_40mm_left.dat", .data$subject_path, .data$subject_prefixed, atlas) + , rightlobeArea40mmFiles = sprintf("%s/surfaces/%s_%s_lobe_areas_40mm_right.dat", .data$subject_path, .data$subject_prefixed, atlas) - , leftlobeThicknessFiles = ~sprintf("%s/surfaces/%s_%s_lobe_thickness_%s_%smm_left.dat", subject_path , subject_prefixed, atlas, thickness_method, thickness_dist) - , rightlobeThicknessFiles = ~sprintf("%s/surfaces/%s_%s_lobe_thickness_%s_%smm_right.dat", subject_path , subject_prefixed, atlas, thickness_method, thickness_dist) + , leftlobeThicknessFiles = sprintf("%s/surfaces/%s_%s_lobe_thickness_%s_%smm_left.dat", .data$subject_path , .data$subject_prefixed, atlas, thickness_method, thickness_dist) + , rightlobeThicknessFiles = sprintf("%s/surfaces/%s_%s_lobe_thickness_%s_%smm_right.dat", .data$subject_path , .data$subject_prefixed, atlas, thickness_method, thickness_dist) - , leftlobeVolumeFiles = ~sprintf("%s/surfaces/%s_%s_lobe_volumes_40mm_left.dat", subject_path, subject_prefixed, atlas) - , rightlobeVolumeFiles = ~sprintf("%s/surfaces/%s_%s_lobe_volumes_40mm_right.dat", subject_path, subject_prefixed, atlas) + , leftlobeVolumeFiles = sprintf("%s/surfaces/%s_%s_lobe_volumes_40mm_left.dat", .data$subject_path, .data$subject_prefixed, atlas) + , rightlobeVolumeFiles = sprintf("%s/surfaces/%s_%s_lobe_volumes_40mm_right.dat", .data$subject_path, .data$subject_prefixed, atlas) - , midSurfaceleftNativeArea = ~sprintf("%s/surfaces/%s_mid_surface_rsl_left_native_area_40mm.txt", subject_path, subject_prefixed) - , midSurfacerightNativeArea = ~sprintf("%s/surfaces/%s_mid_surface_rsl_right_native_area_40mm.txt", subject_path, subject_prefixed) + , midSurfaceleftNativeArea = sprintf("%s/surfaces/%s_mid_surface_rsl_left_native_area_40mm.txt", .data$subject_path, .data$subject_prefixed) + , midSurfacerightNativeArea = sprintf("%s/surfaces/%s_mid_surface_rsl_right_native_area_40mm.txt", .data$subject_path, .data$subject_prefixed) - , SurfaceleftNativeVolume = ~sprintf("%s/surfaces/%s_surface_rsl_left_native_volume_40mm.txt", subject_path, subject_prefixed) - , SurfacerightNativeVolume = ~sprintf("%s/surfaces/%s_surface_rsl_right_native_volume_40mm.txt", subject_path, subject_prefixed) + , SurfaceleftNativeVolume = sprintf("%s/surfaces/%s_surface_rsl_left_native_volume_40mm.txt", .data$subject_path, .data$subject_prefixed) + , SurfacerightNativeVolume = sprintf("%s/surfaces/%s_surface_rsl_right_native_volume_40mm.txt", .data$subject_path, .data$subject_prefixed) - , brain_volume = ~sprintf("%s/classify/%s_cls_volumes.dat", subject_path , subject_prefixed) - , cerebral_volume = ~sprintf("%s/thickness/%s_cerebral_volume.dat", subject_path , subject_prefixed) + , brain_volume = sprintf("%s/classify/%s_cls_volumes.dat", .data$subject_path , .data$subject_prefixed) + , cerebral_volume = sprintf("%s/thickness/%s_cerebral_volume.dat", .data$subject_path , .data$subject_prefixed) - , nativeRMS_RSLtlink_left = ~sprintf("%s/thickness/%s_native_rms_rsl_%s_%smm_left.txt", subject_path, subject_prefixed, thickness_method, thickness_dist) - , nativeRMS_RSLtlink_right = ~sprintf("%s/thickness/%s_native_rms_rsl_%s_%smm_right.txt", subject_path, subject_prefixed,thickness_method, thickness_dist) + , nativeRMS_RSLtlink_left = sprintf("%s/thickness/%s_native_rms_rsl_%s_%smm_left.txt", .data$subject_path, .data$subject_prefixed, thickness_method, thickness_dist) + , nativeRMS_RSLtlink_right = sprintf("%s/thickness/%s_native_rms_rsl_%s_%smm_right.txt", .data$subject_path, .data$subject_prefixed,thickness_method, thickness_dist) - , nativeRMStlink_left = ~sprintf("%s/thickness/%s_native_rms_rsl_%s_%smm_left.txt", subject_path , subject_prefixed, thickness_method, thickness_dist) - , nativeRMStlink_right = ~sprintf("%s/thickness/%s_native_rms_rsl_%s_%smm_right.txt", subject_path , subject_prefixed, thickness_method, thickness_dist) + , nativeRMStlink_left = sprintf("%s/thickness/%s_native_rms_rsl_%s_%smm_left.txt", .data$subject_path , .data$subject_prefixed, thickness_method, thickness_dist) + , nativeRMStlink_right = sprintf("%s/thickness/%s_native_rms_rsl_%s_%smm_right.txt", .data$subject_path , .data$subject_prefixed, thickness_method, thickness_dist) - , RSL_mean_curvature_left = ~sprintf("%s/curvature/%s_mid_surface_rsl_left_mean_curv_%smm.txt", subject_path , subject_prefixed, thickness_dist) - , RSL_mean_curvature_right = ~sprintf("%s/curvature/%s_mid_surface_rsl_right_mean_curv_%smm.txt", subject_path , subject_prefixed, thickness_dist) - , RSL_gaus_curvature_left = ~sprintf("%s/curvature/%s_mid_surface_rsl_left_gaus_curv_%smm.txt", subject_path , subject_prefixed, thickness_dist) - , RSL_gaus_curvature_right = ~sprintf("%s/curvature/%s_mid_surface_rsl_right_gaus_curv_%smm.txt", subject_path , subject_prefixed, thickness_dist) + , RSL_mean_curvature_left = sprintf("%s/curvature/%s_mid_surface_rsl_left_mean_curv_%smm.txt", .data$subject_path , .data$subject_prefixed, thickness_dist) + , RSL_mean_curvature_right = sprintf("%s/curvature/%s_mid_surface_rsl_right_mean_curv_%smm.txt", .data$subject_path , .data$subject_prefixed, thickness_dist) + , RSL_gaus_curvature_left = sprintf("%s/curvature/%s_mid_surface_rsl_left_gaus_curv_%smm.txt", .data$subject_path , .data$subject_prefixed, thickness_dist) + , RSL_gaus_curvature_right = sprintf("%s/curvature/%s_mid_surface_rsl_right_gaus_curv_%smm.txt", .data$subject_path , .data$subject_prefixed, thickness_dist) ) } @@ -747,6 +746,7 @@ civet.vertexFilenames <- #' @export civet.vertexTable <- function(vertex_files){ columns_to_collect <- setdiff(names(vertex_files), "ids") + column_syms <- lapply(columns_to_collect, as.symbol) n_vertices <- getElement(vertex_files, columns_to_collect[1]) %>% @@ -763,9 +763,9 @@ civet.vertexTable <- function(vertex_files){ vertex_files %>% - gather_("measure", "file", columns_to_collect) %>% - mutate_(vertex_data = ~ lapply(file, read_or_NAs)) %>% - arrange_(~ ids) %>% + gather("measure", "file", !!!column_syms) %>% + mutate(vertex_data = lapply(.data$file, read_or_NAs)) %>% + arrange(.data$ids) %>% split(.$measure) %>% lapply(function(df){ unlist(df$vertex_data) %>% @@ -867,7 +867,7 @@ civet.organizeCivetDatFilesAtlas <- function(atlasFile,dataFiles, civetVersion=" } if(file.exists(dataFiles[j])) { - data_file <- read.table(dataFiles[j]) %>% filter_(~ V1 != "Total") + data_file <- read.table(dataFiles[j]) %>% filter(.data$V1 != "Total") labels <- data_file$V1 value <- data_file$V2 labels = as.numeric(as.character(labels)) @@ -1713,16 +1713,16 @@ civet_qc_1_1_12 <- "SRRight", "SSLeft", "SSRight", "MeanCTLeft", "MeanCTRight", "MeanWM-T1", "StdDevWM-T1", "MeanGM-T1", "StdDevGM-T1", "GIleft", "GIright", "GIfull")) %>% - mutate_( - CSFcls_score = ~ ifelse(between(CSFcls, 15, 80), "good", "med"), - GMcls_score = ~ ifelse(between(GMcls, 15, 80), "good", "med"), - WMcls_score = ~ ifelse(between(WMcls, 15, 80), "good", "med"), - WMsurf_score = ~ good_med_bad(WMsurf, 10, 20), - GMsurf_score = ~ good_med_bad(GMsurf, 10, 20), - SRLeft_score = ~ good_med_bad(SRLeft, 250, 500), - SRRight_score = ~ good_med_bad(SRRight, 250, 500), - SSLeft_score = ~ good_med_bad(SSLeft, 250, 500), - SSRight_score = ~ good_med_bad(SSRight, 250, 500) + mutate( + CSFcls_score = ifelse(between(.data$CSFcls, 15, 80), "good", "med"), + GMcls_score = ifelse(between(.data$GMcls, 15, 80), "good", "med"), + WMcls_score = ifelse(between(.data$WMcls, 15, 80), "good", "med"), + WMsurf_score = good_med_bad(.data$WMsurf, 10, 20), + GMsurf_score = good_med_bad(.data$GMsurf, 10, 20), + SRLeft_score = good_med_bad(.data$SRLeft, 250, 500), + SRRight_score = good_med_bad(.data$SRRight, 250, 500), + SSLeft_score = good_med_bad(.data$SSLeft, 250, 500), + SSRight_score = good_med_bad(.data$SSRight, 250, 500) ) %>% cbind( rowwise(.) %>% @@ -1732,7 +1732,7 @@ civet_qc_1_1_12 <- unlist %>% `!=`("bad") %>% all) %>% - mutate_(QC_PASS = ~ unlist(QC_PASS)) + mutate(QC_PASS = unlist(.$dataQC_PASS)) ) } @@ -1774,14 +1774,14 @@ civet_qc_2_0_0 <- setNames(readLines(qc_file, n = 1) %>% strsplit(., ",") %>% first) qc_res %>% - mutate_(mask_score = ~ rate_one_sided(MASK_ERROR) - , CSFcls_score = ~ rate_symmetric(CSF_PERCENT) - , GMcls_score = ~ rate_symmetric(GM_PERCENT) - , WMcls_score = ~ rate_symmetric(WM_PERCENT) - , SRLeft_score = ~ rate_cutoffs(LEFT_INTER, 50, 100) - , SRRight_score = ~ rate_cutoffs(RIGHT_INTER, 50, 100) - , SSLeft_score = ~ rate_cutoffs(LEFT_SURF_SURF, 50, 100) - , SSRight_score = ~ rate_cutoffs(RIGHT_SURF_SURF, 50, 100) + mutate(mask_score = rate_one_sided(.data$MASK_ERROR) + , CSFcls_score = rate_symmetric(.data$CSF_PERCENT) + , GMcls_score = rate_symmetric(.data$GM_PERCENT) + , WMcls_score = rate_symmetric(.data$WM_PERCENT) + , SRLeft_score = rate_cutoffs(.data$LEFT_INTER, 50, 100) + , SRRight_score = rate_cutoffs(.data$RIGHT_INTER, 50, 100) + , SSLeft_score = rate_cutoffs(.data$LEFT_SURF_SURF, 50, 100) + , SSRight_score = rate_cutoffs(.data$RIGHT_SURF_SURF, 50, 100) ) %>% cbind( rowwise(.) %>% @@ -1791,31 +1791,9 @@ civet_qc_2_0_0 <- unlist %>% `!=`("bad") %>% all) %>% - mutate_(QC_PASS = ~ unlist(QC_PASS)) + mutate(QC_PASS = unlist(.data$QC_PASS)) ) - - - # qc_res %>% - # mutate_(mask_score = ~ ifelse(MASK_ERROR > 15, "bad", "good") - # , CSFcls_score = ~ ifelse(CSF_PERCENT > 19, "bad", "good") - # , GMcls_score = ~ ifelse(GM_PERCENT < 45, "bad", "good") - # , WMcls_score = ~ ifelse(WM_PERCENT > 38, "bad", "good") - # , SRLeft_score = ~ good_med_bad(LEFT_INTER, 250, 500) - # , SRRight_score = ~ good_med_bad(RIGHT_INTER, 250, 500) - # , SSLeft_score = ~ good_med_bad(LEFT_SURF_SURF, 250, 500) - # , SSRight_score = ~ good_med_bad(RIGHT_SURF_SURF, 250, 500) - # ) %>% - # cbind( - # rowwise(.) %>% - # do(QC_PASS = - # as_data_frame(.) %>% - # select(matches("_score")) %>% - # unlist %>% - # `!=`("bad") %>% - # all) %>% - # mutate_(QC_PASS = ~ unlist(QC_PASS)) - # ) - } + } civet_qc_2_1_0 <- function(dir){ @@ -1839,14 +1817,14 @@ civet_qc_2_1_0 <- read.csv(qc_file, stringsAsFactors = FALSE) qc_res %>% - mutate_(mask_score = ~ rate_one_sided(MASK_ERROR) - , CSFcls_score = ~ rate_symmetric(CSF_PERCENT) - , GMcls_score = ~ rate_symmetric(GM_PERCENT) - , WMcls_score = ~ rate_symmetric(WM_PERCENT) - , SRLeft_score = ~ rate_cutoffs(LEFT_INTER, 50, 100) - , SRRight_score = ~ rate_cutoffs(RIGHT_INTER, 50, 100) - , SSLeft_score = ~ rate_cutoffs(LEFT_SURF_SURF, 50, 100) - , SSRight_score = ~ rate_cutoffs(RIGHT_SURF_SURF, 50, 100) + mutate(mask_score = rate_one_sided(.data$MASK_ERROR) + , CSFcls_score = rate_symmetric(.data$CSF_PERCENT) + , GMcls_score = rate_symmetric(.data$GM_PERCENT) + , WMcls_score = rate_symmetric(.data$WM_PERCENT) + , SRLeft_score = rate_cutoffs(.data$LEFT_INTER, 50, 100) + , SRRight_score = rate_cutoffs(.data$RIGHT_INTER, 50, 100) + , SSLeft_score = rate_cutoffs(.data$LEFT_SURF_SURF, 50, 100) + , SSRight_score = rate_cutoffs(.data$RIGHT_SURF_SURF, 50, 100) ) %>% cbind( rowwise(.) %>% @@ -1856,6 +1834,6 @@ civet_qc_2_1_0 <- unlist %>% `!=`("bad") %>% all) %>% - mutate_(QC_PASS = ~ unlist(QC_PASS)) + mutate(QC_PASS = unlist(.data$QC_PASS)) ) } diff --git a/R/minc_anatomy.R b/R/minc_anatomy.R index 9bef7f2b..6499ae53 100644 --- a/R/minc_anatomy.R +++ b/R/minc_anatomy.R @@ -304,33 +304,32 @@ create_labels_frame <- label_defs %>% mutate(both_sides = .data$right.label == .data$left.label) %>% gather("hemisphere", "label", c("right.label", "left.label")) %>% - mutate_(Structure = - ~ ifelse(both_sides - , Structure - , ifelse(hemisphere == "right.label" - , paste0("right ", Structure) - , paste0("left ", Structure)))) + mutate(Structure = + ifelse(.data$both_sides + , .data$Structure + , ifelse(.data$hemisphere == "right.label" + , paste0("right ", .data$Structure) + , paste0("left ", .data$Structure)))) if("hierarchy" %in% names(label_defs)) label_defs <- label_defs %>% - mutate_(hierarchy = - ~ with(. - , case_when(is.na(hierarchy) | hierarchy == "" ~ "" - , both_sides ~ hierarchy - , hemisphere == "right.label" ~ paste0("right ", hierarchy) - , hemisphere == "left.label" ~ paste0("left ", hierarchy)))) + mutate(hierarchy = + case_when(is.na(.data$hierarchy) | .data$hierarchy == "" ~ "" + , both_sides ~ hierarchy + , .data$hemisphere == "right.label" ~ paste0("right ", .data$hierarchy) + , .data$hemisphere == "left.label" ~ paste0("left ", .data$hierarchy))) label_defs <- switch(side - , left = filter_(label_defs, ~ both_sides | hemisphere == "left.label") - , right = filter_(label_defs, ~ both_sides | hemisphere == "right.label") - , both = label_defs) + , left = filter(label_defs, .data$both_sides | .data$hemisphere == "left.label") + , right = filter(label_defs, .data$both_sides | .data$hemisphere == "right.label") + , both = label_defs) label_defs <- label_defs %>% - select_(~ -c(hemisphere, both_sides)) %>% - filter_(~ ! duplicated(label)) + select(-c(.data$hemisphere, .data$both_sides)) %>% + filter(! duplicated(.data$label)) label_defs } @@ -347,7 +346,7 @@ create_anat_results <- as.data.frame(results) %>% slice(-1) %>% #removes the zero label mutate(indices = 1:n()) %>% - filter_(~ ! missing_labels[-1]) %>% + filter(! .data$missing_labels[-1]) %>% left_join(label_frame, by = c("indices" = "label")) } else { results <- @@ -358,7 +357,7 @@ create_anat_results <- left_join(label_frame, by = c("indices" = "label")) } - extra_structures <- results %>% filter_(~ is.na(Structure)) %>% .$indices + extra_structures <- results %>% filter(is.na(.data$Structure)) %>% .$indices if(length(extra_structures) != 0) message(length(extra_structures), " extra Structures found in files but not in labels: " @@ -373,14 +372,14 @@ create_anat_results <- results <- results %>% - filter_(~ !is.na(Structure)) + filter(!is.na(.data$Structure)) label_inds <- results$indices structures <- results$Structure results <- results %>% - select_(~ -c(indices,Structure)) %>% + select( -c(.data$indices,.data$Structure)) %>% t %>% `colnames<-`(structures) %>% `rownames<-`(NULL) @@ -576,16 +575,16 @@ anatSummarize <- if(is.character(summarize_by) && length(summarize_by == 1)){ summarize_by <- create_labels_frame(defs, hierarchy = summarize_by) %>% - select_(~ -label) %>% + select(- .data$label) %>% rename_(label = "Structure", group = "hierarchy") } if(!discard_missing){ summarize_by <- summarize_by %>% - mutate_(group = ~ifelse(is.na(group) | group == "", label, group)) + mutate(group = ifelse(is.na(.data$group) | .data$group == "", .data$label, .data$group)) } else { - summarize_by <- summarize_by %>% filter_(~ group != "") + summarize_by <- summarize_by %>% filter(.data$group != "") } anat %>% @@ -594,10 +593,10 @@ anatSummarize <- gather_("label", "value", setdiff(colnames(anat), "rowname")) %>% inner_join(summarize_by, by = "label") %>% group_by_("group", "rowname") %>% - summarize_(value = ~ sum(value)) %>% + summarize(value = sum(.data$value)) %>% spread_("group", "value") %>% - arrange_(~ as.numeric(rowname)) %>% - select_(~ -rowname) %>% + arrange(as.numeric(.data$rowname)) %>% + select(-.data$rowname) %>% as.matrix } diff --git a/R/minc_interface.R b/R/minc_interface.R index 0bed5f5e..dfceead3 100644 --- a/R/minc_interface.R +++ b/R/minc_interface.R @@ -595,8 +595,8 @@ summary.mincQvals <- function(object, ...) { gather_("key", "value", names(.)) %>% separate_("key", c("var", "stat"), sep=-2) %>% spread_("var", "value") %>% - mutate_(stat = ~ factor(stat, labels=paste("sum <", c(0.01, 0.05, 0.10, 0.15, 0.20)))) %>% - select_(~ stat, ~ everything()) %>% + mutate(stat = factor(.data$stat, labels=paste("sum <", c(0.01, 0.05, 0.10, 0.15, 0.20)))) %>% + select(.data$stat, everything()) %>% setNames(sub("_$","", names(.))) } @@ -1374,7 +1374,7 @@ getRMINCTestData <- function(dataPath = getOption("RMINC_DATA_DIR", tempdir()), lapply(filesToFix, rectifyPaths) } - invisible(NULL) + invisible(extractedPath) } #' Run function with/without output silenced diff --git a/R/minc_lmer.R b/R/minc_lmer.R index 7555e2f6..93cd3d2b 100644 --- a/R/minc_lmer.R +++ b/R/minc_lmer.R @@ -463,10 +463,10 @@ ranef_summary <- t_mat <- inner_join(group_se, e, by = c("group", "effect")) %>% - mutate_(tvalue = ~ beta / se - , grouping = ~ group_name - , se = ~ NULL) %>% - gather_("var", "value", c("tvalue", "beta")) %>% + mutate(tvalue = .data$beta / .data$se + , grouping = group_name + , se = NULL) %>% + gather("var", "value", c("tvalue", "beta")) %>% unite_("groupingXgroup", c("grouping", "group"), sep = "") %>% unite_("varXeffectXgroupingXgroup", c("var", "effect", "groupingXgroup"), sep = "-") %>% spread_("varXeffectXgroupingXgroup", "value") %>% diff --git a/R/minc_model_selection.R b/R/minc_model_selection.R index 4833a94f..35f7752f 100644 --- a/R/minc_model_selection.R +++ b/R/minc_model_selection.R @@ -146,13 +146,13 @@ summary.model_comparison <- function(object, ...){ formula_strings <- sapply(attr(object, "formulae"), deparse) formula_table <- - data_frame_(list(formula = ~formula_strings, model = ~as.character(seq_along(formula_strings)))) + data_frame(formula = formula_strings, model = as.character(seq_along(formula_strings))) wins_frame <- full_join(formula_table, wins_table, by = "model") %>% setNA(0) %>% - select_(~model, ~formula, ~wins) %>% - arrange_(~wins) + select(.data$model, .data$formula, .data$wins) %>% + arrange(.data$wins) wins_frame -} \ No newline at end of file +} From 09971430f0d02f5af846a3d795dcb9aa2dcba1c7 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Thu, 27 Feb 2020 16:46:09 -0500 Subject: [PATCH 17/31] [FIX] Remove deprecated untar argument Untar no longer allows specifying the compression algorithm. See #273 --- R/minc_interface.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/minc_interface.R b/R/minc_interface.R index dfceead3..35feb230 100644 --- a/R/minc_interface.R +++ b/R/minc_interface.R @@ -1354,7 +1354,7 @@ getRMINCTestData <- function(dataPath = getOption("RMINC_DATA_DIR", tempdir()), method = method) # changed from "wget" to stop freakouts on mac } - untar(downloadPath, exdir = dataPath, compressed = "gzip") + untar(downloadPath, exdir = dataPath) rectifyPaths <- function(file){ From f609addeba433ae7d2cbcd7dc67a378e83a31007 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Thu, 27 Feb 2020 16:47:06 -0500 Subject: [PATCH 18/31] [FIX] Broken symlink in user_tests mincTable tests weren't pointing to the right location --- inst/user_tests/test_mincTable.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/user_tests/test_mincTable.R b/inst/user_tests/test_mincTable.R index 8840a2ca..28d455a7 120000 --- a/inst/user_tests/test_mincTable.R +++ b/inst/user_tests/test_mincTable.R @@ -1 +1 @@ -tests/testthat/test_mincTable.R \ No newline at end of file +../../tests/testthat/test_mincTable.R \ No newline at end of file From 2eb4b2d0c25ad4decf1690fefffd61fe983b5569 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Thu, 27 Feb 2020 16:47:56 -0500 Subject: [PATCH 19/31] [FIX] Handle convergence warnings in minc/vertexLmer tests This was slightly tedious, testthat installs special warning handlers so this couldn't be done at a global level, instead each mincLmer call had to be wrapped with handling code that allows non-convergence errors to bubble up. --- tests/testthat/test_mincLmer.R | 88 +++++++++++++++++++++---------- tests/testthat/test_vertex_lmer.R | 69 ++++++++++++++---------- 2 files changed, 103 insertions(+), 54 deletions(-) diff --git a/tests/testthat/test_mincLmer.R b/tests/testthat/test_mincLmer.R index aef697af..27f97681 100644 --- a/tests/testthat/test_mincLmer.R +++ b/tests/testthat/test_mincLmer.R @@ -3,6 +3,12 @@ library(lme4) context("mincLmer - basic test") +handle_conv_warnings <- function(expr){ + withCallingHandlers(expr, warning = function(w){ + if(grepl("converge", w)) invokeRestart("muffleWarning") + }) +} + if(!exists("dataPath")) dataPath <- tempdir() @@ -16,19 +22,30 @@ maskfile <- file.path(dataPath, "testminc-mask.mnc") voxelIndex <- 453 # for later comparisons gf$v <- mincGetVoxel(gf$jacobians_fixed_2, 4, 5, 2) gf$coil <- as.factor(gf$coil) -l <- lmer(v ~ Sex + (1|coil), gf) -vsreml <- verboseRun("mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, mask=maskfile)",getOption("verbose")) + +handle_conv_warnings({ + l <- lmer(v ~ Sex + (1|coil), gf) +}) + +handle_conv_warnings({ + vsreml <- verboseRun("mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, mask=maskfile)",getOption("verbose")) +}) + test_that("mincLmer basics", { expect_that(vsreml[voxelIndex,1], is_equivalent_to(fixef(l)[1])) expect_that(vsreml[voxelIndex,2], is_equivalent_to(fixef(l)[2])) }) - + context("mincLmer - maximum likelihood test") -l <- lmer(v ~ Sex + (1|coil), gf, REML=F) +handle_conv_warnings({ + l <- lmer(v ~ Sex + (1|coil), gf, REML=F) +}) -vsml <- verboseRun("mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, REML=F, mask=maskfile)",getOption("verbose")) +handle_conv_warnings({ + vsml <- verboseRun("mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, REML=F, mask=maskfile)",getOption("verbose")) + }) test_that("mincLmer basics", { expect_that(vsml[voxelIndex,1], is_equivalent_to(fixef(l)[1])) @@ -38,14 +55,18 @@ test_that("mincLmer basics", { context("mincLmer - alternative summaries") test_that("ranef works", { verboseRun({ - vs_ranef <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, REML=F, mask=maskfile, summary_type = "ranef") + handle_conv_warnings({ + vs_ranef <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, REML=F, mask=maskfile, summary_type = "ranef") + }) expect_equal(as.numeric(vs_ranef[voxelIndex, 1:3]), ranef(l)$coil[,1], ignore.attributes = TRUE) }) }) test_that("anova works", { verboseRun({ - vs_anova <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, REML=F, mask=maskfile, summary_type = "anova") + handle_conv_warnings({ + vs_anova <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, REML=F, mask=maskfile, summary_type = "anova") + }) expect_equal(as.numeric(vs_anova[voxelIndex, "F-Sex"]), anova(l)[, "F value"]) #expect_equal(anova(l)[,"F value"], as.numeric(vs_anova[voxelIndex, "F-Sex"])) }) @@ -53,19 +74,23 @@ test_that("anova works", { test_that("'both' returns the right stat-types", { verboseRun({ - vs_both <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, REML=F, mask=maskfile, summary_type = "both") + handle_conv_warnings({ + vs_both <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, REML=F, mask=maskfile, summary_type = "both") + }) expect_equal(attr(vs_both, "stat-type") - , c(rep("beta",2) - , rep("tlmer", 2) - , rep("rand-beta", 3) - , rep("rand-tlmer", 3) - , "logLik", "converged")) + , c(rep("beta",2) + , rep("tlmer", 2) + , rep("rand-beta", 3) + , rep("rand-tlmer", 3) + , "logLik", "converged")) }) }) context("mincLmer - log likelihood ratios") -vsml2 <- verboseRun("mincLmer(jacobians_fixed_2 ~ 1 + (1|coil), gf, REML=F, mask=maskfile)",getOption("verbose")) +handle_conv_warnings({ + vsml2 <- verboseRun("mincLmer(jacobians_fixed_2 ~ 1 + (1|coil), gf, REML=F, mask=maskfile)",getOption("verbose")) +}) l2 <- lmer(v ~ 1 + (1|coil), gf, REML=F) @@ -81,33 +106,40 @@ test_that("empty DF by default", { expect_that( mincFDR(vsreml), throws_error() ) }) -verboseRun(vsreml <- mincLmerEstimateDF(vsreml)) +handle_conv_warnings({ + verboseRun(vsreml <- mincLmerEstimateDF(vsreml)) +}) + df <- attr(vsreml, "df") test_that("DF within reasonable range", { expect_that( df[[2]], is_less_than(nrow(gf)+1)) expect_that( df[[2]], is_more_than(1)) }) - + test_that("Local parallel mincLmer works", { skip_on_cran() skip_on_travis() if(Sys.getenv("TEST_Q_MINC") != "yes") skip("qMinc tests disabled") - - verboseRun( - preml <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, mask=maskfile, parallel = c("local", 2)) - ) + + handle_conv_warnings({ + verboseRun( + preml <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf, mask=maskfile, parallel = c("local", 2)) + ) + }) expect_equal(vsreml, preml, check.attributes = FALSE) }) test_that("Exotic formulae work", { - verboseRun({ - exotic <- mincLmer(jacobians_fixed_2 ~ I(factor(as.numeric(Sex) - 1)) + (1|coil), gf, mask=maskfile) - exotic_dfs <- mincLmerEstimateDF(exotic) - df <- attr(exotic_dfs, "df") + handle_conv_warnings({ + verboseRun({ + exotic <- mincLmer(jacobians_fixed_2 ~ I(factor(as.numeric(Sex) - 1)) + (1|coil), gf, mask=maskfile) + exotic_dfs <- mincLmerEstimateDF(exotic) + df <- attr(exotic_dfs, "df") + }) }) expect_that( df[[2]], is_less_than(nrow(gf)+1)) @@ -119,9 +151,11 @@ test_that("mincLmer works with NAs", { verboseRun({ gf_missing <- gf gf_missing[1, "Sex"] <- NA - - missing <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf_missing, mask=maskfile) - missing_dfs <- mincLmerEstimateDF(missing) + + handle_conv_warnings({ + missing <- mincLmer(jacobians_fixed_2 ~ Sex + (1|coil), gf_missing, mask=maskfile) + missing_dfs <- mincLmerEstimateDF(missing) + }) df <- attr(missing_dfs, "df") }) diff --git a/tests/testthat/test_vertex_lmer.R b/tests/testthat/test_vertex_lmer.R index ee731e4b..1d1b9c72 100644 --- a/tests/testthat/test_vertex_lmer.R +++ b/tests/testthat/test_vertex_lmer.R @@ -23,21 +23,28 @@ subjectFile[9,1] <- file.path(dataPath, "vertex3.txt") subjectFile[10,1] <- file.path(dataPath, "vertex1.txt") gftest$testFilesLeft <- subjectFile +handle_conv_warnings <- function(expr){ + withCallingHandlers(expr, warning = function(w){ + if(grepl("converge", w)) invokeRestart("muffleWarning") + }) +} + test_env <- new.env() test_that("Vertex REML Lmer Works", { evalq({ vertex_table <- vertexTable(gftest$testFilesLeft) + + handle_conv_warnings({ + slow_lmer <- + lapply(seq_len(nrow(vertex_table)), function(row){ + vals <- vertex_table[row,] + lmer(vals ~ Age + (1 | Sex), data = gftest) + }) - slow_lmer <- - lapply(seq_len(nrow(vertex_table)), function(row){ - vals <- vertex_table[row,] - lmer(vals ~ Age + (1 | Sex), data = gftest) - }) - - fast_lmer <- - vertexLmer(testFilesLeft ~ Age + (1|Sex), data = gftest) - + fast_lmer <- + vertexLmer(testFilesLeft ~ Age + (1|Sex), data = gftest) + }) expect_equal(fast_lmer[,1:2], t(sapply(slow_lmer, fixef)), check.attributes = FALSE) expect_equal(fast_lmer[,3:4], t(sapply(slow_lmer, function(x) coefficients(summary(x))[,"t value"])) , check.attributes = FALSE) @@ -46,14 +53,16 @@ test_that("Vertex REML Lmer Works", { test_that("Vertex ML Lmer Works", { evalq({ - fast_lmer2 <- - vertexLmer(testFilesLeft ~ Age + (1|Sex), data = gftest, REML = FALSE) + handle_conv_warnings({ + fast_lmer2 <- + vertexLmer(testFilesLeft ~ Age + (1|Sex), data = gftest, REML = FALSE) - slow_lmer2 <- - lapply(seq_len(nrow(vertex_table)), function(row){ - vals <- vertex_table[row,] - lmer(vals ~ Age + (1 | Sex), data = gftest, REML = FALSE) - }) + slow_lmer2 <- + lapply(seq_len(nrow(vertex_table)), function(row){ + vals <- vertex_table[row,] + lmer(vals ~ Age + (1 | Sex), data = gftest, REML = FALSE) + }) + }) expect_equal(fast_lmer2[,1:2], t(sapply(slow_lmer2, fixef)), check.attributes = FALSE, tolerance = 10e-5) expect_equal(fast_lmer2[,3:4], t(sapply(slow_lmer2, function(x) coefficients(summary(x))[,"t value"])) @@ -63,14 +72,16 @@ test_that("Vertex ML Lmer Works", { test_that("Likelihood Ratio Tests for vertexLmer Work", { evalq({ - slow_lmer3 <- - lapply(seq_len(nrow(vertex_table)), function(row){ - vals <- vertex_table[row,] - lmer(vals ~ (1 | Sex), data = gftest, REML = FALSE) - }) + handle_conv_warnings({ + slow_lmer3 <- + lapply(seq_len(nrow(vertex_table)), function(row){ + vals <- vertex_table[row,] + lmer(vals ~ (1 | Sex), data = gftest, REML = FALSE) + }) - fast_lmer3 <- - vertexLmer(testFilesLeft ~ (1|Sex), data = gftest, REML = FALSE) + fast_lmer3 <- + vertexLmer(testFilesLeft ~ (1|Sex), data = gftest, REML = FALSE) + }) expect_error(mincLogLikRatio(fast_lmer, fast_lmer2), regexp = "REML=FALSE") expect_equal(mincLogLikRatio(fast_lmer2, fast_lmer3)[2] @@ -91,7 +102,9 @@ test_that("empty DF by default", { test_that("DF within reasonable range", { evalq({ - verboseRun(fast_lmer_df <- vertexLmerEstimateDF(fast_lmer)) + handle_conv_warnings({ + verboseRun(fast_lmer_df <- vertexLmerEstimateDF(fast_lmer)) + }) df <- attr(fast_lmer_df, "df") expect_that( df[[2]], is_less_than(nrow(gftest)+1)) expect_that( df[[2]], is_more_than(1)) @@ -102,9 +115,11 @@ test_that("vertexLmer works with NAs", { verboseRun({ gf_missing <- gftest gf_missing[1, "Sex"] <- NA - - missing <- vertexLmer(testFilesLeft ~ Age + (1|Sex), gf_missing) - missing_dfs <- vertexLmerEstimateDF(missing) + + handle_conv_warnings({ + missing <- vertexLmer(testFilesLeft ~ Age + (1|Sex), gf_missing) + missing_dfs <- vertexLmerEstimateDF(missing) + }) df <- attr(missing_dfs, "df") }) From 56c98cb41b9f540120de88dd25e936162487c621 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Thu, 27 Feb 2020 16:50:33 -0500 Subject: [PATCH 20/31] [DOC] Better context for mincLm tests --- tests/testthat/test_mincLm.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/testthat/test_mincLm.R b/tests/testthat/test_mincLm.R index 771a8c6b..1cc5518e 100644 --- a/tests/testthat/test_mincLm.R +++ b/tests/testthat/test_mincLm.R @@ -142,6 +142,8 @@ test_that("mincLm Three Factors Interaction",{ expect_that(attr(rmincLm4,"df")[[2]],is_equivalent_to(rLm4$df[2])) }) +context("mincLm - Model Selection") + test_that("Model Selection Works", { comp1 <- compare_models(rmincLm, rmincLm2, rmincLm3, rmincLm4, metric = AIC) comp2 <- compare_models(rmincLm, rmincLm2, rmincLm3, rmincLm4) @@ -158,6 +160,7 @@ test_that("Model Selection Works", { expect_equal(as.numeric(summary(comp2)$wins), c(100, 100, 119, 981)) }) +context("mincLm - Parallel") test_that("mincLm local multicore works", { skip_on_cran() skip_on_travis() @@ -177,6 +180,7 @@ test_that("mincLm local multicore works", { # }) ## Need a much better test here. +context("mincLm - Randomize") test_that("mincLm randomize works", { verboseRun(rlm <- mincLm(voxel_left_file~Sex, gftest)) verboseRun(rand <- RMINC:::mincRandomize.mincLm(rlm, R = 10)) From d25025ec5e87169c3a253dc122c6f71f87953546 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Thu, 27 Feb 2020 16:51:58 -0500 Subject: [PATCH 21/31] [FIX] Muffle warnings in wilcox.test test Flaky ties warning caused periodic failures. See #273 --- tests/testthat/test_mincSummary.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test_mincSummary.R b/tests/testthat/test_mincSummary.R index d06db5ba..ef545628 100644 --- a/tests/testthat/test_mincSummary.R +++ b/tests/testthat/test_mincSummary.R @@ -73,7 +73,9 @@ test_that("correlation", { gf_paired$vox_round <- round(gf_paired$vox,8) -tw <- wilcox.test(vox_round~Strain,data=gf_paired) +suppressWarnings( + tw <- wilcox.test(vox_round~Strain,data=gf_paired) +) mw <- verboseRun("mincWilcoxon(gf_paired$jacobians_0.2,gf_paired $Strain)",getOption("verbose")) test_that("wilcoxon-ties", { expect_equivalent(tw[[1]], mw[1]) From 24658d96ec8b3807d282f8fdd5282b2441952572 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 28 Feb 2020 10:31:44 -0500 Subject: [PATCH 22/31] [DOC] Add columnsToKeep documentation to civet.readCBRAIN --- R/civet.R | 1 + man/civet.readCBRAIN.Rd | 2 ++ 2 files changed, 3 insertions(+) diff --git a/R/civet.R b/R/civet.R index 5ebd4ff7..a0604a25 100644 --- a/R/civet.R +++ b/R/civet.R @@ -644,6 +644,7 @@ civet_filenames_2_0_0 <- #' @param flatten logical whether to convert the CIVET results into a \code{dplyr} compatible data frame or leave #' it in the legacy format #' @param QCDir The directory, or vector of directories of where to find QC tables +#' @param columnsToKeep Additional columns from \link{civet.readAllFiles} to include in the output #' @return A data.frame in the format of \link{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in #' the format of \link{civet.readAllCivetFiles} if \code{readFiles} is TRUE and \code{flatten} is FALSE. And a data.frame in #' the format of \link{civet.flattenForDplyr} if \code{readQC}, \code{readFiles}, and \code{flatten} are all TRUE (default) diff --git a/man/civet.readCBRAIN.Rd b/man/civet.readCBRAIN.Rd index 0a9a4474..7ae56b9b 100644 --- a/man/civet.readCBRAIN.Rd +++ b/man/civet.readCBRAIN.Rd @@ -28,6 +28,8 @@ civet.readCBRAIN(path, prefix, subjects = NULL, atlas = "AAL", it in the legacy format} \item{QCDir}{The directory, or vector of directories of where to find QC tables} + +\item{columnsToKeep}{Additional columns from \link{civet.readAllFiles} to include in the output} } \value{ A data.frame in the format of \link{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in From 3d56503c060059cb2c4feb9460d72b53dbeb6145 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 28 Feb 2020 11:22:59 -0500 Subject: [PATCH 23/31] [INFRA] Working travis config Provides visible tests, R CMD check output, and only runs the tests once as opposed to simpler solutions. --- .travis.yml | 59 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 89214e8e..b414b0c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,66 @@ matrix: include: - os: linux - dist: trusty + dist: xenial + script: | + R CMD build . + R CMD INSTALL RMINC*.tar.gz + R CMD check --as-cran --no-install RMINC*.tar.gz + cat RMINC.Rcheck/00check.log + Rscript -e "\ + testr <- devtools::test(); \ + testr <- as.data.frame(testr); \ + if(any(testr\$error) || any(testr\$warning > 0)) \ + stop('Found failing tests') \ + " + pass=$? + if [[ $pass -ne 0 || $(grep -i "WARNING\|ERROR" RMINC.Rcheck/00check.log) != "" ]]; then + (exit 1) + else + (exit 0) + fi - os: osx + script: | + R CMD build . + R CMD INSTALL RMINC*.tar.gz + R CMD check --as-cran --no-install RMINC*.tar.gz + cat RMINC.Rcheck/00check.log + Rscript -e "\ + testr <- devtools::test(); \ + testr <- as.data.frame(testr); \ + if(any(testr\$error) || any(testr\$warning > 0)) \ + stop('Found failing tests') \ + " + pass=$? + if [[ $pass -ne 0 || $(grep -i "WARNING\|ERROR" RMINC.Rcheck/00check.log) != "" ]]; then + (exit 1) + else + (exit 0) + fi language: r +r_binary_packages: + - devtools + - roxygen2 + - tidyverse + - lme4 sudo: required - +addons: + apt: + update: true + packages: + - libgl1-mesa-dev + - libglu1-mesa-dev + - freeglut3-dev +env: + MINC_PATH=/opt/minc/1.9.17 + before_install: | if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then (cd ../ ; - wget http://packages.bic.mni.mcgill.ca/minc-toolkit/Debian/minc-toolkit-1.9.16-20180117-Ubuntu_14.04-x86_64.deb ) - sudo dpkg -i ../minc-toolkit-1.9.16-20180117-Ubuntu_14.04-x86_64.deb - source /opt/minc/1.9.16/minc-toolkit-config.sh + wget https://packages.bic.mni.mcgill.ca/minc-toolkit/Debian/minc-toolkit-1.9.17-20190313-Ubuntu_16.04-x86_64.deb) + sudo dpkg -i ../minc-toolkit-1.9.17-20190313-Ubuntu_16.04-x86_64.deb + source /opt/minc/1.9.17/minc-toolkit-config.sh fi if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then @@ -21,6 +69,7 @@ before_install: | sudo hdiutil attach ../minc-toolkit-1.9.16-20180117-Darwin-10.8-x86_64.dmg sudo installer -package /Volumes/minc-toolkit-1.9.16-20180117-Darwin-x86_64/minc-toolkit-1.9.16-20180117-Darwin-x86_64.pkg -target / source /opt/minc/1.9.16/minc-toolkit-config.sh + export LDFLAGS="$LDFLAGS -L$(brew --prefix zlib)/lib" Rscript -e "install.packages('digest')" fi From df15768861721c5e0c676afd305d2cb267ccc210 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 28 Feb 2020 11:43:25 -0500 Subject: [PATCH 24/31] [FIX] Add missing param documentation in vertexAtlasApply New `atlas_column` argument was undocumented. --- R/minc_vertex_statistics.R | 1 + man/vertexAtlasApply.Rd | 2 ++ 2 files changed, 3 insertions(+) diff --git a/R/minc_vertex_statistics.R b/R/minc_vertex_statistics.R index 4b3ec5a9..c23522fd 100644 --- a/R/minc_vertex_statistics.R +++ b/R/minc_vertex_statistics.R @@ -172,6 +172,7 @@ vertexApply <- function(filenames, fun, ..., mask = NULL, parallel = NULL #' #' @inheritParams vertexApply #' @param atlas The atlas to use to summarize vertices. +#' @param atlas_column If the atlas is a text file, which column holds the label #' @return The a matrix with a row of results for each structure #' @export vertexAtlasApply <- function(filenames, atlas, fun, ..., mask = NULL diff --git a/man/vertexAtlasApply.Rd b/man/vertexAtlasApply.Rd index e54127f6..2bbc3e77 100644 --- a/man/vertexAtlasApply.Rd +++ b/man/vertexAtlasApply.Rd @@ -29,6 +29,8 @@ indicating the number of jobs to split the computation into.} structure. Defaults to \link{simplify_masked}} \item{column}{Which column to treat as the input from vertex files.} + +\item{atlas_column}{If the atlas is a text file, which column holds the label} } \value{ The a matrix with a row of results for each structure From 4c91c1e18dae07688bc7629de3b75515efedc3d6 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 28 Feb 2020 12:10:24 -0500 Subject: [PATCH 25/31] [DOC] Remove erroneous link in civet.readCBRAIN --- R/civet.R | 2 +- man/civet.readCBRAIN.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/civet.R b/R/civet.R index a0604a25..317d9065 100644 --- a/R/civet.R +++ b/R/civet.R @@ -645,7 +645,7 @@ civet_filenames_2_0_0 <- #' it in the legacy format #' @param QCDir The directory, or vector of directories of where to find QC tables #' @param columnsToKeep Additional columns from \link{civet.readAllFiles} to include in the output -#' @return A data.frame in the format of \link{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in +#' @return A data.frame in the format of \code{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in #' the format of \link{civet.readAllCivetFiles} if \code{readFiles} is TRUE and \code{flatten} is FALSE. And a data.frame in #' the format of \link{civet.flattenForDplyr} if \code{readQC}, \code{readFiles}, and \code{flatten} are all TRUE (default) #' @seealso \link{civet.getAllFilenames} \link{civet.readAllCivetFiles} \link{civet.flattenForDplyr} diff --git a/man/civet.readCBRAIN.Rd b/man/civet.readCBRAIN.Rd index 7ae56b9b..dba4532e 100644 --- a/man/civet.readCBRAIN.Rd +++ b/man/civet.readCBRAIN.Rd @@ -32,7 +32,7 @@ it in the legacy format} \item{columnsToKeep}{Additional columns from \link{civet.readAllFiles} to include in the output} } \value{ -A data.frame in the format of \link{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in +A data.frame in the format of \code{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in the format of \link{civet.readAllCivetFiles} if \code{readFiles} is TRUE and \code{flatten} is FALSE. And a data.frame in the format of \link{civet.flattenForDplyr} if \code{readQC}, \code{readFiles}, and \code{flatten} are all TRUE (default) } From fc217114f7b923c1c2ff3fc0730e77f040e2d46b Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 28 Feb 2020 13:20:49 -0500 Subject: [PATCH 26/31] [FIX] Handle convergence warnings in anatLmer tests --- tests/testthat/test_anatLmer.R | 52 +++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/tests/testthat/test_anatLmer.R b/tests/testthat/test_anatLmer.R index 4e06a598..f94891d9 100644 --- a/tests/testthat/test_anatLmer.R +++ b/tests/testthat/test_anatLmer.R @@ -4,6 +4,12 @@ suppressPackageStartupMessages({ library(lme4) }) +handle_conv_warnings <- function(expr){ + withCallingHandlers(expr, warning = function(w){ + if(grepl("converge", w)) invokeRestart("muffleWarning") + }) +} + context("anatLmer") if(!exists("dataPath")) @@ -30,15 +36,15 @@ test_that("anatLmer works", { method = "jacobians", defs = labels) - suppressWarnings( + handle_conv_warnings( lmer_res_nlhs <- anatLmer( ~ Pain.sensitivity + (1|Genotype), data = gf, anat = jacobians)) - suppressWarnings( + handle_conv_warnings( lmer_res_lhs <- anatLmer(dummy ~ Pain.sensitivity + (1|Genotype), data = gf, anat = jacobians)) - suppressWarnings({ + handle_conv_warnings({ lmer_ref <- apply(jacobians, 2, function(col){ gf2 <- gf %>% mutate(resp = col) @@ -55,7 +61,9 @@ test_that("anatLmer works", { test_that("anatLmer estimate DF returns sensible results", { evalq({ - verboseRun(with_dfs <- anatLmerEstimateDF(lmer_res_nlhs)) + handle_conv_warnings({ + verboseRun(with_dfs <- anatLmerEstimateDF(lmer_res_nlhs)) + }) dfs <- attr(with_dfs, "df") expect_true(between(dfs[1], 1, 3)) expect_true(all(between(dfs[2:4], 20, 31))) @@ -64,12 +72,14 @@ test_that("anatLmer estimate DF returns sensible results", { test_that("anatLmer exotic formulae work", { evalq({ - verboseRun( - exotic_lmer <- anatLmer(~ I(factor(as.numeric(Pain.sensitivity) - 1)) + (1 | Genotype) + handle_conv_warnings({ + verboseRun( + exotic_lmer <- anatLmer(~ I(factor(as.numeric(Pain.sensitivity) - 1)) + (1 | Genotype) , data = gf, anat = jacobians) - ) + ) - verboseRun(with_dfs <- anatLmerEstimateDF(exotic_lmer)) + verboseRun(with_dfs <- anatLmerEstimateDF(exotic_lmer)) + }) dfs <- attr(with_dfs, "df") expect_true(between(dfs[1], 1, 3)) expect_true(all(between(dfs[2:4], 20, 31))) @@ -78,12 +88,14 @@ test_that("anatLmer exotic formulae work", { test_that("anatLmer exotic formulae work", { evalq({ - verboseRun( - exotic_lmer <- anatLmer(~ I(factor(as.numeric(Pain.sensitivity) - 1)) + (1 | Genotype) + handle_conv_warnings({ + verboseRun( + exotic_lmer <- anatLmer(~ I(factor(as.numeric(Pain.sensitivity) - 1)) + (1 | Genotype) , data = gf, anat = jacobians) - ) + ) - verboseRun(with_dfs <- anatLmerEstimateDF(exotic_lmer)) + verboseRun(with_dfs <- anatLmerEstimateDF(exotic_lmer)) + }) dfs <- attr(with_dfs, "df") expect_true(between(dfs[1], 1, 3)) expect_true(all(between(dfs[2:4], 20, 31))) @@ -99,15 +111,17 @@ test_that("weighted lmer works", { a <- matrix(rnorm(60), ncol = 3) - weighted_lmer <- anatLmer( ~ x + (1 | g), data = d, anat = a, weights = d$w) - - lmer_ref <- + handle_conv_warnings({ + weighted_lmer <- anatLmer( ~ x + (1 | g), data = d, anat = a, weights = d$w) + + lmer_ref <- apply(a, 2, function(col){ - d <- d %>% mutate(resp = col) - mod <- lmer(resp ~ x + (1 | g), data = d, weights = d$w) - RMINC:::fixef_summary(mod) + d <- d %>% mutate(resp = col) + mod <- lmer(resp ~ x + (1 | g), data = d, weights = d$w) + RMINC:::fixef_summary(mod) }) %>% - t + t + }) expect_equivalent(unclass(weighted_lmer), lmer_ref) }) From f3d05346eded79833bf2415a605d53c4a34c5563 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 28 Feb 2020 13:29:55 -0500 Subject: [PATCH 27/31] [DOC] Fix broken link in civet.readCBRAIN --- R/civet.R | 4 ++-- man/civet.readCBRAIN.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/civet.R b/R/civet.R index 317d9065..cd20181a 100644 --- a/R/civet.R +++ b/R/civet.R @@ -644,8 +644,8 @@ civet_filenames_2_0_0 <- #' @param flatten logical whether to convert the CIVET results into a \code{dplyr} compatible data frame or leave #' it in the legacy format #' @param QCDir The directory, or vector of directories of where to find QC tables -#' @param columnsToKeep Additional columns from \link{civet.readAllFiles} to include in the output -#' @return A data.frame in the format of \code{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in +#' @param columnsToKeep Additional columns from \link{civet.readAllCivetFiles} to include in the output +#' @return A data.frame in the format of \link{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in #' the format of \link{civet.readAllCivetFiles} if \code{readFiles} is TRUE and \code{flatten} is FALSE. And a data.frame in #' the format of \link{civet.flattenForDplyr} if \code{readQC}, \code{readFiles}, and \code{flatten} are all TRUE (default) #' @seealso \link{civet.getAllFilenames} \link{civet.readAllCivetFiles} \link{civet.flattenForDplyr} diff --git a/man/civet.readCBRAIN.Rd b/man/civet.readCBRAIN.Rd index dba4532e..4a27e984 100644 --- a/man/civet.readCBRAIN.Rd +++ b/man/civet.readCBRAIN.Rd @@ -29,10 +29,10 @@ it in the legacy format} \item{QCDir}{The directory, or vector of directories of where to find QC tables} -\item{columnsToKeep}{Additional columns from \link{civet.readAllFiles} to include in the output} +\item{columnsToKeep}{Additional columns from \link{civet.readAllCivetFiles} to include in the output} } \value{ -A data.frame in the format of \code{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in +A data.frame in the format of \link{civet.getAllFilenames} if \code{readFiles} is FALSE. A data.frame in the format of \link{civet.readAllCivetFiles} if \code{readFiles} is TRUE and \code{flatten} is FALSE. And a data.frame in the format of \link{civet.flattenForDplyr} if \code{readQC}, \code{readFiles}, and \code{flatten} are all TRUE (default) } From 6e8642844365d5b9c92173c9720019df472e682d Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 28 Feb 2020 14:13:55 -0500 Subject: [PATCH 28/31] [FIX] Correct broken QC rating for CIVET 1.1.12 Caught by R CMD check after removing the deprecated underscore verbs that were hiding this problem from the checks. --- R/civet.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/civet.R b/R/civet.R index cd20181a..94f9354c 100644 --- a/R/civet.R +++ b/R/civet.R @@ -1718,12 +1718,12 @@ civet_qc_1_1_12 <- CSFcls_score = ifelse(between(.data$CSFcls, 15, 80), "good", "med"), GMcls_score = ifelse(between(.data$GMcls, 15, 80), "good", "med"), WMcls_score = ifelse(between(.data$WMcls, 15, 80), "good", "med"), - WMsurf_score = good_med_bad(.data$WMsurf, 10, 20), - GMsurf_score = good_med_bad(.data$GMsurf, 10, 20), - SRLeft_score = good_med_bad(.data$SRLeft, 250, 500), - SRRight_score = good_med_bad(.data$SRRight, 250, 500), - SSLeft_score = good_med_bad(.data$SSLeft, 250, 500), - SSRight_score = good_med_bad(.data$SSRight, 250, 500) + WMsurf_score = rate_cutoffs(.data$WMsurf, 10, 20), + GMsurf_score = rate_cutoffs(.data$GMsurf, 10, 20), + SRLeft_score = rate_cutoffs(.data$SRLeft, 250, 500), + SRRight_score = rate_cutoffs(.data$SRRight, 250, 500), + SSLeft_score = rate_cutoffs(.data$SSLeft, 250, 500), + SSRight_score = rate_cutoffs(.data$SSRight, 250, 500) ) %>% cbind( rowwise(.) %>% From 8885c8f755c887aae43a20a5f20fc9f886f43b45 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Fri, 28 Feb 2020 15:13:13 -0500 Subject: [PATCH 29/31] [FIX] Make travis error checks case insensitive --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b414b0c7..d3629601 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: stop('Found failing tests') \ " pass=$? - if [[ $pass -ne 0 || $(grep -i "WARNING\|ERROR" RMINC.Rcheck/00check.log) != "" ]]; then + if [[ $pass -ne 0 || $(grep "WARNING\|ERROR" RMINC.Rcheck/00check.log) != "" ]]; then (exit 1) else (exit 0) @@ -32,7 +32,7 @@ matrix: stop('Found failing tests') \ " pass=$? - if [[ $pass -ne 0 || $(grep -i "WARNING\|ERROR" RMINC.Rcheck/00check.log) != "" ]]; then + if [[ $pass -ne 0 || $(grep "WARNING\|ERROR" RMINC.Rcheck/00check.log) != "" ]]; then (exit 1) else (exit 0) From 17f32e57e6d85f805b706fed8a45cdf6bb007ebc Mon Sep 17 00:00:00 2001 From: cfhammill Date: Mon, 9 Mar 2020 10:52:21 -0400 Subject: [PATCH 30/31] [DOC] More mac build instructions Add code for setting LDFLAGS. Ultimately this should be in the configure script. --- INSTALL | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/INSTALL b/INSTALL index 98423ccd..8567ca95 100644 --- a/INSTALL +++ b/INSTALL @@ -59,11 +59,12 @@ you can use homebrew to install the Gnu Compiler Collection which comes with gfortran ``` -brew install gcc libssh2 libgit2 libomp +brew install gcc libssh2 libgit2 libomp libz ``` Regardless of how you install gfortran you will need to tell -R where to find it. If you installed via brew you can run +R where to find it. If you installed via brew you can run the +following in terminal ``` mkdir $HOME/.R/ ## Ignore the error if this directory already exists @@ -79,6 +80,15 @@ library path. My best guess is echo 'FLIBS=-L/usr/local/gfortran/lib" >> $HOME/.R/Makevars' ``` +Additionally, recent mac versions have struggled to link libz in +to RMINC. You will probably need to run the following in the terminal +before opening R + +``` +export LDFLAGS="$LDFLAGS -L$(brew --prefix zlib)/lib" +``` + + If that works or doesn't let me know in the issues! From 141a62a7000afbad579146c3168fa879623be743 Mon Sep 17 00:00:00 2001 From: cfhammill Date: Mon, 9 Mar 2020 10:53:59 -0400 Subject: [PATCH 31/31] [RELEASE] Bump version and add news Get ready world, here comes 1.5.2.3 --- DESCRIPTION | 2 +- NEWS | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index b146065b..778c49e3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: RMINC -Version: 1.5.2.2 +Version: 1.5.2.3 Date: 2017-05-31 Title: Statistical Tools for Medical Imaging NetCDF (MINC) Files Authors@R: c(person("Jason", "Lerch", role = "aut", email = "jason.lerch@sickkids.ca"), diff --git a/NEWS b/NEWS index fbfcad70..76f81d98 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,24 @@ New in Version 1.5.*.* ======================= +2.3 +-- +- Fixed mincLmer reinit (formula out of scope bug) +- Improved mac install notes (issue #261) +- Defaults RMINC_LABEL_DEFINITIONS to null instead of empty string + (issue #259) +- anatGetAll fails faster if the label defs are broken (issue #260) +- civet.readCBrain now supports `columnsToKeep` to pass to flattening + code +- Add environment variable to configure where test data is located, useful + for systems where internet isn't available. +- Improvement to FDR threshold selection in launch_shiny_RMINC +- Code for reading in a matrix of minc files `mincTable`. Supports + file backed matrices for when your files are too big for your computers + memory. +- Fixed reading QC for CIVET 1.1.12 experiments +- Fixed and streamlined the continuous integration (travis) build scripts +- Fixed all outstanding R CMD check and test issues + 2.2 -- - Improvements to vertex code (thanks @vfonov), now can