Skip to content

Commit

Permalink
Merge pull request #8 from muschellij2/master
Browse files Browse the repository at this point in the history
Fixing NAs
  • Loading branch information
bjw34032 committed May 29, 2020
2 parents 88356ee + 2c5f322 commit 51005a3
Show file tree
Hide file tree
Showing 146 changed files with 4,071 additions and 3,529 deletions.
4 changes: 2 additions & 2 deletions CRAN-RELEASE
@@ -1,2 +1,2 @@
This package was submitted to CRAN on 2020-01-24.
Once it is accepted, delete this file and tag the release (commit 2701b70d47).
This package was submitted to CRAN on 2020-05-28.
Once it is accepted, delete this file and tag the release (commit 3420c8ea90).
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,5 +1,5 @@
Package: oro.nifti
Version: 0.10.2
Version: 0.10.3
Title: Rigorous - 'NIfTI' + 'ANALYZE' + 'AFNI' : Input / Output
Authors@R:
c(person(given = "Brandon",
Expand Down Expand Up @@ -165,6 +165,6 @@ Collate:
'img_length.R'
'zzz.R'
'zzz_niftiImage.R'
RoxygenNote: 7.0.2
RoxygenNote: 7.1.0
Encoding: UTF-8

4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# oro.nifti 0.10.3

* Fixing when there are any `NA` values.

# oro.nifti 0.10.1

* Added an `origin` accessor for `nifti` objects.
Expand Down
25 changes: 19 additions & 6 deletions R/writeS4.R
Expand Up @@ -155,9 +155,14 @@ setMethod("writeNIfTI", signature(nim="array"),

.writeNIfTI <- function(nim, filename, onefile=TRUE, gzipped=TRUE,
verbose=FALSE, warn=-1, compression = 6) {

## Warnings?
oldwarn <- getOption("warn")
options(warn=warn)
any_na = anyNA(nim@.Data)
if (any_na) {
warning("NAs may be turned to NaNs")
}
#### added so that range of the data will equal cal.min/cal.max
nim <- calibrateImage(nim)
##### Added so that bad dimensions are dropped
Expand Down Expand Up @@ -198,6 +203,18 @@ setMethod("writeNIfTI", signature(nim="array"),
cat(" vox_offset =", nim@"vox_offset", fill=TRUE)
}
}
## reorient?
if (nim@"reoriented") {
data <- as.vector(inverseReorient(nim))
} else {
data <- as.vector(nim@.Data)
}
if (any_na) {
warning("Need to change bitpix and datatype to FLOAT32 due to NAs")
nim@"datatype" = max(16L, nim@datatype)
nim@bitpix = max(64L, nim@bitpix)
}

##
writeBin(as.integer(nim@"sizeof_hdr"), fid, size=4)
writeChar(nim@"data_type", fid, nchars=10, eos=NULL)
Expand Down Expand Up @@ -270,16 +287,12 @@ setMethod("writeNIfTI", signature(nim="array"),
stop("@extender set but", nim, "has no extensions.")
}
}
## reorient?
if (nim@"reoriented") {
data <- as.vector(inverseReorient(nim))
} else {
data <- as.vector(nim@.Data)
}

## Write image file...
if (verbose) {
cat(" writing data at byte =", seek(fid), fill=TRUE)
}

switch(as.character(nim@"datatype"),
"2" = writeBin(as.integer(data), fid, size=nim@"bitpix"/8),
"4" = writeBin(as.integer(data), fid, size=nim@"bitpix"/8),
Expand Down
12 changes: 3 additions & 9 deletions cran-comments.md
@@ -1,16 +1,10 @@
## Test environments
* local OS X install, R 3.6.0
* ubuntu 14.04 (on travis-ci), R 3.6.0
* win-builder (devel and release)
* local R installation, R 3.6.3
* ubuntu 16.04 (on travis-ci), R 3.6.3
* win-builder (devel)

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.

---

Size of tarball has been large for many years with `oro.nifti` - images in vignette are large.

"Package has a VignetteBuilder field but no prebuilt vignette index.", which is not a concerning note as one of the vignettes is really an `rticles` Rmd file.
39 changes: 27 additions & 12 deletions docs/404.html

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

39 changes: 27 additions & 12 deletions docs/LICENSE-text.html

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

40 changes: 25 additions & 15 deletions docs/articles/index.html

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

0 comments on commit 51005a3

Please sign in to comment.