Skip to content

Commit

Permalink
Fixing run_first_all
Browse files Browse the repository at this point in the history
  • Loading branch information
muschellij2 committed Sep 22, 2017
1 parent 12fd69d commit fd70dbd
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 17 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: fslr
Type: Package
Title: Wrapper Functions for FSL ('FMRIB' Software Library) from Functional MRI
of the Brain ('FMRIB')
Version: 2.14
Version: 2.15.1
Authors@R: person(given = "John",
family = "Muschelli",
role = "cre",
Expand Down Expand Up @@ -35,3 +35,4 @@ Suggests:
BugReports: https://github.com/muschellij2/fslr/issues
SystemRequirements: FSL
RoxygenNote: 6.0.1.9000
Encoding: UTF-8
68 changes: 57 additions & 11 deletions R/run_first_all.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
#' @param affine specifies the affine registration matrix to standard space (optional)
#' @param opts (character) operations to be passed to \code{run_first_all}
#' @param verbose (logical) print out command before running
#' @return Result of \code{\link{system}}
#' @return List of results, including result of \code{\link{system}}
#' and some output files
#' @export
run_first_all <- function(img, oprefix,
brain_extracted = FALSE,
structures = NULL,
affine = NULL,
opts = "",
verbose = TRUE
){
run_first_all <- function(
img,
oprefix = tempfile(),
brain_extracted = FALSE,
structures = NULL,
affine = NULL,
opts = "",
verbose = TRUE
){
img = checkimg(img)
args = list(i = shQuote(img),
o = shQuote(oprefix))
Expand All @@ -25,29 +28,72 @@ run_first_all <- function(img, oprefix,
}
args$a = affine
args$structures = structures
if (verbose) {
args$v = ""
}

name_args = names(args)
if (is.null(name_args)) {
name_args = rep("", length(args))
}

stopifnot(length(name_args) == length(args))
name_args = paste0("-", name_args)
args = paste(name_args, args)
args = paste(args, sep = "", collapse = " ")

cmd = get.fsl()

##########################
# Add frontopts
##########################
cmd <- paste0(cmd, "run_first_all ", args)

if (verbose) {
message(cmd, "\n")
}
res = system(cmd, intern = FALSE)

return(res)
L = list(result = res)
stubs = c(
"_all_fast_firstseg.nii.gz",
"_all_fast_origsegs.nii.gz",
"-BrStem_first.bvars", "-BrStem_first.vtk",
"-L_Accu_first.bvars", "-L_Accu_first.vtk",
"-L_Amyg_first.bvars", "-L_Amyg_first.vtk",
"-L_Caud_first.bvars", "-L_Caud_first.vtk",
"-L_Hipp_first.bvars", "-L_Hipp_first.vtk",
"-L_Pall_first.bvars", "-L_Pall_first.vtk",
"-L_Puta_first.bvars", "-L_Puta_first.vtk",
"-L_Thal_first.bvars", "-L_Thal_first.vtk",
"-R_Accu_first.bvars", "-R_Accu_first.vtk",
"-R_Amyg_first.bvars", "-R_Amyg_first.vtk",
"-R_Caud_first.bvars", "-R_Caud_first.vtk",
"-R_Hipp_first.bvars", "-R_Hipp_first.vtk",
"-R_Pall_first.bvars", "-R_Pall_first.vtk",
"-R_Puta_first.bvars", "-R_Puta_first.vtk",
"-R_Thal_first.bvars", "-R_Thal_first.vtk",
".com", ".com2", ".com3", ".logs")

seg = paste0(
oprefix,
"_all_fast_firstseg.nii.gz")
if (file.exists(seg)) {
L$segmentation = seg
}
seg_list = paste0(
oprefix,
"_all_fast_origsegs.nii.gz")
if (file.exists(seg_list)) {
L$segmentation_list = seg_list
}

outfiles = paste0(oprefix, stubs)
outfiles = outfiles[ file.exists(outfiles)]

L$outfiles = outfiles

return(L)
}


Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ install:

environment:
global:
WARNINGS_ARE_ERORRS: 1
WARNINGS_ARE_ERRORS: 1

build_script:
- travis-tool.sh install_deps
Expand Down
1 change: 0 additions & 1 deletion man/fsldir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions man/run_first_all.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fd70dbd

Please sign in to comment.