Skip to content

Commit

Permalink
version 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
muschellij2 authored and cran-robot committed Aug 13, 2018
1 parent 923ee8a commit 01d6476
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 23 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: kirby21.base
Type: Package
Title: Example Data from the Multi-Modal MRI 'Reproducibility' Resource
Version: 1.6.0
Date: 2017-10-10
Version: 1.7.0
Date: 2018-08-13
Author: John Muschelli <muschellij2@gmail.com>
Maintainer: John Muschelli <muschellij2@gmail.com>
Description: Multi-modal magnetic resonance imaging ('MRI')
Expand All @@ -13,11 +13,11 @@ License: GPL-2
LazyData: true
LazyLoad: true
Imports: utils, stats, git2r
RoxygenNote: 6.0.1.9000
RoxygenNote: 6.1.0
URL: https://www.nitrc.org/projects/multimodal/,
http://dx.doi.org/10.1016/j.neuroimage.2010.11.047
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2017-10-10 15:47:59 UTC; johnmuschelli
Packaged: 2018-08-13 15:38:48 UTC; johnmuschelli
Repository: CRAN
Date/Publication: 2017-10-11 10:30:08 UTC
Date/Publication: 2018-08-13 16:00:03 UTC
18 changes: 10 additions & 8 deletions MD5
@@ -1,11 +1,12 @@
0b5f46ca021a492564cbae88d92933c2 *DESCRIPTION
2771c376a0fd6a0ef9c3574b0dfff669 *NAMESPACE
ec2d168c139813ea91698a9714ad1859 *NEWS.md
680d95f5b08e3fde31a0bbe599514561 *DESCRIPTION
842959f5a65c65e7d526ff99c0c9d95b *NAMESPACE
9f99cd179b335821e44e589b8d00fd2f *NEWS.md
fb3e2ffb85ea7152093c9957c9055d5e *R/all_modalities.R
1a8d4083060c1826c6a178f2d2d4a20c *R/copy_kirby21_data.R
0341f7a80b040e589e8ee367e8d5411c *R/download_kirby21_data.R
7ec94da3fcd1e5d4b5525415c94b7321 *R/delete_kirby21_data.R
87bc58add0dfc531671acd223781f585 *R/download_kirby21_data.R
0a7065b1cdf0d8b5af4a490fc17e26d8 *R/get_ids.R
064695f3876bc517b1e0dde3dc18f335 *R/get_image_filenames.R
ea8d002c5f03d34a8657fd9692db9634 *R/get_image_filenames.R
4292e61f49e4f9e82c7ce7ed6b3611ac *R/get_par_filenames.R
9dd958acf733d2c88c37cb4a6fc96356 *R/kirby21_demog.R
baf061417d9e5cbf22217bb77d161369 *R/modality_df.R
Expand All @@ -15,11 +16,12 @@ b9807347392fceecad9e148fe1a17335 *data/subject_id_to_visit_id.rda
ae7db4099be276e1cdcb1e96d92af51a *inst/CITATION
b30671fc022fd2dae26186285057be36 *man/all_modalities.Rd
ab7062fb18c57e22f71dc138d7960ae3 *man/copy_kirby21_data.Rd
c7373161636558920def16543d66827a *man/download_kirby21_data.Rd
0b9f1a180e51dc3f9eb2da3b7d494023 *man/delete_kirby21_data.Rd
42bf314cc76513a8add8d72f0685d5b6 *man/download_kirby21_data.Rd
f7a607c07a59712c921dc3c95f40ca66 *man/get_ids.Rd
eaa5db5b8ad10dac75ebd990c11444ae *man/get_image_filenames.Rd
c1437bc9239af54cf55cb77b9ea82c90 *man/get_image_filenames_df.Rd
f40d6828276b4037abb2a028f1c49f16 *man/get_par_filenames.Rd
40eb7f79eb82fd3c8afdda41921cf10a *man/get_image_filenames_df.Rd
fd0cac41994b4d9e2ebddc1c966efa93 *man/get_par_filenames.Rd
fa7b4abb0dc2361174afc7fa7c812fa2 *man/kirby21_demog.Rd
9dd5bacfb252c30db714051996af881c *man/modality_df.Rd
365975275fcdabca8ca7a2823ef31f47 *man/subject_id_to_visit_id.Rd
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -2,6 +2,7 @@

