Skip to content

Commit

Permalink
Preparing to pass CHECK
Browse files Browse the repository at this point in the history
  • Loading branch information
neuroimaginador committed Apr 30, 2019
1 parent e2adea3 commit 5602461
Show file tree
Hide file tree
Showing 24 changed files with 248 additions and 215 deletions.
10 changes: 10 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
^\./vignettes/resources/dti/dti_bvals\.csv$
^\./vignettes/resources/dti/dti_example\.nii\.gz$
^\./vignettes/resources/dti/dti_gradients\.csv$
^\./vignettes/resources/rsfMRI/anat\.nii\.gz$
^\./vignettes/resources/rsfMRI/data$
^\./vignettes/resources/rsfMRI/func\.nii\.gz$
^\./vignettes/resources/volumetry/bet$
^\./vignettes/resources/volumetry/input$
^\./vignettes/resources/volumetry/MNI152_T1_1mm\.nii\.gz$
^\./vignettes/resources/volumetry/parcellation$
^Meta$
^doc$
^README\.Rmd$
Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ Package: wf4ni
Type: Package
Title: Workflows for Neuroimaging
Version: 0.1.0
Date: 2018-01-04
Date: 2019-04-29
Author: Domingo López-Rodríguez [aut, cre]
Authors@R: person("Domingo", "López-Rodríguez", role = c("aut", "cre"), email = "[email protected]")
Maintainer: Domingo Lopez-Rodriguez <[email protected]>
Maintainer: Domingo López-Rodríguez <[email protected]>
Description: The aim of this package is to provide a means to create reproducible workflows specifically designed for Neuroimaging.
License: GPL (>= 2)
URL: https://github.com/neuroimaginador/wf4ni
BugReports: https://github.com/neuroimaginador/wf4ni/issues
Imports: stringr, styler, devtools, igraph, RCurl, R6, RNifti, neurobase, oro.nifti, scales, zip, crayon, prettyunits, pryr, purrr, methods, utils
Imports: stringr, styler, devtools, igraph, RCurl, R6, RNifti, neurobase, oro.nifti, scales, zip, crayon, prettyunits, pryr, purrr, methods, utils, Rgraphviz, grid, ANTsRCore, graph
Suggests:
testthat,
knitr,
Expand Down
16 changes: 14 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ export(NIflow)
export(add)
export(download_repo)
export(execute)
export(get_atlas)
export(get_dataset)
export(get_flow)
export(get_flows_dir)
export(merge)
Expand All @@ -14,14 +12,28 @@ import(crayon)
import(igraph)
import(stringr)
import(zip)
importFrom(ANTsRCore,antsImageWrite)
importFrom(R6,R6Class)
importFrom(RCurl,url.exists)
importFrom(Rgraphviz,agopen)
importFrom(grDevices,dev.off)
importFrom(grDevices,png)
importFrom(graph,graphAM)
importFrom(grid,convertX)
importFrom(grid,convertY)
importFrom(grid,grid.newpage)
importFrom(grid,grob)
importFrom(grid,stringWidth)
importFrom(grid,unit)
importFrom(igraph,add_edges)
importFrom(igraph,add_vertices)
importFrom(igraph,as_adj)
importFrom(igraph,make_empty_graph)
importFrom(igraph,topo_sort)
importFrom(methods,as)
importFrom(methods,formalArgs)
importFrom(neurobase,readnii)
importFrom(neurobase,writenii)
importFrom(prettyunits,pretty_bytes)
importFrom(pryr,object_size)
importFrom(pryr,partial)
Expand Down
127 changes: 0 additions & 127 deletions R/datasets.R

This file was deleted.

1 change: 1 addition & 0 deletions R/flow.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @description This internal function provides an environment usable from the class NIflow.
#'
#' @param name (character) Name of the flow
#' @param work_dir (character) Path of the temporary folder where to store results
#' @param inputs (list of names) List of inputs used in the flow, Default: list()
#'
#' @return A NIflow object.
Expand Down
28 changes: 15 additions & 13 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@

##%######################################################%##
# #
#### PLOTTING ####
# #
##%######################################################%##

