diff --git a/NEWS.md b/NEWS.md index e979eb7..6d25a3c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -#voxel +# voxel Functions for the voxelwise analysis of NIfTI data in R. diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..911ae01 --- /dev/null +++ b/docs/404.html @@ -0,0 +1,135 @@ + + + +
+ + + + +NEWS.md
+ R/anovagamVoxel.R
+ anovagamVoxel.Rd
This function computes analysis of variance tables for the fitted models after running a Generalized Additive Model (from mgcv::gam). +The analysis will run in all voxels in the mask and will return the analysis of variance table for each voxel. +Please check the mgcv::anova.gam documentation for further information about specific arguments used in anova.gam. Multi-model calls are disabled.
+ +anovagamVoxel(image, mask, fourdOut = NULL, formula, subjData, + dispersion = NULL, freq = FALSE, mc.preschedule = TRUE, ncores = 1, + ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gam() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
dispersion | +To be passed to mgcv::anova.gam, Defaults to NULL. Dispersion Parameter, not normally used. |
+
freq | +To be passed to mgcv::anova.gam, Defaults to FALSE. Frequentist or Bayesian approximations for p-values |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to gam() |
+
Returns list of models fitted to each voxel over the masked images passed to function.
+ + ++image <- oro.nifti::nifti(img = array(1:200, dim =c(2,2,2,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(2,2,2,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y=runif(25)) +fm1 <- "~ s(x) + y" +models <- anovagamVoxel(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test ANOVA" +#> [1] "Running parallel ANOVAs" +#> elapsed +#> 0.07 +#> [1] "Parallel ANOVAs Ran"
R/anovagammVoxel.R
+ anovagammVoxel.Rd
This function computes analysis of variance tables for the fitted Generalized Additive Mixed Effects (from gamm4::gamm4) models. +The analysis will run in all voxels in the specified mask and will return a list with the ANOVA table at each voxel. +Please check the mgcv::anova.gam documentation for further information about specific arguments used in anova.gam. Multi-model calls are disabled.
+ +anovagammVoxel(image, mask, fourdOut = NULL, formula, randomFormula, subjData, + dispersion = NULL, freq = FALSE, mc.preschedule = TRUE, ncores = 1, + ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary. |
+
fourdOut | +To be passed to mergeNifti, This is the output path to write out the fourd file. Do not include a suffix (i.e. .nii.gz). Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gamm4() |
+
randomFormula | +Random effects formula passed to gamm4() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
dispersion | +To be passed to mgcv::anova.gam, Defaults to NULL. Dispersion Parameter, not normally used. |
+
freq | +To be passed to mgcv::anova.gam, Defaults to FALSE. Frequentist or Bayesian approximations for p-values |
+
mc.preschedule | +To be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to gamm4() |
+
Returns list of models fitted to each voxel over the masked images passed to function.
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(data = c(rep(0,15), rep(1,1)), + dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y=runif(25), id = rep(1:5,5)) +f1 <- "~ s(x) + y" +randomFormula <- "~(1|id)" +models <- anovagammVoxel(image, mask, formula = f1, + randomFormula = randomFormula, + subjData = covs, ncores = 1, REML=TRUE)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test ANOVA" +#> [1] "Running parallel ANOVAs" +#> elapsed +#> 0.571 +#> [1] "Parallel ANOVAs Ran"
R/anovalmVoxel.R
+ anovalmVoxel.Rd
This function computes analysis of variance tables for the fitted models after running a Linear Model using the stats::lm() function. +The analysis will run in all voxels in the mask and will return the analysis of variance table for each voxel. +Please check the stats documentation for further information about specific arguments used in stats::anova.lm(). Multi-model calls are disabled.
+ +anovalmVoxel(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lm() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lm() |
+
Returns list of models fitted to each voxel over the masked images passed to function.
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y=runif(25)) +fm1 <- "~ x + y" +models <- anovalmVoxel(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test ANOVA" +#> [1] "Running parallel ANOVAs" +#> elapsed +#> 0.044 +#> [1] "Parallel ANOVAs Ran"
R/anovalmerVoxel.R
+ anovalmerVoxel.Rd
This function computes analysis of variance tables for the fitted models after running a Linear Mixed Effect Model using the lmerTest() function and the anova function in that package. +The analysis will run in all voxels in the mask and will return the analysis of variance table for each voxel. +Please check the lmerTest documentation for further information about specific arguments used in anova.lmerModLmerTest. Multi-model calls are disabled.
+ +anovalmerVoxel(image, mask, fourdOut = NULL, formula, subjData, + ddf = "Satterthwaite", type = 3, mc.preschedule = TRUE, ncores = 1, + ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lmer() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
ddf | +Which approximation of DDF to be used. To be passed to anova.lmerModLmerTest. Defaults to "Satterthwaite" |
+
type | +Type of hypothesis to be test (defined from SAS terminology). Defaults to 3. To be passed to anova.lmerModLmerTest |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lmer() |
+
Returns list of models fitted to each voxel over the masked images passed to function.
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,15), rep(1,1)), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = runif(25), id = rep(1:5,5)) +fm1 <- "~ x + y + (1|id)" +models <- anovalmerVoxel(image, mask, formula = fm1, subjData = covs, ncores = 1, REML=TRUE)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test ANOVA"#>#> [1] "Running parallel ANOVAs"#>#>#>#>#> elapsed +#> 0.325 +#> [1] "Parallel ANOVAs Ran"+
R/gamCluster.R
+ gamCluster.Rd
This function is able to run a Generalized Additive Model (GAM) using the mgcv package. +All clusters must be labeled with integers in the mask passed as an argument.
+ +gamCluster(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNiftis() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. All clusters must be labeled with integers in the mask passed as an argument |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gam() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use for the analysis |
+
... | +Additional arguments passed to gam() |
+
Returns list of models fitted to the mean voxel intensity over region of interest.
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(1:4, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25)) +fm1 <- "~ s(x)" +models <- gamCluster(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1, method="REML")#> [1] "Created meanCluster Matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.1 +#> [1] "Parallel Models Ran"
R/gamNIfTI.R
+ gamNIfTI.Rd
This function is able to run a Generalized Additive Model (GAM) using the mgcv package. +The analysis will run in all voxels in in the mask and will return parametric and smooth coefficients. +The function will create parametric maps according to the model selected. +The function will return a p-map, t-map, z-map, p-adjusted-map for parametric terms and p-map, z-map, p-adjusted-map for smooth terms. +You can select which type of p-value correction you want done on the map.
+ +gamNIfTI(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, method = "none", residual = FALSE, + outDir = NULL, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gam() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
method | +which method of correction for multiple comparisons (default is none) |
+
residual | +If set to TRUE then residuals maps will be returned along parametric maps |
+
outDir | +Path to the folder where to output parametric maps (Default is Null, only change if you want to write maps out) |
+
... | +Additional arguments passed to gam() |
+
Parametric maps of the fitted models
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = rnorm(25)) +fm1 <- "~ x + s(y)" +Maps <- gamNIfTI(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1, method="fdr")#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.242 +#> [1] "Parallel Models Ran" +#> [1] "Creating parametric maps" +#> [1] "Working with output of gam object"
This function is able to generate all the necessary files to run randomise with a GAM Model +This script will write out all design and contrast files +This function will run a f-test to compare a full and reduced model (a model with and without spline)
+ +gamRandomise(image, maskPath = NULL, formulaFull, formulaRed, subjData, + outDir, nsim = 500, thresh = 0.01, run = FALSE)+ +
image | +Input path of 'nifti' image or vector of path(s) to images. If multiple paths, the script will all mergeNiftis() and merge across time. |
+
---|---|
maskPath | +to mask. Must be a binary mask |
+
formulaFull | +Must be the formula of the full model (i.e. "~s(age,k=5)+sex+mprage_antsCT_vol_TBV") |
+
formulaRed | +Must be the formula of the reduced model (i.e. "~sex+mprage_antsCT_vol_TBV") |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
outDir | +output directory for randomise |
+
nsim | +Number of simulations |
+
thresh | +significance threshold |
+
run | +FALSE will only print randomise command but won't it |
+
Return randomise command
+ + ++if (FALSE) { + +subjData = mgcv::gamSim(1,n=400,dist="normal",scale=2) +OutDirRoot="Output Directory" +maskName="Path to mask" +imagePath="Path to output" +covsFormula="~s(age,k=5)+sex+mprage_antsCT_vol_TBV" +redFormula="~sex+mprage_antsCT_vol_TBV" + +gamRandomise(image = imagePath, maskPath = maskName, formulaFull = covsFormula, + formulaRed = redFormula, subjData = subjData, outDir = OutDirRoot) + +}
R/gamVoxel.R
+ gamVoxel.Rd
This function is able to run a Generalized Additive Model (GAM) using the mgcv package. +The analysis will run in all voxels in in the mask and will return the model fit for each voxel.
+ +gamVoxel(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gam() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to gam() |
+
List of models fitted to each voxel over the masked images passed to function.
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25)) +fm1 <- "~ s(x)" +models <- gamVoxel(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.183 +#> [1] "Parallel Models Ran"
R/gammCluster.R
+ gammCluster.Rd
This function is able to run a Generalized Additive Mixed Effects Model (GAMM) using the gamm4() function. +All clusters or Regions of Interest must be labeled with integers in the mask passed as an argument.
+ +gammCluster(image, mask, fourdOut = NULL, formula, randomFormula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. All clusters must be labeled with integers in the mask passed as an argument |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gamm4() |
+
randomFormula | +Random effects formula passed to gamm4() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use for the analysis |
+
... | +Additional arguments passed to gamm4() |
+
Returns list of models fitted to the mean voxel intensity a region or interest.
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,14),1,2), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), id = rep(1:5,5)) +fm1 <- "~ s(x)" +randomFormula <- "~(1|id)" +models <- gammCluster(image, mask, formula = fm1, + randomFormula = randomFormula, subjData = covs, ncores = 1, REML=TRUE)#> [1] "Created meanCluster Matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.127 +#> [1] "Parallel Models Ran"+
R/gammNIfTI.R
+ gammNIfTI.Rd
This function is able to run a Generalized Additive Model (GAMM) using the gamm4() function. +The analysis will run in all voxels within the mask and will return parametric and smooth coefficients. +The function will create parametric maps according to the model selected. +The function will return a p-map, t-map, z-map, p-adjusted-map for parametric terms and p-map, z-map, p-adjusted-map for smooth terms. +You can select which type of p-value correction you want done on the map
+ +gammNIfTI(image, mask, fourdOut = NULL, formula, randomFormula, subjData, + mc.preschedule = TRUE, ncores = 1, method = "none", residual = FALSE, + outDir = NULL, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gamm4() |
+
randomFormula | +Random effects formula passed to gamm4() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
method | +which method of correction for multiple comparisons (default is none) |
+
residual | +If set to TRUE then residuals maps will be returned along parametric maps |
+
outDir | +Path to the folder where to output parametric maps (Default is Null, only change if you want to write maps out) |
+
... | +Additional arguments passed to gamm4() |
+
Returns Parametric maps of the fitted models over the NIfTI image
+ + +++image <- oro.nifti::nifti(img = array(rnorm(1600, sd=10), dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,14), rep(1,2)), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = runif(25), id = rep(1:5,5)) +fm1 <- "~ s(x) + s(y)" +randomFormula <- "~(1|id)" +Maps <- gammNIfTI(image, mask, formula = fm1, + randomFormula = randomFormula, subjData = covs, ncores = 1, + method="fdr", REML=TRUE)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.56 +#> [1] "Parallel Models Ran" +#> [1] "Creating parametric maps" +#> [1] "Working with output of gam object"+ +
R/gammVoxel.R
+ gammVoxel.Rd
This function is able to run a Generalized Mixed Effects Model (GAMM) using the gamm4() function. +The analysis will run in all voxels within the mask and will return the model fit for each voxel.
+ +gammVoxel(image, mask, fourdOut = NULL, formula, randomFormula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gamm4() |
+
randomFormula | +Random effects formula passed to gamm4() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to gamm4() |
+
Returns list of models fitted to each voxel over the masked images passed to function.
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,14),1), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), id = rep(1:5,5)) +fm1 <- "~ s(x)" +randomFormula <- "~(1|id)" +models <- gammVoxel(image = image , mask = mask, formula = fm1, randomFormula = randomFormula, + subjData = covs, ncores = 1, REML=TRUE)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.414 +#> [1] "Parallel Models Ran"+
This function is internal. +This function creates list of formulas that will be passed for analysis.
+ +listFormula(x, formula)+ +
x | +Index of voxels to be analyzed |
+
---|---|
formula | +covariates to be included in the analysis |
+
++ +x <- 1 +fm1 <- "~ x1" +formula <- listFormula(x, formula = fm1)
R/lmCluster.R
+ lmCluster.Rd
This function is able to run a Linear Model using the stats package. +All clusters must be labeled with integers in the mask passed as an argument.
+ +lmCluster(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. All clusters must be labeled with integers in the mask passed as an argument |
+
fourdOut | +To be passed to mergeNifti. This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lm() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lm() |
+
Returns list of models fitted to the mean voxel intensity a region or interest.
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(1:4, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25)) +fm1 <- "~ x" +models <- lmCluster(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1)#> [1] "Created meanCluster Matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.003 +#> [1] "Parallel Models Ran"
R/lmNIfTI.R
+ lmNIfTI.Rd
This function is able to run a Linear Model using the stats package. +The analysis will run in all voxels in in the mask and will return parametric coefficients. +The function will create parametric maps according to the model selected. +The function will return a p-map, t-map, z-map, p-adjusted-map for parametric terms and p-map, z-map, p-adjusted-map for smooth terms. +You can select which type of p-value correction you want done on the map.
+ +lmNIfTI(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, method = "none", residual = FALSE, + outDir = NULL, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lm() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
method | +which method of correction for multiple comparisons (default is none) |
+
residual | +If set to TRUE then residuals maps will be returned along parametric maps |
+
outDir | +Path to the folder where to output parametric maps (Default is Null, only change if you want to write maps out) |
+
... | +Additional arguments passed to lm() |
+
Return parametric maps of the fitted models
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = runif(25)) +fm1 <- "~ x + y" +Maps <- lmNIfTI(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1, method="fdr")#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.029 +#> [1] "Parallel Models Ran" +#> [1] "Creating parametric maps" +#> [1] "Working with output from lm model"
R/lmVoxel.R
+ lmVoxel.Rd
This function is able to run a Linear Model using the stats package. +The analysis will run in all voxels in in the mask and will return the model fit for each voxel.
+ +lmVoxel(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lm() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lm() |
+
Returns list of models fitted to each voxel over the masked images passed to function.
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25)) +fm1 <- "~ x" +models <- lmVoxel(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.021 +#> [1] "Parallel Models Ran"
R/lmerCluster.R
+ lmerCluster.Rd
This function is able to run a LME using the lmer() function. +All clusters or region of interest must be labeled with integers in the mask passed as an argument. +The function relies on lmerTest to create p-values using the Satterthwaite Approximation.
+ +lmerCluster(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. All clusters must be labeled with integers in the mask passed as an argument |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lmer() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lmer() |
+
Returns list of models fitted to the mean voxel intensity a region or interest.
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,14),1,2), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), id = rep(1:5,5)) +fm1 <- "~ x + (1|id)" +models <- lmerCluster(image, mask, formula = fm1, subjData = covs, ncores = 1, REML=TRUE)#> [1] "Created meanCluster Matrix" +#> [1] "Created formula list" +#> [1] "Running test model"#>#> [1] "Running parallel models"#>#>#> elapsed +#> 0.09 +#> [1] "Parallel Models Ran"+
R/lmerNIfTI.R
+ lmerNIfTI.Rd
This function is able to run a Linear Mixed Effect Model using the lmer() function. +The function relies on lmerTest to create p-values using the Satterthwaite Approximation. +The analysis will run in all voxels in in the mask and will return parametric coefficients. +The function will create parametric maps according to the model selected. +The function will return a p-map, t-map, z-map, p-adjusted-map for parametric terms and p-map, z-map, p-adjusted-map for smooth terms. +You can select which type of p-value correction you want done on the map.
+ +lmerNIfTI(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, method = "none", residual = FALSE, + outDir = NULL, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lmer() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
method | +which method of correction for multiple comparisons (default is none) |
+
residual | +If set to TRUE then residuals maps will be returned along parametric maps |
+
outDir | +Path to the folder where to output parametric maps (Default is Null, only change if you want to write maps out) |
+
... | +Additional arguments passed to lmer() |
+
Returns parametric maps of the fitted models
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,14),1,1), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), id = rep(1:5,5)) +fm1 <- "~ x + (1|id)" +Maps <- lmerNIfTI(image, mask, formula = fm1, subjData = covs, method="fdr", ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model"#>#> [1] "Running parallel models"#>#>#>#>#>#>#>#>#> elapsed +#> 0.465 +#> [1] "Parallel Models Ran" +#> [1] "Creating parametric maps" +#> [1] "Working with output from lmerTest model"+
R/lmerVoxel.R
+ lmerVoxel.Rd
This function is able to run a Linear Mixed Effect Model using the lmer() function. +The analysis will run in all voxels in in the mask and will return parametric coefficients at each voxel +The function relies on lmerTest to create p-values using the Satterthwaite Approximation.
+ +lmerVoxel(image, mask, fourdOut = NULL, formula = NULL, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will call mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lmer() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lmer() |
+
returns list of models fitted to each voxel over the masked images passed to function.
+ + ++if (FALSE) { + +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), id = rep(1:5,5)) +fm1 <- "~ x + (1|id)" +models <- lmerVoxel(image, mask, formula = fm1, subjData = covs, ncores = 1, REML=T) +}
This function merges nifti images together in a specified direction.
+ +mergeNiftis(inputPaths, direction = c("x", "y", "z", "t"), outfile = NULL, + ncores = 1, ...)+ +
inputPaths | +This is a vector of input filenames (character) |
+
---|---|
direction | +This is the direction you want to merge your image over, x, y, z, or t |
+
outfile | +This is the path and file name to save the Nifti file without the suffix, passed to writeNIfTI |
+
ncores | +Number of cores to be used for this operation |
+
... | +Additional arguments passed to readNIfTI |
+
Returns a merged NIfTI image
+ + +This function create parametric maps according from model parametric tables or analysis of variance tables. +The function will return a p-map, t-map, signed z-map, p-adjusted-map for parametric terms and p-map, z-map, p-adjusted-map for smooth terms. +Additionally the function will return a p-map, F-map, p-to-z-map, and p-adjusted-map if the input is ANOVA. +You can select which type of p-value correction you want done on the map. The z-maps are signed just like FSL.
+ +parMap(parameters, mask, method = "none", outDir = NULL)+ +
parameters | +list of parametric and smooth table coefficients or ANOVA (like the output from vlmParam, vgamParam, anovalmVoxel) |
+
---|---|
mask | +Input mask of type 'nifti' or path to one. Must be a binary mask or a character. Must match the mask passed to one of vlmParam, vgamParam, vgamm4Param, vlmerParam |
+
method | +which method of correction for multiple comparisons (default is none) |
+
outDir | +Path to the folder where to output parametric maps (Default is Null, only change if you want to write maps out) |
+
Return parametric maps of the fitted models
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = runif(25)) +fm1 <- "~ x + y" +models <- vlmParam(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.033 +#> [1] "Parallel Models Ran"Maps <- parMap(models, mask, method="fdr")#> [1] "Working with output from lm model"
GAM plotting using ggplot2
+ +plotGAM(gamFit, smooth.cov, groupCovs = NULL, orderedAsFactor = T, + rawOrFitted = F, plotCI = T)+ +
gamFit | +fitted gam model as produced by mgcv::gam() |
+
---|---|
smooth.cov | +(character) name of smooth term to be plotted |
+
groupCovs | +(character) name of group variable to plot by, if NULL (default) then there are no groups in plot |
+
orderedAsFactor | +if TRUE then the model is refitted with ordered variables as factors. |
+
rawOrFitted | +If FALSE (default) then only smooth terms are plotted; if rawOrFitted = "raw" then raw values are plotted against smooth; if rawOrFitted = "fitted" then fitted values are plotted against smooth |
+
plotCI | +if TRUE (default) upper and lower confidence intervals are added at 2 standard errors above and below the mean |
+
Returns a ggplot object that can be visualized using the print() function
+ +Other Plotting: plotGAMM
++data <- data.frame(x = rep(1:20, 2), group = rep(1:2, each = 20)) +set.seed(1) +data$y <- (data$x^2)*data$group*3 + rnorm(40, sd = 200) +data$group <- ordered(data$group) + +gam <- mgcv::gam(y ~ s(x) + group, data=data) + +plot1 <- plotGAM(gamFit = gam, smooth.cov = "x", groupCovs = NULL, + rawOrFitted = "raw", plotCI=TRUE, orderedAsFactor = FALSE)#> Warning: There are one or more factors in the model fit, please consider plotting by group since plot might be unprecisegam <- mgcv::gam(y ~ s(x) + group + s(x, by=group), data=data) +plot2 <- plotGAM(gamFit = gam, smooth.cov = "x", groupCovs = "group", + rawOrFitted = "raw", orderedAsFactor = FALSE)
GAMM plotting using ggplot2
+ +plotGAMM(gammFit, smooth.cov, groupCovs = NULL, orderedAsFactor = F, + rawOrFitted = F, plotCI = T, grouping = NULL)+ +
gammFit | +fitted gam model as produced by gamm4::gamm() |
+
---|---|
smooth.cov | +(character) name of smooth term to be plotted |
+
groupCovs | +(character) name of group variable to plot by, if NULL (default) then there are no groups in plot |
+
orderedAsFactor | +Disabled |
+
rawOrFitted | +If FALSE (default) then only smooth terms are plotted; if rawOrFitted = "raw" then raw values are plotted against smooth; if rawOrFitted = "fitted" then fitted values are plotted against smooth |
+
plotCI | +if TRUE (default) upper and lower confidence intervals are added at 2 standard errors above and below the mean |
+
grouping | +(character) Name of variable that you want to use as the group argument in ggplot2::aes(), useful for better visualization of longitudinal data, (default is NULL) |
+
Returns a ggplot object that can be visualized using the print() function
+ +Other Plotting: plotGAM
++set.seed(1) +data <- data.frame(x = (seq(.25,25, .25) +rnorm(100)), group = rep(1:2, 5), z=rnorm(100), + index.rnorm = rep(rnorm(50, sd = 50), 2), index.var = rep(1:50, 2)) +data$y <- (data$x)*data$group*10 + rnorm(100, sd = 700) + data$index.rnorm + data$z +data$group <- ordered(data$group) + + +gamm <- gamm4::gamm4(y ~ + s(x) + s(x, by=group) + z + group, data=data, random = ~ (1|index.var)) + + +plot <- plotGAMM(gammFit <- gamm, smooth.cov <- "x", groupCovs = "group", + plotCI <- T, rawOrFitted = "raw", grouping = "index.var") + +plot2 <- plotGAMM(gammFit <- gamm, smooth.cov <- "x", groupCovs = "group", + plotCI <- T, rawOrFitted = "fitted", grouping = "index.var")
R/rgamParam.R
+ rgamParam.Rd
This function is able to run a Generalized Additive Model (GAM) using the mgcv package. +The analysis will run in all voxels in in the mask and will return parametric and smooth coefficients.
+ +rgamParam(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gam() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to gam() |
+
Return list of parametric and spline coefficients (include standard errors and p-values) fitted to each voxel over the masked images passed to function.
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25)) +fm1 <- "~ s(x)" +models <- rgamParam(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1, method="REML")#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.78 +#> [1] "Parallel Models Ran"
R/rgamm4Param.R
+ rgamm4Param.Rd
This function is able to run a Generalized Mixed Effects Model (GAMM) using the gamm4() function. +The analysis will run in all voxels in in the mask and will return parametric and smooth coefficients.
+ +rgamm4Param(image, mask, fourdOut = NULL, formula, randomFormula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gamm4() |
+
randomFormula | +Random effects formula passed to gamm4() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to gamm4() |
+
Return list of parametric and spline coefficients (include standard errors and p-values) fitted to each voxel over the masked images passed to function.
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,15), 1), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = runif(25), id = rep(1:5,5)) +fm1 <- "~ s(x) + s(y)" +randomFormula <- "~(1|id)" +models <- rgamm4Param(image, mask, formula = fm1, + randomFormula = randomFormula, subjData = covs, ncores = 1, REML=TRUE)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.3 +#> [1] "Parallel Models Ran"+
R/rlmParam.R
+ rlmParam.Rd
This function is able to run a Linear Model using the stats package. +The analysis will run in all voxels in in the mask and will and will return parametric coefficients at each voxel.
+ +rlmParam(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lm() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lm() |
+
Return list of parametric and spline coefficients (include standard errors and p-values) fitted to each voxel over the masked images passed to function.
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = runif(25)) +fm1 <- "~ x + y" +models <- rlmParam(image=image, mask=mask, formula=fm1, subjData=covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.045 +#> [1] "Parallel Models Ran"
R/rlmerParam.R
+ rlmerParam.Rd
This function is able to run a Linear Mixed Effect Model using the lmer() function. +The analysis will run in all voxels in in the mask and will return the model fit for each voxel. +The function relies on lmerTest to create p-values using the Satterthwaite Approximation.
+ +rlmerParam(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lmer() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lmer() |
+
Return list of parametric and spline coefficients (include standard errors and p-values) fitted to each voxel over the masked images passed to function.
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,15),1), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), id = rep(1:5,5)) +fm1 <- "~ x + (1|id)" +models <- rlmerParam(image, mask, formula = fm1, subjData = covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model"#>#> [1] "Running parallel models"#>#>#>#>#> elapsed +#> 0.286 +#> [1] "Parallel Models Ran"+
This function create parametric maps according from model parametric tables or analysis of variance tables. +The function will return a p-map, t-map, signed z-map, p-adjusted-map for parametric terms and p-map, z-map, p-adjusted-map for smooth terms. +Additionally the function will return a p-map, F-map, p-to-z-map, and p-adjusted-map if the input is ANOVA. +This function will return a residual map that can be used for cluster correction +You can select which type of p-value correction you want done on the map. The z-maps are signed just like FSL.
+ +rparMap(parameters, image, mask, method, ncores, mc.preschedule, + outDir = NULL)+ +
parameters | +list of parametric and smooth table coefficients or ANOVA (like the output from vlmParam, vgamParam, anovalmVoxel) |
+
---|---|
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
mask | +Input mask of type 'nifti' or path to one. Must be a binary mask or a character. Must match the mask passed to one of vlmParam, vgamParam, vgamm4Param, vlmerParam |
+
method | +which method of correction for multiple comparisons (default is none) |
+
ncores | +Number of cores to use |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
outDir | +Path to the folder where to output parametric maps (Default is Null, only change if you want to write maps out) |
+
Return parametric maps of the fitted models
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = runif(25)) +fm1 <- "~ x + y" +models <- rlmParam(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.046 +#> [1] "Parallel Models Ran"Maps <- rparMap(models, image, mask, method="fdr", ncores = 1, mc.preschedule=TRUE)#> [1] "Working with output from lm model"
This function is able to mask a 4-Dimensional image and create a matrix from it. +Each column represents the same voxel in the xyz array while the rows represent the t-dimension.
+ +ts2matrix(image, mask)+ +
image | +Input image of type 'nifti' |
+
---|---|
mask | +Input mask of type 'nifti'. Must be a binary mask |
+
+
This function is able to output the mean voxel intensity over a cluster. +Each column represents a cluster and the rows represent the t-dimension.
+ +ts2meanCluster(image, mask)+ +
image | +Input image of type 'nifti' |
+
---|---|
mask | +Input mask of type 'nifti'. Must have different clusters labeled as integers. |
+
+
R/vgamParam.R
+ vgamParam.Rd
This function is able to run a Generalized Additive Model (GAM) using the mgcv package. +The analysis will run in all voxels in in the mask and will return parametric and smooth coefficients.
+ +vgamParam(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gam() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to gam() |
+
Return list of parametric and spline coefficients (include standard errors and p-values) fitted to each voxel over the masked images passed to function.
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25)) +fm1 <- "~ s(x)" +models <- vgamParam(image=image, mask=mask, + formula=fm1, subjData=covs, ncores = 1, method="REML")#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.641 +#> [1] "Parallel Models Ran"
R/vgamm4Param.R
+ vgamm4Param.Rd
This function is able to run a Generalized Mixed Effects Model (GAMM) using the gamm4() function. +The analysis will run in all voxels in in the mask and will return parametric and smooth coefficients.
+ +vgamm4Param(image, mask, fourdOut = NULL, formula, randomFormula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to gamm4() |
+
randomFormula | +Random effects formula passed to gamm4() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to gamm4() |
+
Return list of parametric and spline coefficients (include standard errors and p-values) fitted to each voxel over the masked images passed to function.
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,15), 1), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = runif(25), id = rep(1:5,5)) +fm1 <- "~ s(x) + s(y)" +randomFormula <- "~(1|id)" +models <- vgamm4Param(image, mask, formula = fm1, + randomFormula = randomFormula, subjData = covs, ncores = 1, REML=TRUE)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.265 +#> [1] "Parallel Models Ran"+
R/vlmParam.R
+ vlmParam.Rd
This function is able to run a Linear Model using the stats package. +The analysis will run in all voxels in in the mask and will and will return parametric coefficients at each voxel.
+ +vlmParam(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lm() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lm() |
+
Return list of parametric and spline coefficients (include standard errors and p-values) fitted to each voxel over the masked images passed to function.
+ + ++image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(0:1, dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), y = runif(25)) +fm1 <- "~ x + y" +models <- vlmParam(image=image, mask=mask, formula=fm1, subjData=covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model" +#> [1] "Running parallel models" +#> elapsed +#> 0.025 +#> [1] "Parallel Models Ran"
R/vlmerParam.R
+ vlmerParam.Rd
This function is able to run a Linear Mixed Effect Model using the lmer() function. +The analysis will run in all voxels in in the mask and will return the model fit for each voxel. +The function relies on lmerTest to create p-values using the Satterthwaite Approximation.
+ +vlmerParam(image, mask, fourdOut = NULL, formula, subjData, + mc.preschedule = TRUE, ncores = 1, ...)+ +
image | +Input image of type 'nifti' or vector of path(s) to images. If multiple paths, the script will all mergeNifti() and merge across time. |
+
---|---|
mask | +Input mask of type 'nifti' or path to mask. Must be a binary mask |
+
fourdOut | +To be passed to mergeNifti, This is the path and file name without the suffix to save the fourd file. Default (NULL) means script won't write out 4D image. |
+
formula | +Must be a formula passed to lmer() |
+
subjData | +Dataframe containing all the covariates used for the analysis |
+
mc.preschedule | +Argument to be passed to mclapply, whether or not to preschedule the jobs. More info in parallel::mclapply |
+
ncores | +Number of cores to use |
+
... | +Additional arguments passed to lmer() |
+
Return list of parametric and spline coefficients (include standard errors and p-values) fitted to each voxel over the masked images passed to function.
+ + +++ +image <- oro.nifti::nifti(img = array(1:1600, dim =c(4,4,4,25))) +mask <- oro.nifti::nifti(img = array(c(rep(0,15),1), dim = c(4,4,4,1))) +set.seed(1) +covs <- data.frame(x = runif(25), id = rep(1:5,5)) +fm1 <- "~ x + (1|id)" +models <- vlmerParam(image, mask, formula = fm1, subjData = covs, ncores = 1)#> [1] "Created time series to matrix" +#> [1] "Created formula list" +#> [1] "Running test model"#>#> [1] "Running parallel models"#>#>#>#>#> elapsed +#> 0.195 +#> [1] "Parallel Models Ran"+