export(all_modalities)
export(copy_kirby21_data)
export(delete_kirby21_data)
export(download_kirby21_data)
export(get_ids)
export(get_image_filenames)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
@@ -1,3 +1,10 @@
# kirby21.base 1.7.0

* Added options for deleting data with `delete_kirby21_data`.

* Added option for `outdir` so that you can download the data to a different
directory than the package path as per CRAN rules.

# kirby21.base 1.6

* Data is now downloaded and directories are created if necessary versus
Expand Down
25 changes: 25 additions & 0 deletions R/delete_kirby21_data.R
@@ -0,0 +1,25 @@
#' @title Delete Kirby21 Imaging Data
#' @description This function allows users to remove specific
#' modalities for Kirby21 data sets. This allows this package to be
#' on CRAN
#'
#' @param modality modality of images that are to be downloaded. You
#' must have the package downloaded for that modality.
#'
#' @return Nothing is returned
#' @export
delete_kirby21_data = function(
modality = kirby21.base::all_modalities()
){

modality = match.arg(modality)
fnames = get_image_filenames(
modalities = modality,
ids = get_ids(),
FALSE)
if (!is.null(fnames)) {
file.remove(fnames)
}
return(invisible(NULL))
}

17 changes: 13 additions & 4 deletions R/download_kirby21_data.R
Expand Up @@ -10,20 +10,24 @@
#' @param force If the package of that modality is not installed stop. If
#' \code{force = FALSE}, then this will download the data but not
#' really install the package.
#' @param outdir output directory for files to download. It will
#' default to the directory of the corresponding package for the data.
#'
#' @return A logical indicating the data is there.
#' @export
#' @importFrom git2r clone
download_kirby21_data = function(
modality = kirby21.base::all_modalities(),
progress = TRUE,
force = FALSE){
force = FALSE,
outdir = NULL){

modality = match.arg(modality)
fnames = get_image_filenames(
modalities = modality,
ids = get_ids(),
warn = !force)
warn = !force,
outdir = outdir)

mod_df = kirby21.base::modality_df()
pkg = mod_df[ mod_df$modality %in% modality, "package"]
Expand Down Expand Up @@ -84,7 +88,11 @@ download_kirby21_data = function(
files = list.files(path = datadir, recursive = TRUE)
files = files[ !(files %in% "CITATION")]
if (length(files) > 0) {
pkg_dir = system.file(package = pkg)
if (is.null(outdir)) {
pkg_dir = system.file(package = pkg)
} else {
pkg_dir = outdir
}
infiles = file.path(datadir, files)
outfiles = file.path(pkg_dir, files)
dn = dirname(outfiles)
Expand All @@ -98,7 +106,8 @@ download_kirby21_data = function(
good = tryCatch({
fnames = get_image_filenames(modalities = modality,
ids = get_ids(),
warn = !force)
warn = !force,
outdir = outdir)
TRUE
}, warning = function(w) FALSE)
return(good)
Expand Down
16 changes: 14 additions & 2 deletions R/get_image_filenames.R
Expand Up @@ -8,6 +8,8 @@
#' @param long if \code{TRUE}, each row is a subject, visit, modality pair
#' @param warn if \code{TRUE}, warnings will be produced when packages
#' are not installed
#' @param outdir output directory for files to download. It will
#' default to the directory of the corresponding package for the data.
#'
#' @return Data.frame of filenames
#'
Expand All @@ -22,7 +24,8 @@ get_image_filenames_df = function(
modalities = all_modalities(),
visits = c(1,2),
long = TRUE,
warn = TRUE){
warn = TRUE,
outdir = NULL){


##########################################
Expand Down Expand Up @@ -75,7 +78,16 @@ get_image_filenames_df = function(
}
}
df$filename = mapply(function(fname, pkg){
system.file( fname, package = pkg)
if (is.null(outdir)) {
file = system.file( fname, package = pkg)
return(file)
} else {
file = file.path(outdir, fname)
if (!file.exists(file)) {
file = ""
}
return(file)
}
}, df$filename, df$package)

df = df[ !(df$filename %in% ""), , drop = FALSE]
Expand Down
20 changes: 20 additions & 0 deletions man/delete_kirby21_data.Rd

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

5 changes: 4 additions & 1 deletion man/download_kirby21_data.Rd

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

5 changes: 4 additions & 1 deletion man/get_image_filenames_df.Rd

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

4 changes: 2 additions & 2 deletions man/get_par_filenames.Rd

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

0 comments on commit 01d6476

Please sign in to comment.