# Auxiliary function for plotting
#' @importFrom grid unit stringWidth convertX convertY grob
#' @importFrom graph graphAM
#' @importFrom methods as
#' @importFrom igraph as_adj
#' @importFrom Rgraphviz agopen
#'
.plot_flow <- function(flow,
to_file = "") {

nWi <- function(labels, margin) {

library(grid)

result <- unit(0, "inch")
for (label in labels) result <- result + stringWidth(label) +
unit(margin$rl * 2, "inch")
Expand All @@ -25,8 +28,6 @@

nHi <- function(labels, margin) {

library(grid)

result <- unit(1, "lines") + unit(margin$tb * 2, "inch")
if (length(labels) > 1)
result <- result + unit(margin$otb * 2, "inch")
Expand All @@ -36,8 +37,8 @@

stopifnot(inherits(flow, "NIflow"))

suppressPackageStartupMessages(library(grid))
suppressPackageStartupMessages(library(Rgraphviz))
requireNamespace("grid", quietly = TRUE)
requireNamespace("Rgraphviz", quietly = TRUE)

# Define color of each node as its type
# num_types <- length(unique(V(flow$graph)$type))
Expand Down Expand Up @@ -119,17 +120,18 @@
#' @description This function plots a flow using \link{igraph} plotting capabilities.
#'
#' @param flow (a NIflow object) The flow.
#' @param to_file (character) Path to a file to save the graph. If not present, plots the flow to the screen. Otherwise, it is stored in a PNG file with the given name.
#'
#' @return Nothing
#'
#' @seealso
#' \code{\link[threejs]{graphjs}}

#' \code{\link[igraph]{layout_with_sugiyama}}

#' \code{\link[scales]{alpha}},\code{\link[scales]{hue_pal}}
#' @import igraph
#' @importFrom scales alpha hue_pal
#' @importFrom grid unit stringWidth convertX convertY grob grid.newpage
#' @importFrom graph graphAM
#' @importFrom methods as
#' @importFrom igraph as_adj
#' @importFrom Rgraphviz agopen
#' @importFrom grDevices dev.off png
#'
plot <- function(flow,
to_file = "") {
Expand Down
15 changes: 11 additions & 4 deletions R/save_result.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# Save an object to the temp folder.
#' @importFrom neurobase writenii
#' @importFrom ANTsRCore antsImageWrite
#'
.save_result <- function(value, name, folder = tempdir()) {

if (inherits(value, "nifti") | inherits(value, "niftiImage")) {

requireNamespace("neurobase", quietly = TRUE)

my_file <- file.path(folder, paste0(name, ".nii.gz"))

neurobase::writenii(nim = value,
filename = my_file)
writenii(nim = value,
filename = my_file)

return(invisible(TRUE))

}

if (inherits(value, "antsImage")) {

requireNamespace("ANTsRCore", quietly = TRUE)

my_file <- file.path(folder, paste0(name, ".nii.gz"))

ANTsRCore::antsImageWrite(image = value,
filename = my_file)
antsImageWrite(image = value,
filename = my_file)

return(invisible(TRUE))

Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ In `wf4ni`, a _flow_ is an ordered collection of processes that convert inputs i

By defining the appropriate functions, one can model the pipeline in the correct order and obtain a flow as the one depicted in the following figure:

![A sample workflow](img/flow.png)
![A sample workflow](vignettes/img/flow.png)

Original inputs in the _flow_ are _I1_, _I2_ and _I3_ (in blue). Other nodes represent the output of a given function, using the incident nodes as inputs for that function.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ By defining the appropriate functions, one can model the pipeline in the
correct order and obtain a flow as the one depicted in the following
figure:

![A sample workflow](img/flow.png)
![A sample workflow](vignettes/img/flow.png)

Original inputs in the *flow* are *I1*, *I2* and *I3* (in blue). Other
nodes represent the output of a given function, using the incident nodes
Expand Down
4 changes: 3 additions & 1 deletion man/dot-create_flow.Rd

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

25 changes: 0 additions & 25 deletions man/get_atlas.Rd

This file was deleted.

25 changes: 0 additions & 25 deletions man/get_dataset.Rd

This file was deleted.

Loading

0 comments on commit 5602461

Please sign in to comment.