Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NA cannot be in an image #91

Open
muschellij2 opened this issue Jun 19, 2019 · 2 comments
Open

NA cannot be in an image #91

muschellij2 opened this issue Jun 19, 2019 · 2 comments

Comments

@muschellij2
Copy link
Collaborator

If you put an NA into an image, antsImage classes automatically turn this into a NaN output. I don't know if it is possible to put NA into the image, but this seems like an issue we should at least have a warning about. This is an issue if people use is.na. Should not really affect new stats as na.rm for @jeffduda really applies to NaN:

library(ANTsRCore)
#> 
#> Attaching package: 'ANTsRCore'
#> The following objects are masked from 'package:stats':
#> 
#>     sd, var
#> The following objects are masked from 'package:base':
#> 
#>     all, any, apply, max, min, prod, range, sum
img <- makeImage(c(10, 100, 3), rpois(n = 1000*3, lambda = 5)) 
img[1,1,1] = NA_real_
img[1,1,2] = Inf
img[1,1,3] = NaN
img[1,2,3] = -Inf
as.array(img)[1,1,]
#> [1] NaN Inf NaN

Created on 2019-06-19 by the reprex package (v0.3.0)

@muschellij2
Copy link
Collaborator Author

Similarly, any comparison procedure should likely give an NaN for the value if the value is NaN. Or at least it should likely be 0, not 1:

library(ANTsRCore)
#> 
#> Attaching package: 'ANTsRCore'
#> The following objects are masked from 'package:stats':
#> 
#>     sd, var
#> The following objects are masked from 'package:base':
#> 
#>     all, any, apply, max, min, prod, range, sum
img <- makeImage(c(10, 100, 3), rpois(n = 1000*3, lambda = 5)) 
img[1,1,1] = NA_real_
img[1,1,2] = Inf
img[1,1,3] = NaN
img[1,2,3] = -Inf
mask =img > 0
arr = as.array(mask)
sum(is.nan(arr))
#> [1] 0
arr[1,1,1:3]
#> [1] 1 1 1
arr[1,2,3]
#> [1] 1

Created on 2019-06-19 by the reprex package (v0.3.0)

@muschellij2
Copy link
Collaborator Author

Do you have any thoughts on NA @jeffduda? Should NaN > 0 produce NaN at least?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant