Skip to content

Commit

Permalink
added find_mrs_files function
Browse files Browse the repository at this point in the history
  • Loading branch information
martin3141 committed Sep 14, 2023
1 parent 2a9e50f commit 59cda3f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: spant
Type: Package
Title: MR Spectroscopy Analysis Tools
Version: 2.15.9000
Date: 2023-08-03
Version: 2.15.0
Date: 2023-09-14
Authors@R: c(
person("Martin", "Wilson", email = "[email protected]",
role = c("cre", "aut"), comment = c(ORCID = "0000-0002-2089-3956")),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# spant 2.15.0
* An SNR estimate of zero in comb_coils is now a failure case.
* Bug fix for GE pfile reader header revision 20.
* Added a function for finding valid MRS files : find_mrs_files.

# spant 2.14.0
* Added vline argument to stackplot function.
Expand Down
27 changes: 27 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
#' Find valid MRS data files recursively from a directory path.
#' @param dir a directory path.
#' @return a vector of valid MRS data files.
#' @examples
find_mrs_files <- function(dir) {

# recursively find all files
all_files <- list.files(dir, recursive = TRUE, full.names = TRUE)

# empty vector of found files
mrs_files <- c()

# check each file, catching any errors
for (file in all_files) {
tryCatch(
{
dummy <- read_mrs(file)
mrs_files <- c(mrs_files, file)
},
error = function(cond) {
}
)
}
return(mrs_files)
}


#' Apply a function over specified array axes.
#' @param x an array.
#' @param axes a vector of axes to apply fun over.
Expand Down
17 changes: 17 additions & 0 deletions man/find_mrs_files.Rd

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

0 comments on commit 59cda3f

Please sign in to comment.