Skip to content

Commit

Permalink
fix bug in handling of numeric versions
Browse files Browse the repository at this point in the history
* r-devel now refuses to compare a number with a numeric_version
* reported by CRAN (Kurt Hornik, who also kindly pointed out the precise error)
  • Loading branch information
jefferis committed Aug 25, 2023
1 parent e401a43 commit 9d2aca8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
15 changes: 10 additions & 5 deletions R/cmtk_io.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ read.cmtk<-function(con, CheckLabel=TRUE){
}

#' Write out CMTK registration list to folder
#'
#'
#' @details Note that transformation in the forward direction (i.e. sample->ref)
#' e.g. as calculated from a set of landmarks where set 1 is the sample is
#' e.g. as calculated from a set of landmarks where set 1 is the sample is
#' considered an inverse transformation by the IGS software. So in order to
#' use such a transformation as an initial affine with the registration
#' command the switch --initial-inverse must be used specifying the folder
Expand All @@ -168,11 +168,16 @@ read.cmtk<-function(con, CheckLabel=TRUE){
#' by default.
#' @param reglist List specifying CMTK registration parameters
#' @param foldername Path to registration folder (usually ending in .list)
#' @param version CMTK version for registration (default 2.4)
#' @param version CMTK version for registration (default 2.4). Will be converted
#' to character vector if not already.
#' @export
#' @family cmtk-io
write.cmtkreg<-function(reglist, foldername, version="2.4"){
if(!is.null(attr(reglist, 'version')) && (attr(reglist, 'version') != version)) warning("Specified version (", version, ") is not the same as the version stored in the reglist object (", attr(reglist, 'version'), ").")
write.cmtkreg<-function(reglist, foldername, version="2.4") {
if(!is.character(version))
version=as.character(version)
if(!is.null(attr(reglist, 'version')) && (attr(reglist, 'version') != version))
warning("Specified version (", version, ") is not the same as the version stored in the reglist object (", attr(reglist, 'version'), ").")

dir.create(foldername, showWarnings=FALSE, recursive=TRUE)
if(!is.list(reglist)) reglist=cmtkreglist(reglist)
write.cmtk(reglist,file.path(foldername, "registration"),
Expand Down
5 changes: 3 additions & 2 deletions man/write.cmtkreg.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-cmtk_io.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test_that("read.cmtk and write.cmtk can round-trip a registration file", {
reglist=read.cmtkreg(reg)
tf=tempfile('dofv1.1wshears_copy',fileext='.list')
on.exit(unlink(tf,recursive=TRUE))
write.cmtkreg(reglist,foldername=tf,version=1.1)
write.cmtkreg(reglist, foldername=tf, version=1.1)
ctf=cmtkreg(tf,returnDir=TRUE)
# equivalent because we are not interested in the file.info attributes
# though this also removes version attribute which might be worth a thought
Expand Down

0 comments on commit 9d2aca8

Please sign in to comment.