Skip to content

Commit

Permalink
added usptream
Browse files Browse the repository at this point in the history
  • Loading branch information
muschellij2 committed Oct 17, 2018
2 parents 289317b + 13fe605 commit 50ec9b5
Show file tree
Hide file tree
Showing 36 changed files with 1,718 additions and 528 deletions.
4 changes: 3 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
^\.travis\.yml$
^.*\.Rproj$
^\.Rproj\.user$
^standalone
^appveyor.yml$
^standalone$
^revdep$
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
.Ruserdata
/revdep
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ sudo: false
cache: packages

install:
- Rscript -e 'install.packages(c("Rcpp","testthat","tractor.base","oro.nifti"))'
- Rscript -e 'install.packages(c("Rcpp","testthat","covr","tractor.base","oro.nifti"))'

script:
- R CMD build .
- R CMD check *tar.gz
- cd standalone && make clean && make CC="$(R CMD config CC)" CXX="$(R CMD config CXX)" && ./nii_info ../inst/extdata/example.nii.gz

after_success:
- Rscript -e 'covr::coveralls()'
19 changes: 9 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: RNifti
Version: 0.7.1
Date: 2017-09-13
Version: 0.9.0
Date: 2018-09-06
Title: Fast R and C++ Access to NIfTI Images
Authors@R: c(person("Jon","Clayden",role=c("cre","aut"),email="code@clayden.org"),
person("Bob","Cox",role="aut"),
Expand All @@ -10,16 +10,15 @@ Authors@R: c(person("Jon","Clayden",role=c("cre","aut"),email="code@clayden.org"
person("Kate","Fissell",role="ctb"),
person("Jean-loup","Gailly",role="cph"),
person("Mark","Adler",role="cph"))
Imports:
Rcpp (>= 0.11.0)
Suggests:
testthat (>= 0.11.0)
Imports: Rcpp (>= 0.11.0)
Suggests: testthat (>= 0.11.0), covr, reportr
Enhances: oro.nifti, tractor.base
LinkingTo: Rcpp
Description: Provides very fast access to images stored in the NIfTI-1 file
format <http://www.nitrc.org/docman/view.php/26/64/nifti1.h>, with seamless
synchronisation between compiled C and interpreted R code. Not to be
confused with 'RNiftyReg', which provides tools for image registration.
Description: Provides very fast read and write access to images stored in the
NIfTI-1 and ANALYZE-7.5 formats, with seamless synchronisation between
compiled C and interpreted R code. Also provides a C/C++ API that can be
used by other packages. Not to be confused with 'RNiftyReg', which performs
image registration.
License: GPL-2
URL: https://github.com/jonclayden/RNifti
BugReports: https://github.com/jonclayden/RNifti/issues
Expand Down
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
# Generated by roxygen2: do not edit by hand

S3method("$",niftiImage)
S3method("$<-",niftiImage)
S3method("dim<-",internalImage)
S3method("pixdim<-",default)
S3method("pixunits<-",default)
S3method(as.array,internalImage)
S3method(dim,internalImage)
S3method(pixdim,default)
S3method(pixunits,default)
S3method(print,analyzeHeader)
S3method(print,niftiHeader)
S3method(print,niftiImage)
export("orientation<-")
export("pixdim<-")
export("pixunits<-")
export("qform<-")
export("sform<-")
export(analyzeHeader)
export(dumpNifti)
export(ndim)
export(niftiHeader)
export(niftiVersion)
export(orientation)
export(origin)
export(pixdim)
export(pixunits)
export(readNifti)
export(retrieveNifti)
export(rotation)
export(updateNifti)
export(voxelToWorld)
export(worldToVoxel)
Expand Down
56 changes: 56 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,62 @@ Significant changes to the RNifti package are laid out below for each release.

===============================================================================

VERSION 0.9.0

- When writing an image using an integer datatype, the scale and slope fields
will now be set if the original values are outside the representable range of
that datatype. This ensures that the voxel values are accurate when read back
from the file (although some precision may, necessarily, be lost). This makes
the datatype argument to writeNifti() more generally useful for file size
reduction.
- The dumpNifti() function has been soft-deprecated in favour of niftiHeader(),
which works the same way. There is also a new analyzeHeader() function, which
returns a list giving the header elements when interpreted according to the
ANALYZE-7.5 format. Both functions now return a default header when given no
argument.
- The $ operator can now be used on "niftiImage" objects as a shorthand way to
get or set individual header fields.
- The qform and sform replacement functions now work on lists of class
"niftiHeader".
- The new rotation() function extracts just a pure 3x3 rotation matrix from an
image xform or general affine.
- Functions such as origin() and orientation() now also work directly on xform-
like numeric matrices.
- The offset part of an image's xform matrix (the fourth column) is now
properly updated when the image is reoriented. Reorientation should also now
work correctly for all possible permutations.
- NA and NaN values are no longer removed from images on reading.
- The pixdim attribute should now always contain the absolute values of the
pixdim for each dimension.

===============================================================================

VERSION 0.8.1

- A C-level namespace clash on certain platforms has been corrected.

===============================================================================

VERSION 0.8.0

- The new niftiVersion() function identifies the NIfTI format variant used by
files on disk.
- The readNifti() function gains an option which allows only certain volumes
to be read from disk.
- The updateNifti() function gains an option to set the internal datatype, for
advanced usage only (issue #8).
- Calling updateNifti() with a list containing only a few fields could
previously reset the remaining metadata to the defaults. This has been
corrected.
- It is now possible to change the cal_min and cal_max fields with the
updateNifti() function (issue #9). The scl_slope and scl_inter fields cannot
be changed, but this is now documented.
- R packages using the RNifti API must now ensure that the USING_R symbol is
defined (which it is by the main R header, R.h). Conversely, standalone use
of RNifti as a C++ library no longer requires _NO_R__ to be defined.

===============================================================================

VERSION 0.7.1

- The package is now more careful about handling NaNs when converting to
Expand Down
33 changes: 33 additions & 0 deletions R/image.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,36 @@ pixunits.default <- function (object)

return (object)
}

#' Access to metadata elements
#'
#' These methods provide shorthand access to metadata elements from the NIfTI
#' header corresponding to an image. The extraction version returns the
#' corresponding element from the result of \code{niftiHeader}, while the
#' replacement version calls \code{updateNifti} to replace it.
#'
#' @param x A \code{"niftiImage"} object, internal or otherwise.
#' @param name A string naming the field required.
#' @param value A new value for the field.
#'
#' @examples
#' im <- readNifti(system.file("extdata", "example.nii.gz", package="RNifti"))
#' print(im$descrip)
#'
#' @author Jon Clayden <code@@clayden.org>
#' @seealso \code{\link{niftiHeader}}, \code{\link{updateNifti}}
#' @rdname indexing
#' @export
"$.niftiImage" <- function (x, name)
{
return (niftiHeader(x)[[name]])
}

#' @rdname indexing
#' @export
"$<-.niftiImage" <- function (x, name, value)
{
template <- list()
template[[name]] <- value
return (updateNifti(x, template))
}
Loading

0 comments on commit 50ec9b5

Please sign in to comment.