Skip to content

Commit

Permalink
version 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jonclayden authored and cran-robot committed Feb 16, 2024
1 parent a52842b commit 3c0b1dd
Show file tree
Hide file tree
Showing 50 changed files with 15,857 additions and 3,317 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: RNifti
Version: 1.5.1
Date: 2023-11-27
Version: 1.6.0
Date: 2024-02-15
Title: Fast R and C++ Access to NIfTI Images
Authors@R: c(person("Jon", "Clayden", role=c("cre","aut"),
email="code@clayden.org", comment=c(ORCID="0000-0002-6608-0619")),
Expand All @@ -27,7 +27,7 @@ BugReports: https://github.com/jonclayden/RNifti/issues
Encoding: UTF-8
RoxygenNote: 7.2.3
NeedsCompilation: yes
Packaged: 2023-11-28 11:18:58 UTC; jon
Packaged: 2024-02-15 16:27:14 UTC; jon
Author: Jon Clayden [cre, aut] (<https://orcid.org/0000-0002-6608-0619>),
Bob Cox [aut],
Mark Jenkinson [aut],
Expand All @@ -38,4 +38,4 @@ Author: Jon Clayden [cre, aut] (<https://orcid.org/0000-0002-6608-0619>),
Mark Adler [cph]
Maintainer: Jon Clayden <code@clayden.org>
Repository: CRAN
Date/Publication: 2023-11-28 12:10:12 UTC
Date/Publication: 2024-02-15 17:20:02 UTC
89 changes: 49 additions & 40 deletions MD5
@@ -1,24 +1,24 @@
a30c9b714a9dce08fda52433ee5d0324 *DESCRIPTION
6fc172b39781ad6ec2fb8f0f5197698d *DESCRIPTION
b94d5d2bf459e2903296147cf718349d *NAMESPACE
44864e0b14c644955b119fa29afcdb6c *NEWS
3a3d731e3dd52253df0eb0eb481ee8b0 *NEWS
48127c25699df64079656e5eb7fcd1d2 *R/extensions.R
a45b6c1b24ab18fa3818f783bf93a84c *R/image.R
0f3541bd599edbfd113439d69b5f693b *R/nifti.R
46e14f10e18c2dee71fa72ff7cdc8f70 *R/nifti.R
72db1a838f07adbc2f834ec36dd21f32 *R/rgb.R
81e0d85d15f23b2f3d102d6760a36bc3 *R/viewer.R
3a52b438782f0fc4f0a005012ee2cba5 *R/xform.R
0b6222eb8972506a715ac81c6cce2c33 *R/zzz.R
670e72fe47adc1d9545f4fe4dfc46b21 *README.md
e3d31206c28f1700a9cf327ed830369b *cleanup
768dc560b52c4f3a17897d3899ab2457 *README.md
de3a96bc3b47cf2717cdc84e20eac575 *cleanup
7c2c1d94dfe6a983036431788e83b6e4 *cleanup.win
2f8989e7304bad7a66be87c041e8c296 *configure
ece526a031b3767436ac7381a8ac41e5 *configure.ac
f63f838e72ef37a38b2fa23c3145b065 *configure
d7f17ed909040ac92c623f8af8a4dde5 *configure.ac
fb6ea71c285b8fc5d86bf53c4e104348 *inst/COPYRIGHTS
bad67894bda1a1b3b135369d6c07df6a *inst/extdata/example.nii.gz
e8547f4bc7609814adfbab6fe9c1c288 *inst/extdata/example_4d.nii.gz
c26818fcb45b7b7a9d4154d5487230e1 *inst/extdata/example_rgb.nii.gz
bdc38ee7810c9f6b00579488566ee382 *inst/include/RNifti.h
e2c74e0083e3937157cced62c63414e0 *inst/include/RNifti/NiftiImage.h
27b3377916ff84a549f8ec2cd8f3aef8 *inst/include/RNifti.h
034a48f9e5b92ed077c271db7ad36fc8 *inst/include/RNifti/NiftiImage.h
a43b0c2c9871d4edf6185c6c6060073a *inst/include/RNifti/NiftiImage_impl.h
f80b24dc1fac288092c6758dfe0b36f3 *inst/include/RNifti/NiftiImage_matrix.h
8a9527a48edffbebde2170c000a321ad *inst/include/RNifti/NiftiImage_print.h
Expand All @@ -30,9 +30,7 @@ f3b89c12d91297deee7a2b1cf27d41d7 *inst/include/niftilib/nifti2.h
4e373c9b99d88d0019a2ea3da10e7330 *inst/include/niftilib/nifti2_image.h
59a3d4d90a3c6f2f1577e59b130850fb *inst/include/niftilib/nifti2_io.h
d3ab930e9ad209cc857a839d2e080ebc *inst/include/niftilib/nifti2_io_version.h
5407d4c937d8f925665f71aad35c12fa *inst/include/zlib/zconf.h
1c128a3b0a0fd84c1224754170ee7756 *inst/include/zlib/zlib.h
b832290b2ff8ffe44114b4e86475f301 *inst/include/znzlib/znzlib.h
e465fe9fd570402aba84704902ead0e4 *inst/include/znzlib/znzlib.h
ee8949e3b781480b0201286063b5c2ac *man/ExtensionCodes.Rd
8ecefba81cb4bce311f77e0cb0e7d865 *man/asNifti.Rd
89095e599895dbb1547cfc9159d447f1 *man/channels.Rd
Expand All @@ -41,7 +39,7 @@ f62cda6e04dc9e2216c24227eac3c1c0 *man/extensions.Rd
1ea9e61a79acb5999d259813d2213c0f *man/indexing.Rd
b83a9399244f6c7de4ddf7775daf8a36 *man/internalImage.Rd
42120833f7c250a1d4e56c649ef40ed4 *man/ndim.Rd
f140c602ae576950196d1ce92e00d7b3 *man/niftiHeader.Rd
858433f6367476a59330e16917d291d2 *man/niftiHeader.Rd
7406628fc63edbf979ad6348dda8b9a7 *man/niftiVersion.Rd
20c181da31a24521475e83eff3927f90 *man/pixdim.Rd
bdff7a46d55ff74e148f797da7af245a *man/readNifti.Rd
Expand All @@ -50,40 +48,51 @@ dfef27c9fc33dc654e3e1cb2cdbb1464 *man/view.Rd
7f366aa4296dae452fb39f3131e3cf38 *man/voxelToWorld.Rd
d1e37db347a3cdf2329fe98282c554d5 *man/writeNifti.Rd
cd7905d91c416d05dc58c980254711fb *man/xform.Rd
8e06de557abf2608ef1d50c13753683c *src/Makevars.in
49abe6af876df7ba9299e3eda904dc59 *src/Makevars.win
2b76d04b3924ab31ced53f5e08491d5e *src/main.cpp
ba4b75f46c445369ab22405a14947c88 *src/niftilib/nifti1_io.c
56634e57ebb5d93a068d62acb48c6b1a *src/Makevars.in
08367357a0cc57225d43002490f619fa *src/Makevars.win
dc85947bdd5b359584b04c8e8e0486d6 *src/main.cpp
3ec9b546cf310cdb253ec203693e4e8d *src/niftilib/nifti1_io.c
5bbd85dfe9831c8cda38edcfa4a60cd9 *src/niftilib/nifti2_io.c
ae3bbb54820e1d49fb90cbba222e973f *src/zlib/adler32.c
7a734598f9792fee943b70b6da8d932f *src/zlib/compress.c
1339c92938d2594a6eecfa21c374d1b6 *src/zlib/crc32.c
f28d16b67efecdfafa0d816a7d982124 *src/zlib/crc32.h
cd7826278ce9d9d9ed5abdefef50c3e2 *src/zlib/deflate.c
7ceae74a13201f14c91623116af169c3 *src/zlib/deflate.h
29d02cff161bde3e4e717b25a2ab7050 *src/zlib/gzclose.c
715df37bf53af0dee6d018d0f34836ad *src/zlib/gzguts.h
cb70e50d56c980fb8fd2e2e97bb9cd86 *src/zlib/gzlib.c
62164548c5f9c89dc5e7d8ea382ffd8e *src/zlib/gzread.c
cb95538e53e594b0d8a4bf4ecb2b5659 *src/zlib/gzwrite.c
bdb9cc0c602c951ed5f0557798e15299 *src/zlib/infback.c
9c14c1d95cee9f62465dedea7524c5fb *src/zlib/inffast.c
f3669099d3f571dbc0426401ed5f50e3 *src/zlib/inffast.h
1167fcfa3f77ffa597b4f5a5b42d8e2c *src/zlib/Makefile.in
cea51e08d9b176c6bf8b5820169d4102 *src/zlib/adler32.c
b0b5688c87d809bb32d0923dbef28ee6 *src/zlib/compress.c
27b59d6e86c24acba698841021daf84b *src/zlib/configure
47f7b459ecb8e1cc0240d9ae8dda8e6e *src/zlib/crc32.c
0ce0ac9394905aa53ed0a915620d9e5d *src/zlib/crc32.h
35a956fb82eee2a69cf298d455e727d4 *src/zlib/deflate.c
c4e786a4cb9b55522c1d084388abcee5 *src/zlib/deflate.h
83049e4eaab1319f7ed94f15e7de5c4c *src/zlib/gzclose.c
262b6710ab626436ee7e7ebe18f47212 *src/zlib/gzguts.h
f2ae48e6c40e5c92b1b0074e1cb08e5f *src/zlib/gzlib.c
1c8f8dfe08e58d6088a3b6c9bf4160bd *src/zlib/gzread.c
fc122bb96017e7a19828e04a1b3dd564 *src/zlib/gzwrite.c
1b8a0a4ebb220896e2610d292b821ce0 *src/zlib/infback.c
1846b459fac461ded03f741f4953dc00 *src/zlib/inffast.c
6c907e4d7c65aff48183101b66a6133b *src/zlib/inffast.h
7fa3e91804601b6618c915b76a8dc332 *src/zlib/inffixed.h
ec1b347da6284c0661decb41d3c50955 *src/zlib/inflate.c
8f1b05cdf36a269882a955071b140162 *src/zlib/inflate.h
3d0a4fce4b156f064e9be2aef36a7897 *src/zlib/inftrees.c
ec87be89b9bcca8ced80a70f857e823b *src/zlib/inftrees.h
bc195d555c24fecff56af6c06bd55b1d *src/zlib/trees.c
6b32d46536f8c9adc0378ab9b9251fa4 *src/zlib/inflate.c
819fb5556d0c65ba2577ee379b4641c0 *src/zlib/inflate.h
b6705992b276162d6ea76cc0442bcd28 *src/zlib/inftrees.c
ca4636a86335f58971f7a8944e5519b7 *src/zlib/inftrees.h
3f55761581cbf60586a2c6380721e41d *src/zlib/trees.c
51fdcb3e2ccf60ca13c06920c89296a3 *src/zlib/trees.h
eabe905cdd27f5b935e6378cd0253418 *src/zlib/uncompr.c
fff257bc1656eb60fc585a7dc35f963d *src/zlib/zutil.c
de91a463004fd5b944c3d37eab0c1794 *src/zlib/zutil.h
c76e0f7b934ca6695d453b1b51aa3112 *src/zlib/uncompr.c
63cdfd6798d79c3d181b59daa84c5df0 *src/zlib/win32/Makefile.bor
14edf6fc0eb45b3e0ae5b73cef7300f5 *src/zlib/win32/Makefile.gcc
4b7373caa4e587e84d56b3719bfcc288 *src/zlib/win32/Makefile.msc
684d84fae62becb5ad9d0b4a95d262bd *src/zlib/win32/zlib.def
6ebfda6f8e9db737af5af76b5f06faa8 *src/zlib/win32/zlib1.rc
bf9c9b7ce8a0434dc4f3ae1efdd5c1c4 *src/zlib/zconf.h
bf9c9b7ce8a0434dc4f3ae1efdd5c1c4 *src/zlib/zconf.h.in
b0d674489d5c40c17a7ab66238737af4 *src/zlib/zlib.h
60674eee456b5cab09b25a4bfd55d533 *src/zlib/zlib.pc.in
ef9f3b09085209c0193ab0686e1edd5b *src/zlib/zutil.c
1e2f8af01fcb13b9b32ded1340092d11 *src/zlib/zutil.h
420a0b8e9d75cd936a6d08acd1e7bf34 *src/znzlib/znzlib.c
2960da031fea46eaffe3e3abedb78f29 *src/zzz.c
d4a2abbb6217055b8900c8d86ac6aa53 *tests/testthat.R
284ecfcebb44440aaf575935eb8a37dc *tests/testthat/Rplots.pdf
9b78b59582b4b2dfdab2c3124c705535 *tests/testthat/test-05-nifti.R
8ee24bd56273bdd9e13749822b8cae8f *tests/testthat/test-05-nifti.R
923f10fc2c56863736b67257909b4e19 *tests/testthat/test-08-composite.R
f586c7912239dbe87e5d75cfba3b4aee *tests/testthat/test-10-xform.R
9cefc1807eb2fc89f6dcf799ca4b6e0b *tests/testthat/test-12-viewer.R
Expand Down
32 changes: 32 additions & 0 deletions NEWS
Expand Up @@ -2,6 +2,38 @@ Significant changes to the RNifti package are laid out below for each release.

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

VERSION 1.6.0

R interface

- The `niftiHeader()` function gains an "unused" argument. If `TRUE`, the
function's return value includes those legacy ANALYZE-7.5 fields that are
formally unused by the NIfTI-1 standard (or the last few bytes of a NIfTI-2
header). These fields cannot be set, however, as the `niftilib` I/O functions
discard them, and the core `nifti_image` structure does not represent them.
They also cannot be accessed with the `$` operator shorthand. The option is
therefore only useful to inspect file headers created by other software.

API changes

- The `NiftiImage` class now has constructors taking a NIfTI header structure.

Other changes

- The `NiftiImageData::Iterator` inner class now holds a pointer, not a
reference, to its parent. This doesn't really change the API, but ensures
that iterator objects are mutable, which is formally required by the C++
standard. (Prompted by Timothy Anderson, issue #31.)
- There is now support for standalone use on Windows with the Visual C++
toolchain, including an `nmake`-compatible makefile, and this is now tested
as part of package CI. The package also no longer includes symlinks, for
better portability. (Prompted by Timothy Anderson, issue #31.)
- The bundled `zlib` is now version 1.3. The included `zlib` headers are no
longer exposed to client packages if the system `zlib` is used for linkage,
as the two may be incompatible.

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

VERSION 1.5.1

- Several warnings from recent compilers relating to printf-style format
Expand Down
9 changes: 6 additions & 3 deletions R/nifti.R
Expand Up @@ -217,6 +217,9 @@ updateNifti <- function (image, template = NULL, datatype = "auto")
#' @param image An image, in any acceptable form (see \code{\link{asNifti}}).
#' A list containing partial header information is acceptable, including an
#' empty list, which returns defaults for every field.
#' @param unused Logical value. If \code{TRUE}, legacy ANALYZE and padding
#' fields that are unused by the relevant NIfTI standard are included in the
#' return value. These are occasionally used by software packages.
#' @param x A \code{"niftiHeader"} object.
#' @param ... Ignored.
#' @return For \code{niftiHeader}, a list of class \code{"niftiHeader"}, with
Expand Down Expand Up @@ -246,13 +249,13 @@ updateNifti <- function (image, template = NULL, datatype = "auto")
#' @references The NIfTI-1 standard (\url{https://www.nitrc.org/docman/view.php/26/64/nifti1.h}).
#' @aliases dumpNifti
#' @export niftiHeader dumpNifti
niftiHeader <- dumpNifti <- function (image = list())
niftiHeader <- dumpNifti <- function (image = list(), unused = FALSE)
{
# Special case to avoid expensively reading image data from file when only metadata is needed
if (is.character(image) && length(image) == 1 && !inherits(image,"internalImage"))
.Call("niftiHeader", image, PACKAGE="RNifti")
.Call("niftiHeader", image, unused, PACKAGE="RNifti")
else
.Call("niftiHeader", asNifti(image,internal=TRUE), PACKAGE="RNifti")
.Call("niftiHeader", asNifti(image,internal=TRUE), unused, PACKAGE="RNifti")
}

#' @rdname niftiHeader
Expand Down
6 changes: 3 additions & 3 deletions README.md
@@ -1,6 +1,6 @@


[![CRAN version](http://www.r-pkg.org/badges/version/RNifti)](https://cran.r-project.org/package=RNifti) [![CI](https://github.com/jonclayden/RNifti/actions/workflows/ci.yaml/badge.svg)](https://github.com/jonclayden/RNifti/actions/workflows/ci.yaml) [![Coverage Status](https://coveralls.io/repos/github/jonclayden/RNifti/badge.svg?branch=master)](https://coveralls.io/github/jonclayden/RNifti?branch=master)
[![CRAN version](http://www.r-pkg.org/badges/version/RNifti)](https://cran.r-project.org/package=RNifti) [![CI](https://github.com/jonclayden/RNifti/actions/workflows/ci.yaml/badge.svg)](https://github.com/jonclayden/RNifti/actions/workflows/ci.yaml) [![codecov](https://codecov.io/gh/jonclayden/RNifti/graph/badge.svg?token=WTwyfvbbfL)](https://app.codecov.io/gh/jonclayden/RNifti) [![Dependencies](https://tinyverse.netlify.com/badge/RNifti)](https://tinyverse.netlify.app)

# RNifti: Fast R and C++ Access to NIfTI Images

Expand Down Expand Up @@ -283,7 +283,7 @@ Moreover, when reading the file into an "internal" image, which does not copy th

## Implementation details

The package does not fully duplicate the NIfTI structure's contents in R-visible objects. Instead, it passes key metadata back to R, such as the image dimensions and pixel dimensions, and it also passes back the pixel values where they are needed. Finally, it creates an [external pointer](http://r-manuals.flakery.org/R-exts.html#External-pointers-and-weak-references) to the native data structure, which is stored in an attribute. This pointer is dereferenced whenever the object is passed back to the C++ code, thereby avoiding unnecessary duplication and ensuring that all metadata remains intact. The full NIfTI-1 header can be obtained using the `niftiHeader` R function, if it is needed.
The package does not fully duplicate the NIfTI structure's contents in R-visible objects. Instead, it passes key metadata back to R, such as the image dimensions and pixel dimensions, and it also passes back the pixel values where they are needed. Finally, it creates an [external pointer](https://r-manuals.flakery.org/R-exts.html#External-pointers-and-weak-references) to the native data structure, which is stored in an attribute. This pointer is dereferenced whenever the object is passed back to the C++ code, thereby avoiding unnecessary duplication and ensuring that all metadata remains intact. The full NIfTI-1 header can be obtained using the `niftiHeader` R function, if it is needed.

This arrangement is efficient and generally works well, but certain R operations strip attributes—in which case the external pointer will be removed. The internal structure will be built again when necessary, but using default metadata. In these cases, if it is important to keep the original metadata, the `asNifti` function should be called explicitly, with a template object. This reconstructs the NIfTI data structure, using the template as a starting point.

Expand All @@ -294,7 +294,7 @@ It is possible to use the package's NIfTI-handling code in other R packages' com
- `NiftiImage`, which simplifies memory management and supports the package's internal image pointers and associated reference counting, and
- `NiftiImageData`, which encapsulates the pixel data within an image, and handles datatype multiplexing and data scaling, as well as providing indexing, iterators and other niceties.

Full doxygen documentation for these classes is available at <http://doxygen.flakery.org/RNifti/>, and is also provided with package releases.
Full doxygen documentation for these classes is available at <https://doxygen.flakery.org/RNifti/>, and is also provided with package releases.

A third-party package can use the `NiftiImage` class by including

Expand Down
3 changes: 2 additions & 1 deletion cleanup
@@ -1,3 +1,4 @@
#!/bin/sh

rm -f src/Makevars src/*.o src/niftilib/*.o src/zlib/*.o src/znzlib/*.o
rm -f src/Makevars src/*.o src/niftilib/*.o src/znzlib/*.o inst/include/zlib.h inst/include/zconf.h
rm -f src/zlib/*.o src/zlib/libz.*

0 comments on commit 3c0b1dd

Please sign in to comment.