ANTsX / ANTsRCore

Rcpp bindings for the C++ ANTs library used by the ANTsR package
9 stars 9 forks source link

plot.antsImage direction=-1 doesn't change the direction #160

Open muratmaga opened 1 year ago

muratmaga commented 1 year ago

Describe the bug I want to create two plots in which the red colorbar indicates absolutely higher positive magnitude change, and blue colorbar with absolutely higher negative effects. I thought that's what the direction parameter does, but it doesn't seem to have any effect. Here is the sample code modified from plot.antsImage.

To Reproduce

 img = antsImageRead( getANTsRData( 'r16' ) )
  betaVals = rnorm( prod( dim( img ) ), 0, 20 )
  betaImg = makeImage( dim( img ), betaVals )  %>% smoothImage( 3.5 )
  betaImg[ abs( betaImg ) < 1.5 ] = 0
plot( img, betaImg, window.img=range(img) ,window.overlay=c(0.000001, 12), color.overlay="red", colorbar=T )

plot( img, betaImg, window.img=range(img) ,window.overlay=c(-10, -.0000001), color.overlay="blue", colorbar=T, direction=-1 )

Expected behavior I would have expected the in the second plot, darker blue colors would have more negative values, whereas lighter (whitish color) would have ranges closer to 0.

image image

Session Info

> antsVersions
  Dependency                                   GitTag
1       ANTs d30526f9cb5159bc0a3e9011f7ae5f409b3634c8
2  ANTsRCore 038b62f258d426e82ec3dd837793a7746b5d83b8
3    ANTsURL        https://github.com/ANTsX/ANTs.git
4        ITK                                 v5.3rc04
> sessioninfo::session_info("ANTsRCore")
─ Session info  ─────────────────────────────────────────────────
 hash: red triangle pointed down, flag: Bulgaria, unamused face

 setting  value
 version  R version 4.1.2 (2021-11-01)
 os       Ubuntu 20.04.5 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language en_CA:en
 collate  en_CA.UTF-8
 ctype    en_CA.UTF-8
 tz       America/Vancouver
 date     2023-06-27
 rstudio  2021.09.1+372 Ghost Orchid (desktop)
 pandoc   2.14.0.3 @ /usr/lib/rstudio/bin/pandoc/ (via rmarkdown)

─ Packages ──────────────────────────────────────────────────────
 package   * version   date (UTC) lib source
 ANTsRCore * 0.7.5     2023-04-19 [2] Neuroconductor (R 4.1.2)
 ITKR        0.6.0.0.2 2023-04-19 [2] local
 lattice     0.20-45   2021-09-22 [4] CRAN (R 4.1.1)
 magrittr    2.0.3     2022-03-30 [2] CRAN (R 4.1.2)
 Matrix      1.4-0     2021-12-08 [4] CRAN (R 4.1.2)
 Rcpp        1.0.9     2022-07-08 [2] CRAN (R 4.1.2)
 RcppEigen   0.3.3.9.3 2022-11-05 [2] CRAN (R 4.1.2)

 [1] /home/maga/R/x86_64-pc-linux-gnu-library/4.1
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

─────────────────────────────────────────────────────────────────
>