Giter Site home page Giter Site logo

antsrnet's Introduction

Contributor Covenant PubMed

ANTsRNet

A collection of deep learning architectures and applications ported to the R language and tools for basic medical image processing. Based on keras and tensorflow with cross-compatibility with our python analog ANTsPyNet.

Documentation page

ANTsXNet tutorial

Architectures

Image voxelwise segmentation/regression

Image classification/regression

Object detection

Image super-resolution

Registration and transforms

Generative adverserial networks

Clustering

Applications
Publications
  • Nicholas J. Tustison, Min Chen, Fae N. Kronman, Jeffrey T. Duda, Clare Gamlin, Mia G. Tustison, Michael Kunst, Rachel Dalley, Staci Sorenson, Quanxi Wang, Lydia Ng, Yongsoo Kim, and James C. Gee. The ANTsX Ecosystem for Mapping the Mouse Brain. (biorxiv)

  • Nicholas J. Tustison, Michael A. Yassa, Batool Rizvi, Philip A. Cook, Andrew J. Holbrook, Mithra Sathishkumar, Mia G. Tustison, James C. Gee, James R. Stone, and Brian B. Avants. ANTsX neuroimaging-derived structural phenotypes of UK Biobank. Scientific Reports, 14(1):8848, Apr 2024. (pubmed)

  • Nicholas J. Tustison, Talissa A. Altes, Kun Qing, Mu He, G. Wilson Miller, Brian B. Avants, Yun M. Shim, James C. Gee, John P. Mugler III, and Jaime F. Mata. Image- versus histogram-based considerations in semantic segmentation of pulmonary hyperpolarized gas images. Magnetic Resonance in Medicine, 86(5):2822-2836, Nov 2021. (pubmed)

  • Andrew T. Grainger, Arun Krishnaraj, Michael H. Quinones, Nicholas J. Tustison, Samantha Epstein, Daniela Fuller, Aakash Jha, Kevin L. Allman, Weibin Shi. Deep Learning-based Quantification of Abdominal Subcutaneous and Visceral Fat Volume on CT Images, Academic Radiology, 28(11):1481-1487, Nov 2021. (pubmed)

  • Nicholas J. Tustison, Philip A. Cook, Andrew J. Holbrook, Hans J. Johnson, John Muschelli, Gabriel A. Devenyi, Jeffrey T. Duda, Sandhitsu R. Das, Nicholas C. Cullen, Daniel L. Gillen, Michael A. Yassa, James R. Stone, James C. Gee, and Brian B. Avants for the Alzheimer’s Disease Neuroimaging Initiative. The ANTsX ecosystem for quantitative biological and medical imaging. Scientific Reports. 11(1):9068, Apr 2021. (pubmed)

  • Nicholas J. Tustison, Brian B. Avants, and James C. Gee. Learning image-based spatial transformations via convolutional neural networks: a review, Magnetic Resonance Imaging, 64:142-153, Dec 2019. (pubmed)

  • Nicholas J. Tustison, Brian B. Avants, Zixuan Lin, Xue Feng, Nicholas Cullen, Jaime F. Mata, Lucia Flors, James C. Gee, Talissa A. Altes, John P. Mugler III, and Kun Qing. Convolutional Neural Networks with Template-Based Data Augmentation for Functional Lung Image Quantification, Academic Radiology, 26(3):412-423, Mar 2019. (pubmed)

  • Andrew T. Grainger, Nicholas J. Tustison, Kun Qing, Rene Roy, Stuart S. Berr, and Weibin Shi. Deep learning-based quantification of abdominal fat on magnetic resonance images. PLoS One, 13(9):e0204071, Sep 2018. (pubmed)

  • Cullen N.C., Avants B.B. (2018) Convolutional Neural Networks for Rapid and Simultaneous Brain Extraction and Tissue Segmentation. In: Spalletta G., Piras F., Gili T. (eds) Brain Morphometry. Neuromethods, vol 136. Humana Press, New York, NY doi

Acknowledgements

antsrnet's People

Contributors

cookpa avatar muschellij2 avatar ntustison avatar stnava avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

antsrnet's Issues

InstanceNormalizationLayer

I see the stop code for axis = 1L, but https://github.com/ANTsX/ANTsRNet/blob/master/R/customNormalizationLayers.R#L21 states to set axis = 1.

library(ANTsRNet)
InstanceNormalizationLayer$new(axis = 1L)
#> Error in .subset2(public_bind_env, "initialize")(...): Error:  axis can't be 1.

Created on 2020-01-30 by the reprex package (v0.3.0.9001)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       macOS Mojave 10.14.6        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2020-01-30                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version     date       lib source                             
#>  ANTsR         0.5.4.2     2019-11-14 [1] local                              
#>  ANTsRCore     0.7.3       2019-12-11 [1] Github (ANTsX/ANTsRCore@416d8f1)   
#>  ANTsRNet    * 1.1         2020-01-30 [1] local                              
#>  assertthat    0.2.1       2019-03-21 [1] CRAN (R 3.6.0)                     
#>  backports     1.1.5       2019-10-02 [1] CRAN (R 3.6.0)                     
#>  base64enc     0.1-3       2015-07-28 [1] CRAN (R 3.6.0)                     
#>  cli           2.0.1       2020-01-08 [1] CRAN (R 3.6.0)                     
#>  crayon        1.3.4       2017-09-16 [1] CRAN (R 3.6.0)                     
#>  digest        0.6.23      2019-11-23 [1] CRAN (R 3.6.0)                     
#>  evaluate      0.14        2019-05-28 [1] CRAN (R 3.6.0)                     
#>  fansi         0.4.1       2020-01-08 [1] CRAN (R 3.6.0)                     
#>  fs            1.3.1       2019-05-06 [1] CRAN (R 3.6.0)                     
#>  generics      0.0.2       2018-11-29 [1] CRAN (R 3.6.0)                     
#>  glue          1.3.1       2019-03-12 [1] CRAN (R 3.6.0)                     
#>  highr         0.8         2019-03-20 [1] CRAN (R 3.6.0)                     
#>  htmltools     0.4.0       2019-10-04 [1] CRAN (R 3.6.0)                     
#>  ITKR          0.5.2       2019-11-05 [1] Github (stnava/ITKR@fe97efa)       
#>  jsonlite      1.6         2018-12-07 [1] CRAN (R 3.6.0)                     
#>  keras         2.2.5.0     2019-10-08 [1] CRAN (R 3.6.0)                     
#>  knitr         1.26.1      2020-01-05 [1] Github (muschellij2/knitr@f5af631) 
#>  lattice       0.20-38     2018-11-04 [1] CRAN (R 3.6.0)                     
#>  magrittr      1.5         2014-11-22 [1] CRAN (R 3.6.0)                     
#>  Matrix        1.2-17      2019-03-22 [1] CRAN (R 3.6.0)                     
#>  mvtnorm       1.0-11      2019-06-19 [1] CRAN (R 3.6.0)                     
#>  pillar        1.4.3       2019-12-20 [1] CRAN (R 3.6.0)                     
#>  pkgconfig     2.0.3       2019-09-22 [1] CRAN (R 3.6.0)                     
#>  purrr         0.3.3       2019-10-18 [1] CRAN (R 3.6.0)                     
#>  R6            2.4.1       2019-11-12 [1] CRAN (R 3.6.0)                     
#>  Rcpp          1.0.3       2019-11-08 [1] CRAN (R 3.6.0)                     
#>  RcppEigen     0.3.3.7.0   2019-11-16 [1] CRAN (R 3.6.0)                     
#>  reprex        0.3.0.9001  2020-01-05 [1] Github (tidyverse/reprex@5ae0b29)  
#>  reticulate    1.13        2019-07-24 [1] CRAN (R 3.6.0)                     
#>  rlang         0.4.2       2019-11-23 [1] CRAN (R 3.6.0)                     
#>  rmarkdown     2.0.7       2020-01-17 [1] Github (rstudio/rmarkdown@2faf16a) 
#>  rstudioapi    0.10.0-9003 2020-01-05 [1] Github (rstudio/rstudioapi@abe596d)
#>  sessioninfo   1.1.1       2018-11-05 [1] CRAN (R 3.6.0)                     
#>  stringi       1.4.5       2020-01-11 [1] CRAN (R 3.6.0)                     
#>  stringr       1.4.0       2019-02-10 [1] CRAN (R 3.6.0)                     
#>  styler        1.1.1       2019-05-06 [1] CRAN (R 3.6.0)                     
#>  tensorflow    2.0.0       2019-10-02 [1] CRAN (R 3.6.0)                     
#>  tfruns        1.4         2018-08-25 [1] CRAN (R 3.6.0)                     
#>  tibble        2.1.3       2019-06-06 [1] CRAN (R 3.6.0)                     
#>  whisker       0.4         2019-08-28 [1] CRAN (R 3.6.0)                     
#>  withr         2.1.2       2018-03-15 [1] CRAN (R 3.6.0)                     
#>  xfun          0.11        2019-11-12 [1] CRAN (R 3.6.0)                     
#>  yaml          2.2.0       2018-07-25 [1] CRAN (R 3.6.0)                     
#>  zeallot       0.1.0       2018-01-28 [1] CRAN (R 3.6.0)                     
#> 
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

Failing UNet

library(reticulate)
library(keras)
library(ANTsRNet)
inputImageSize = c( 256L, 256L, 1L )
inputs <- layer_input( shape = inputImageSize )
outputs <- inputs %>% layer_zero_padding_2d( padding = c( 3L, 3L ) )
layer_scale = ANTsRNet:::layer_scale
outputs %>% 
	layer_scale(axis = -1L)

Loss functions

Hey @stnava ,

I'm thinking of a small reorganization involving pulling the various custom loss functions from their respective utilities .R files and putting them in their own file. Would you have any issue with that?

Nick

travis warnings

current status:

* checking R code for possible problems ... NOTE
createAlexNetModel2D: no visible global function definition for
  тАШusePkgтАЩ
createAlexNetModel2D : splitTensor2D: no visible global function
  definition for тАШlayer_lambdaтАЩ
createAlexNetModel2D : crossChannelNormalization2D: no visible global
  function definition for тАШlayer_lambdaтАЩ
createAlexNetModel2D: no visible global function definition for
  тАШlayer_inputтАЩ
createAlexNetModel2D: no visible global function definition for тАШ%>%тАЩ
createAlexNetModel2D: no visible global function definition for
  тАШlayer_conv_2dтАЩ
createAlexNetModel2D: no visible global function definition for
  тАШlayer_max_pooling_2dтАЩ
createAlexNetModel2D: no visible global function definition for
  тАШlayer_zero_padding_2dтАЩ
createAlexNetModel2D: no visible global function definition for
  тАШlayer_concatenateтАЩ
createAlexNetModel2D: no visible global function definition for
  тАШlayer_flattenтАЩ
createAlexNetModel2D: no visible global function definition for
  тАШlayer_denseтАЩ
createAlexNetModel2D: no visible global function definition for
  тАШlayer_dropoutтАЩ
createAlexNetModel2D: no visible global function definition for
  тАШkeras_modelтАЩ
createAlexNetModel3D: no visible global function definition for
  тАШusePkgтАЩ
createAlexNetModel3D : splitTensor3D: no visible global function
  definition for тАШlayer_lambdaтАЩ
createAlexNetModel3D : crossChannelNormalization3D: no visible global
  function definition for тАШlayer_lambdaтАЩ
createAlexNetModel3D: no visible global function definition for
  тАШlayer_inputтАЩ
createAlexNetModel3D: no visible global function definition for тАШ%>%тАЩ
createAlexNetModel3D: no visible global function definition for
  тАШlayer_conv_3dтАЩ
createAlexNetModel3D: no visible global function definition for
  тАШlayer_max_pooling_3dтАЩ
createAlexNetModel3D: no visible global function definition for
  тАШlayer_zero_padding_3dтАЩ
createAlexNetModel3D: no visible global function definition for
  тАШlayer_concatenateтАЩ
createAlexNetModel3D: no visible global function definition for
  тАШlayer_flattenтАЩ
createAlexNetModel3D: no visible global function definition for
  тАШlayer_denseтАЩ
createAlexNetModel3D: no visible global function definition for
  тАШlayer_dropoutтАЩ
createAlexNetModel3D: no visible global function definition for
  тАШkeras_modelтАЩ
createDenseNetModel2D: no visible global function definition for
  тАШusePkgтАЩ
createDenseNetModel2D : convolutionFactory2D: no visible global
  function definition for тАШ%>%тАЩ
createDenseNetModel2D : convolutionFactory2D: no visible global
  function definition for тАШlayer_batch_normalizationтАЩ
createDenseNetModel2D : convolutionFactory2D: no visible global
  function definition for тАШregularizer_l2тАЩ
createDenseNetModel2D : convolutionFactory2D: no visible global
  function definition for тАШlayer_activationтАЩ
createDenseNetModel2D : convolutionFactory2D: no visible global
  function definition for тАШlayer_conv_2dтАЩ
createDenseNetModel2D : convolutionFactory2D: no visible global
  function definition for тАШlayer_dropoutтАЩ
createDenseNetModel2D : transition2D: no visible global function
  definition for тАШ%>%тАЩ
createDenseNetModel2D : transition2D: no visible global function
  definition for тАШlayer_average_pooling_2dтАЩ
createDenseNetModel2D : createDenseBlocks2D: no visible global function
  definition for тАШlayer_concatenateтАЩ
createDenseNetModel2D: no visible global function definition for
  тАШlayer_inputтАЩ
createDenseNetModel2D: no visible global function definition for тАШ%>%тАЩ
createDenseNetModel2D: no visible global function definition for
  тАШlayer_conv_2dтАЩ
createDenseNetModel2D: no visible global function definition for
  тАШregularizer_l2тАЩ
createDenseNetModel2D: no visible global function definition for
  тАШlayer_batch_normalizationтАЩ
createDenseNetModel2D: no visible global function definition for
  тАШlayer_activationтАЩ
createDenseNetModel2D: no visible global function definition for
  тАШlayer_global_average_pooling_2dтАЩ
createDenseNetModel2D: no visible global function definition for
  тАШlayer_denseтАЩ
createDenseNetModel2D: no visible global function definition for
  тАШkeras_modelтАЩ
createDenseNetModel3D: no visible global function definition for
  тАШusePkgтАЩ
createDenseNetModel3D : convolutionFactory3D: no visible global
  function definition for тАШ%>%тАЩ
createDenseNetModel3D : convolutionFactory3D: no visible global
  function definition for тАШlayer_batch_normalizationтАЩ
createDenseNetModel3D : convolutionFactory3D: no visible global
  function definition for тАШregularizer_l2тАЩ
createDenseNetModel3D : convolutionFactory3D: no visible global
  function definition for тАШlayer_activationтАЩ
createDenseNetModel3D : convolutionFactory3D: no visible global
  function definition for тАШlayer_conv_3dтАЩ
createDenseNetModel3D : convolutionFactory3D: no visible global
  function definition for тАШlayer_dropoutтАЩ
createDenseNetModel3D : transition3D: no visible global function
  definition for тАШ%>%тАЩ
createDenseNetModel3D : transition3D: no visible global function
  definition for тАШlayer_average_pooling_3dтАЩ
createDenseNetModel3D : createDenseBlocks3D: no visible global function
  definition for тАШlayer_concatenateтАЩ
createDenseNetModel3D: no visible global function definition for
  тАШlayer_inputтАЩ
createDenseNetModel3D: no visible global function definition for тАШ%>%тАЩ
createDenseNetModel3D: no visible global function definition for
  тАШlayer_conv_3dтАЩ
createDenseNetModel3D: no visible global function definition for
  тАШregularizer_l2тАЩ
createDenseNetModel3D: no visible global function definition for
  тАШlayer_batch_normalizationтАЩ
createDenseNetModel3D: no visible global function definition for
  тАШlayer_activationтАЩ
createDenseNetModel3D: no visible global function definition for
  тАШlayer_global_average_pooling_3dтАЩ
createDenseNetModel3D: no visible global function definition for
  тАШlayer_denseтАЩ
createDenseNetModel3D: no visible global function definition for
  тАШkeras_modelтАЩ
createGoogLeNetModel2D: no visible global function definition for
  тАШusePkgтАЩ
createGoogLeNetModel2D : convolutionAndBatchNormalization2D: no visible
  global function definition for тАШ%>%тАЩ
createGoogLeNetModel2D : convolutionAndBatchNormalization2D: no visible
  global function definition for тАШlayer_conv_2dтАЩ
createGoogLeNetModel2D : convolutionAndBatchNormalization2D: no visible
  global function definition for тАШlayer_batch_normalizationтАЩ
createGoogLeNetModel2D : convolutionAndBatchNormalization2D: no visible
  global function definition for тАШlayer_activationтАЩ
createGoogLeNetModel2D: no visible global function definition for
  тАШlayer_inputтАЩ
createGoogLeNetModel2D: no visible global function definition for тАШ%>%тАЩ
createGoogLeNetModel2D: no visible global function definition for
  тАШlayer_max_pooling_2dтАЩ
createGoogLeNetModel2D: no visible global function definition for
  тАШlayer_average_pooling_2dтАЩ
createGoogLeNetModel2D: no visible global function definition for
  тАШlayer_concatenateтАЩ
createGoogLeNetModel2D: no visible global function definition for
  тАШlayer_global_average_pooling_2dтАЩ
createGoogLeNetModel2D: no visible global function definition for
  тАШlayer_denseтАЩ
createGoogLeNetModel2D: no visible global function definition for
  тАШkeras_modelтАЩ
createResNetModel2D: no visible global function definition for тАШusePkgтАЩ
createResNetModel2D : addCommonLayers: no visible global function
  definition for тАШ%>%тАЩ
createResNetModel2D : addCommonLayers: no visible global function
  definition for тАШlayer_batch_normalizationтАЩ
createResNetModel2D : addCommonLayers: no visible global function
  definition for тАШlayer_activation_leaky_reluтАЩ
createResNetModel2D : groupedConvolutionLayer2D: no visible global
  function definition for тАШ%>%тАЩ
createResNetModel2D : groupedConvolutionLayer2D: no visible global
  function definition for тАШlayer_conv_2dтАЩ
createResNetModel2D : groupedConvolutionLayer2D: no visible global
  function definition for тАШlayer_lambdaтАЩ
createResNetModel2D : groupedConvolutionLayer2D: no visible global
  function definition for тАШlayer_concatenateтАЩ
createResNetModel2D : residualBlock2D: no visible global function
  definition for тАШ%>%тАЩ
createResNetModel2D : residualBlock2D: no visible global function
  definition for тАШlayer_conv_2dтАЩ
createResNetModel2D : residualBlock2D: no visible global function
  definition for тАШlayer_batch_normalizationтАЩ
createResNetModel2D : residualBlock2D: no visible global function
  definition for тАШlayer_addтАЩ
createResNetModel2D : residualBlock2D: no visible global function
  definition for тАШlayer_activation_leaky_reluтАЩ
createResNetModel2D: no visible global function definition for
  тАШlayer_inputтАЩ
createResNetModel2D: no visible global function definition for тАШ%>%тАЩ
createResNetModel2D: no visible global function definition for
  тАШlayer_conv_2dтАЩ
createResNetModel2D: no visible global function definition for
  тАШlayer_max_pooling_2dтАЩ
createResNetModel2D: no visible global function definition for
  тАШlayer_global_average_pooling_2dтАЩ
createResNetModel2D: no visible global function definition for
  тАШlayer_denseтАЩ
createResNetModel2D: no visible global function definition for
  тАШkeras_modelтАЩ
createResNetModel3D: no visible global function definition for тАШusePkgтАЩ
createResNetModel3D : addCommonLayers: no visible global function
  definition for тАШ%>%тАЩ
createResNetModel3D : addCommonLayers: no visible global function
  definition for тАШlayer_batch_normalizationтАЩ
createResNetModel3D : addCommonLayers: no visible global function
  definition for тАШlayer_activation_leaky_reluтАЩ
createResNetModel3D : groupedConvolutionLayer3D: no visible global
  function definition for тАШ%>%тАЩ
createResNetModel3D : groupedConvolutionLayer3D: no visible global
  function definition for тАШlayer_conv_3dтАЩ
createResNetModel3D : groupedConvolutionLayer3D: no visible global
  function definition for тАШlayer_lambdaтАЩ
createResNetModel3D : groupedConvolutionLayer3D: no visible global
  function definition for тАШlayer_concatenateтАЩ
createResNetModel3D : residualBlock3d: no visible global function
  definition for тАШ%>%тАЩ
createResNetModel3D : residualBlock3d: no visible global function
  definition for тАШlayer_conv_3dтАЩ
createResNetModel3D : residualBlock3d: no visible global function
  definition for тАШlayer_batch_normalizationтАЩ
createResNetModel3D : residualBlock3d: no visible global function
  definition for тАШlayer_addтАЩ
createResNetModel3D : residualBlock3d: no visible global function
  definition for тАШlayer_activation_leaky_reluтАЩ
createResNetModel3D: no visible global function definition for
  тАШlayer_inputтАЩ
createResNetModel3D: no visible global function definition for тАШ%>%тАЩ
createResNetModel3D: no visible global function definition for
  тАШlayer_conv_3dтАЩ
createResNetModel3D: no visible global function definition for
  тАШlayer_max_pooling_3dтАЩ
createResNetModel3D: no visible global function definition for
  тАШlayer_global_average_pooling_3dтАЩ
createResNetModel3D: no visible global function definition for
  тАШlayer_denseтАЩ
createResNetModel3D: no visible global function definition for
  тАШkeras_modelтАЩ
createSsd7Model2D: no visible global function definition for тАШusePkgтАЩ
createSsd7Model2D: no visible global function definition for
  тАШlayer_inputтАЩ
createSsd7Model2D: no visible global function definition for тАШ%>%тАЩ
createSsd7Model2D: no visible global function definition for
  тАШlayer_conv_2dтАЩ
createSsd7Model2D: no visible global function definition for
  тАШlayer_batch_normalizationтАЩ
createSsd7Model2D: no visible global function definition for
  тАШlayer_activation_eluтАЩ
createSsd7Model2D: no visible global function definition for
  тАШlayer_max_pooling_2dтАЩ
createSsd7Model2D: no visible global function definition for
  тАШlayer_reshapeтАЩ
createSsd7Model2D: no visible global function definition for
  тАШlayer_concatenateтАЩ
createSsd7Model2D: no visible global function definition for
  тАШlayer_activationтАЩ
createSsd7Model2D: no visible global function definition for
  тАШkeras_modelтАЩ
createSsd7Model3D: no visible global function definition for тАШusePkgтАЩ
createSsd7Model3D: no visible global function definition for
  тАШlayer_inputтАЩ
createSsd7Model3D: no visible global function definition for тАШ%>%тАЩ
createSsd7Model3D: no visible global function definition for
  тАШlayer_conv_3dтАЩ
createSsd7Model3D: no visible global function definition for
  тАШlayer_batch_normalizationтАЩ
createSsd7Model3D: no visible global function definition for
  тАШlayer_activation_eluтАЩ
createSsd7Model3D: no visible global function definition for
  тАШlayer_max_pooling_3dтАЩ
createSsd7Model3D: no visible global function definition for
  тАШlayer_reshapeтАЩ
createSsd7Model3D: no visible global function definition for
  тАШlayer_concatenateтАЩ
createSsd7Model3D: no visible global function definition for
  тАШlayer_activationтАЩ
createSsd7Model3D: no visible global function definition for
  тАШkeras_modelтАЩ
createSsdModel2D: no visible global function definition for тАШusePkgтАЩ
createSsdModel2D: no visible global function definition for
  тАШlayer_inputтАЩ
createSsdModel2D: no visible global function definition for тАШ%>%тАЩ
createSsdModel2D: no visible global function definition for
  тАШlayer_conv_2dтАЩ
createSsdModel2D: no visible global function definition for
  тАШinitializer_he_normalтАЩ
createSsdModel2D: no visible global function definition for
  тАШregularizer_l2тАЩ
createSsdModel2D: no visible global function definition for
  тАШlayer_max_pooling_2dтАЩ
createSsdModel2D: no visible global function definition for
  тАШlayer_zero_padding_2dтАЩ
createSsdModel2D: no visible global function definition for тАШheadтАЩ
createSsdModel2D: no visible global function definition for
  тАШlayer_reshapeтАЩ
createSsdModel2D: no visible global function definition for
  тАШlayer_concatenateтАЩ
createSsdModel2D: no visible global function definition for
  тАШlayer_activationтАЩ
createSsdModel2D: no visible global function definition for
  тАШkeras_modelтАЩ
createSsdModel3D: no visible global function definition for тАШusePkgтАЩ
createSsdModel3D: no visible global function definition for
  тАШlayer_inputтАЩ
createSsdModel3D: no visible global function definition for тАШ%>%тАЩ
createSsdModel3D: no visible global function definition for
  тАШlayer_conv_3dтАЩ
createSsdModel3D: no visible global function definition for
  тАШinitializer_he_normalтАЩ
createSsdModel3D: no visible global function definition for
  тАШregularizer_l2тАЩ
createSsdModel3D: no visible global function definition for
  тАШlayer_max_pooling_3dтАЩ
createSsdModel3D: no visible global function definition for
  тАШlayer_zero_padding_3dтАЩ
createSsdModel3D: no visible global function definition for тАШheadтАЩ
createSsdModel3D: no visible binding for global variable
  тАШAnchorBoxLayer3dтАЩ
createSsdModel3D: no visible global function definition for
  тАШlayer_reshapeтАЩ
createSsdModel3D: no visible global function definition for
  тАШlayer_concatenateтАЩ
createSsdModel3D: no visible global function definition for
  тАШlayer_activationтАЩ
createSsdModel3D: no visible global function definition for
  тАШkeras_modelтАЩ
createUnetModel2D: no visible global function definition for тАШusePkgтАЩ
createUnetModel2D: no visible global function definition for
  тАШlayer_inputтАЩ
createUnetModel2D: no visible global function definition for тАШ%>%тАЩ
createUnetModel2D: no visible global function definition for
  тАШlayer_conv_2dтАЩ
createUnetModel2D: no visible global function definition for
  тАШlayer_max_pooling_2dтАЩ
createUnetModel2D: no visible global function definition for
  тАШlayer_concatenateтАЩ
createUnetModel2D: no visible global function definition for
  тАШlayer_conv_2d_transposeтАЩ
createUnetModel2D: no visible global function definition for
  тАШkeras_modelтАЩ
createUnetModel3D: no visible global function definition for тАШusePkgтАЩ
createUnetModel3D: no visible global function definition for
  тАШlayer_inputтАЩ
createUnetModel3D: no visible global function definition for тАШ%>%тАЩ
createUnetModel3D: no visible global function definition for
  тАШlayer_conv_3dтАЩ
createUnetModel3D: no visible global function definition for
  тАШlayer_max_pooling_3dтАЩ
createUnetModel3D: no visible global function definition for
  тАШlayer_concatenateтАЩ
createUnetModel3D: no visible global function definition for
  тАШlayer_conv_3d_transposeтАЩ
createUnetModel3D: no visible global function definition for
  тАШkeras_modelтАЩ
createVggModel2D: no visible global function definition for тАШusePkgтАЩ
createVggModel2D: no visible global function definition for
  тАШkeras_model_sequentialтАЩ
createVggModel2D: no visible global function definition for тАШ%>%тАЩ
createVggModel2D: no visible global function definition for
  тАШlayer_conv_2dтАЩ
createVggModel2D: no visible global function definition for
  тАШlayer_max_pooling_2dтАЩ
createVggModel2D: no visible global function definition for
  тАШlayer_flattenтАЩ
createVggModel2D: no visible global function definition for
  тАШlayer_denseтАЩ
createVggModel2D: no visible global function definition for
  тАШlayer_dropoutтАЩ
createVggModel3D: no visible global function definition for тАШusePkgтАЩ
createVggModel3D: no visible global function definition for
  тАШkeras_model_sequentialтАЩ
createVggModel3D: no visible global function definition for тАШ%>%тАЩ
createVggModel3D: no visible global function definition for
  тАШlayer_conv_3dтАЩ
createVggModel3D: no visible global function definition for
  тАШlayer_max_pooling_3dтАЩ
createVggModel3D: no visible global function definition for
  тАШlayer_flattenтАЩ
createVggModel3D: no visible global function definition for
  тАШlayer_denseтАЩ
createVggModel3D: no visible global function definition for
  тАШlayer_dropoutтАЩ
decodeY: no visible global function definition for тАШtailтАЩ
decodeY: no visible global function definition for тАШas.antsImageтАЩ
drawRectangles: no visible global function definition for тАШplot.newтАЩ
drawRectangles: no visible global function definition for тАШrasterImageтАЩ
drawRectangles: no visible global function definition for тАШrectтАЩ
drawRectangles: no visible global function definition for тАШtextтАЩ
layer_anchor_box_2d: no visible global function definition for
  тАШcreate_layerтАЩ
layer_anchor_box_3d: no visible global function definition for
  тАШcreate_layerтАЩ
layer_l2_normalization_2d: no visible global function definition for
  тАШcreate_layerтАЩ
layer_l2_normalization_3d: no visible global function definition for
  тАШcreate_layerтАЩ
Undefined global functions or variables:
  %>% AnchorBoxLayer3d as.antsImage create_layer head
  initializer_he_normal keras_model keras_model_sequential
  layer_activation layer_activation_elu layer_activation_leaky_relu
  layer_add layer_average_pooling_2d layer_average_pooling_3d
  layer_batch_normalization layer_concatenate layer_conv_2d
  layer_conv_2d_transpose layer_conv_3d layer_conv_3d_transpose
  layer_dense layer_dropout layer_flatten
  layer_global_average_pooling_2d layer_global_average_pooling_3d
  layer_input layer_lambda layer_max_pooling_2d layer_max_pooling_3d
  layer_reshape layer_zero_padding_2d layer_zero_padding_3d plot.new
  rasterImage rect regularizer_l2 tail text usePkg
Consider adding
  importFrom("graphics", "plot.new", "rasterImage", "rect", "text")
  importFrom("utils", "head", "tail")
to your NAMESPACE file.
* checking Rd files ... NOTE
prepare_Rd: convertCoordinates.Rd:26-31: Dropping empty section \examples
prepare_Rd: drawRectangles.Rd:30-35: Dropping empty section \examples
* checking Rd metadata ... OK
* checking Rd line widths ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... WARNING
Undocumented code objects:
  тАШssdImageBatchGenerator2DтАЩ тАШssdImageBatchGenerator3DтАЩ
  тАШunetImageBatchGeneratorтАЩ
All user-level objects in a package should have documentation entries.
See chapter тАШWriting R documentation filesтАЩ in the тАШWriting R
ExtensionsтАЩ manual.
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... WARNING
Documented arguments not in \usage in documentation object 'AnchorBoxLayer2D':
  тАШimageSizeтАЩ тАШscaleтАЩ тАШnextScaleтАЩ тАШaspectRatiosтАЩ тАШvariancesтАЩ

Documented arguments not in \usage in documentation object 'AnchorBoxLayer3D':
  тАШimageSizeтАЩ тАШscaleтАЩ тАШnextScaleтАЩ тАШaspectRatiosтАЩ тАШvariancesтАЩ

Documented arguments not in \usage in documentation object 'L2NormalizationLayer2D':
  тАШscaleтАЩ

Documented arguments not in \usage in documentation object 'L2NormalizationLayer3D':
  тАШscaleтАЩ

Undocumented arguments in documentation object 'createAlexNetModel2D'
  тАШdenseUnitsтАЩ тАШdropoutRateтАЩ

Undocumented arguments in documentation object 'createAlexNetModel3D'
  тАШdenseUnitsтАЩ тАШdropoutRateтАЩ

Undocumented arguments in documentation object 'createDenseNetModel2D'
  тАШnumberOfFiltersтАЩ

Undocumented arguments in documentation object 'createDenseNetModel3D'
  тАШnumberOfFiltersтАЩ

Undocumented arguments in documentation object 'createSsdModel2D'
  тАШstyleтАЩ

Undocumented arguments in documentation object 'createSsdModel3D'
  тАШstyleтАЩ

Undocumented arguments in documentation object 'decodeY'
  тАШdomainImageтАЩ

Undocumented arguments in documentation object 'decodeY2D'
  тАШimageSizeтАЩ
Documented arguments not in \usage in documentation object 'decodeY2D':
  тАШinputImageSizeтАЩ

Undocumented arguments in documentation object 'decodeY3D'
  тАШimageSizeтАЩ
Documented arguments not in \usage in documentation object 'decodeY3D':
  тАШinputImageSizeтАЩ

Undocumented arguments in documentation object 'encodeY2D'
  тАШimageSizeтАЩ
Documented arguments not in \usage in documentation object 'encodeY2D':
  тАШinputImageSizeтАЩ

Undocumented arguments in documentation object 'encodeY3D'
  тАШimageSizeтАЩ
Documented arguments not in \usage in documentation object 'encodeY3D':
  тАШinputImageSizeтАЩ

Documented arguments not in \usage in documentation object 'lossSsd':
  тАШbackgroundRatioтАЩ тАШminNumberOfBackgroundBoxesтАЩ тАШalphaтАЩ

uvaSeg not working

library(ANTsRNet)
library(ANTsR)
#> Loading required package: 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 <- ri( 1 ) %>% resampleImage( c(4,4) ) %>% iMath( "Normalize" )
mask = randomMask( getMask( img ), 50 )
r = c( 3, 3 )
patch = getNeighborhoodInMask( img, mask, r, boundary.condition = "NA" )
uvaSegModel = uvaSegTrain( patch, 6 )
#> Error in py_call_impl(callable, dots$args, dots$keywords): _SymbolicException: Inputs to eager execution function cannot be Keras symbolic tensors, but found [<tf.Tensor 'dense_2/Identity:0' shape=(None, 6) dtype=float32>, <tf.Tensor 'dense_1/Identity:0' shape=(None, 6) dtype=float32>]
#> 
#> Detailed traceback: 
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py", line 728, in fit
#>     use_multiprocessing=use_multiprocessing)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2.py", line 324, in fit
#>     total_epochs=epochs)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2.py", line 123, in run_one_epoch
#>     batch_outs = execution_function(iterator)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training_v2_utils.py", line 86, in execution_function
#>     distributed_function(input_fn))
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/eager/def_function.py", line 457, in __call__
#>     result = self._call(*args, **kwds)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/eager/def_function.py", line 520, in _call
#>     return self._stateless_fn(*args, **kwds)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py", line 1823, in __call__
#>     return graph_function._filtered_call(args, kwargs)  # pylint: disable=protected-access
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py", line 1141, in _filtered_call
#>     self.captured_inputs)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py", line 1224, in _call_flat
#>     ctx, args, cancellation_manager=cancellation_manager)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/eager/function.py", line 511, in call
#>     ctx=ctx)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/eager/execute.py", line 75, in quick_execute
#>     "tensors, but found {}".format(keras_symbolic_tensors))

Created on 2020-01-30 by the reprex package (v0.3.0.9001)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       macOS Mojave 10.14.6        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2020-01-30                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version     date       lib source                             
#>  ANTsR       * 0.5.4.2     2019-11-14 [1] local                              
#>  ANTsRCore   * 0.7.3       2019-12-11 [1] Github (ANTsX/ANTsRCore@416d8f1)   
#>  ANTsRNet    * 1.1         2020-01-30 [1] local                              
#>  assertthat    0.2.1       2019-03-21 [1] CRAN (R 3.6.0)                     
#>  backports     1.1.5       2019-10-02 [1] CRAN (R 3.6.0)                     
#>  base64enc     0.1-3       2015-07-28 [1] CRAN (R 3.6.0)                     
#>  cli           2.0.1       2020-01-08 [1] CRAN (R 3.6.0)                     
#>  crayon        1.3.4       2017-09-16 [1] CRAN (R 3.6.0)                     
#>  digest        0.6.23      2019-11-23 [1] CRAN (R 3.6.0)                     
#>  evaluate      0.14        2019-05-28 [1] CRAN (R 3.6.0)                     
#>  fansi         0.4.1       2020-01-08 [1] CRAN (R 3.6.0)                     
#>  fs            1.3.1       2019-05-06 [1] CRAN (R 3.6.0)                     
#>  generics      0.0.2       2018-11-29 [1] CRAN (R 3.6.0)                     
#>  glue          1.3.1       2019-03-12 [1] CRAN (R 3.6.0)                     
#>  highr         0.8         2019-03-20 [1] CRAN (R 3.6.0)                     
#>  htmltools     0.4.0       2019-10-04 [1] CRAN (R 3.6.0)                     
#>  ITKR          0.5.2       2019-11-05 [1] Github (stnava/ITKR@fe97efa)       
#>  jsonlite      1.6         2018-12-07 [1] CRAN (R 3.6.0)                     
#>  keras         2.2.5.0     2019-10-08 [1] CRAN (R 3.6.0)                     
#>  knitr         1.26.1      2020-01-05 [1] Github (muschellij2/knitr@f5af631) 
#>  lattice       0.20-38     2018-11-04 [1] CRAN (R 3.6.0)                     
#>  magrittr      1.5         2014-11-22 [1] CRAN (R 3.6.0)                     
#>  Matrix        1.2-17      2019-03-22 [1] CRAN (R 3.6.0)                     
#>  mvtnorm       1.0-11      2019-06-19 [1] CRAN (R 3.6.0)                     
#>  pillar        1.4.3       2019-12-20 [1] CRAN (R 3.6.0)                     
#>  pkgconfig     2.0.3       2019-09-22 [1] CRAN (R 3.6.0)                     
#>  purrr         0.3.3       2019-10-18 [1] CRAN (R 3.6.0)                     
#>  R6            2.4.1       2019-11-12 [1] CRAN (R 3.6.0)                     
#>  Rcpp          1.0.3       2019-11-08 [1] CRAN (R 3.6.0)                     
#>  RcppEigen     0.3.3.7.0   2019-11-16 [1] CRAN (R 3.6.0)                     
#>  reprex        0.3.0.9001  2020-01-05 [1] Github (tidyverse/reprex@5ae0b29)  
#>  reticulate    1.13        2019-07-24 [1] CRAN (R 3.6.0)                     
#>  rlang         0.4.2       2019-11-23 [1] CRAN (R 3.6.0)                     
#>  rmarkdown     2.0.7       2020-01-17 [1] Github (rstudio/rmarkdown@2faf16a) 
#>  rstudioapi    0.10.0-9003 2020-01-05 [1] Github (rstudio/rstudioapi@abe596d)
#>  sessioninfo   1.1.1       2018-11-05 [1] CRAN (R 3.6.0)                     
#>  stringi       1.4.5       2020-01-11 [1] CRAN (R 3.6.0)                     
#>  stringr       1.4.0       2019-02-10 [1] CRAN (R 3.6.0)                     
#>  styler        1.1.1       2019-05-06 [1] CRAN (R 3.6.0)                     
#>  tensorflow    2.0.0       2019-10-02 [1] CRAN (R 3.6.0)                     
#>  tfruns        1.4         2018-08-25 [1] CRAN (R 3.6.0)                     
#>  tibble        2.1.3       2019-06-06 [1] CRAN (R 3.6.0)                     
#>  whisker       0.4         2019-08-28 [1] CRAN (R 3.6.0)                     
#>  withr         2.1.2       2018-03-15 [1] CRAN (R 3.6.0)                     
#>  xfun          0.11        2019-11-12 [1] CRAN (R 3.6.0)                     
#>  yaml          2.2.0       2018-07-25 [1] CRAN (R 3.6.0)                     
#>  zeallot       0.1.0       2018-01-28 [1] CRAN (R 3.6.0)                     
#> 
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

applyDBPN4x.R app?

Hey @stnava—do you think we should move applyDBPN4x.R to ANTsRNet Apps? Correct me if I’m wrong but it looks like it’s more of an application.

desikanKillianyTourvilleLabeling only produces few ROI stats

Hi, I ran this:

Desikan-Killiany-Tourville labeling

dkt <- desikanKillianyTourvilleLabeling(t1, verbose = TRUE )

DKT label propagation throughout the cortex

dktCorticalMask <- thresholdImage(dkt$segmentationImage, 1000, 3000, 1, 0)
dkt_tmp <- dktCorticalMask * dkt$lobarParcellation
ctMask <- thresholdImage(ct, 0, 0, 0, 1 )
dktPropagated <- iMath( ctMask, "PropagateLabelsThroughMask", ctMask * dkt_tmp )

Get average regional thickness values

kkRegionalStats <- labelStats( ct, dktPropagated )

#########
The kkRegionalStats are as follows:

  LabelValue Mean Min Max Variance Count Volume
6 0 2.25050940114837E-05 0 6.45785713195801 7.3504343231611E-05 11745573 11745573
9 1 4.46170796618715 0.134810075163841 7.60828638076782 1.14595331163874 114597 114597
4 2 4.07671980862016 0.405249327421188 7.39905118942261 1.38525981652527 77245 77245
1 3 4.81822021355789 0.400924563407898 9.02170276641846 1.6220879055683 68294 68294
3 4 4.04803002276969 0.639022290706635 8.20927333831787 1.85578869231405 31673 31673
7 7 4.57856543870385 0.389928877353668 7.97378826141357 1.24850672721444 111488 111488
8 8 4.22279086312069 0.287868797779083 7.82217359542847 1.55966843808537 74477 74477
5 9 4.66563194519103 0.0898957625031471 8.62117767333984 1.56477323722089 67147 67147
2 10 3.79709706348709 0.324555575847626 7.30307388305664 1.93271658343352 30274 30274

As it's hard to tell, only 9 ROIs, that's stange, could you please fix it?

Instructions for deepFlash and deepAtropos

Dear ANTsRNet experts,

I wonder if there are examples/instructions for viewing (and saving as nii.gz) deepFlash and deepAtropos results?
I tried but I could not locate them in the manual link.

Thank you in advance.

External data?

Hey @muschellij2 ,

We would like to turn some of the more well-vetted "apps" into ANTsRNet functions (e.g., brain extraction). However, these require the download of external data (e.g., a template and the model weights). In the R context, what is standard practice? Specifically, to where should these data be downloaded? A temp directory or inst/extdata/? Presumably it would be nice to download these data to a destination where they can be recycled for future function calls. Thanks.

installation issues

Hey @stnava,

I've reinstalled everything (ANTsR, ANTsCore, ANTsRNet) from scratch (i.e., completely removing the directories and cloning a fresh repo.). However, I'm getting this error

$ R CMD INSTALL ANTsRNet 

*** Successfully loaded .Rprofile ***

* installing to library ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library’
* installing *source* package ‘ANTsRNet’ ...
** R
** inst
** byte-compile and prepare package for lazy loading
Error in namespaceExport(ns, exports) : 
  undefined exports: imageListToMatrix, imagesToMatrix, matrixToImages
ERROR: lazy loading failed for package ‘ANTsRNet’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/ANTsRNet’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/ANTsRNet’

Since those "undefined exports" are from ANTsR, does this stem from your recent changes?

Nick

Installation Issue.

Describe the bug
Our team was having issues installing ANTsRNet on our ubuntu servers. (Distributor ID: Ubuntu, Description: Ubuntu 20.04.6 LTS Release: 20.04, Codename: focal)

To Reproduce
Steps to reproduce the behavior:

  1. I installed ITKR, ANTsRCore, and ANTsRCore via "Method 2: from command line (most traditional method)"... no issues there (to my read)
  2. I then tried both methods specified on the ANTsRNet github and both receive the same error (noted below).

> devtools::install_github( "ANTsX/ANTsRNet" )
Downloading GitHub repo ANTsX/ANTsRNet@HEAD
Skipping 2 packages not available: ANTsR, ANTsRCore
── R CMD build ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘/tmp/Rtmpea90i5/remotes65adb36036d31/ANTsX-ANTsRNet-0c56992/DESCRIPTION’ (458ms)
─  preparing ‘ANTsRNet’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘ANTsRNet_1.1.tar.gz’

Installing package into ‘/home/jamielh/lib/R/library’
(as ‘lib’ is unspecified)
* installing *source* package ‘ANTsRNet’ ...
** using non-staged installation via StagedInstall field
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘ANTsRNet’ in namespaceExport(ns, exports):
 undefined exports: GaussianDiffusion
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/jamielh/lib/R/library/ANTsRNet’
Warning message:
In i.p(...) :
  installation of package ‘/tmp/Rtmpea90i5/file65adb782270d1/ANTsRNet_1.1.tar.gz’ had non-zero exit status

Here's my R sessioninfo():

> sessioninfo::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.0 (2023-04-21)
 os       Ubuntu 20.04.6 LTS
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       America/New_York
 date     2023-06-09
 pandoc   NA

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 !  package     * version date (UTC) lib source
    cachem        1.0.6   2021-08-19 [2] CRAN (R 4.2.2)
    callr         3.7.3   2022-11-02 [2] CRAN (R 4.2.2)
 VP cli           3.6.0   2023-03-23 [2] CRAN (R 4.3.0) (on disk 3.6.1)
    crayon        1.5.2   2022-09-29 [1] CRAN (R 4.2.2)
    curl          5.0.0   2023-01-12 [2] CRAN (R 4.2.2)
    desc          1.4.2   2022-09-08 [1] CRAN (R 4.2.2)
    devtools      2.4.5   2022-10-11 [1] CRAN (R 4.2.2)
    digest        0.6.31  2022-12-11 [1] CRAN (R 4.2.2)
    ellipsis      0.3.2   2021-04-29 [2] CRAN (R 4.2.2)
    fastmap       1.1.0   2021-01-25 [2] CRAN (R 4.2.2)
    fs            1.6.1   2023-02-06 [2] CRAN (R 4.2.2)
    glue          1.6.2   2022-02-24 [1] CRAN (R 4.2.2)
    htmltools     0.5.4   2022-12-07 [1] CRAN (R 4.2.2)
    htmlwidgets   1.6.1   2023-01-07 [1] CRAN (R 4.2.2)
    httpuv        1.6.8   2023-01-12 [1] CRAN (R 4.2.2)
    later         1.3.0   2021-08-18 [1] CRAN (R 4.2.2)
    lifecycle     1.0.3   2022-10-07 [2] CRAN (R 4.2.2)
    magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.3.0)
    memoise       2.0.1   2021-11-26 [2] CRAN (R 4.2.2)
    mime          0.12    2021-09-28 [1] CRAN (R 4.2.2)
    miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.2.2)
    pkgbuild      1.4.0   2022-11-27 [1] CRAN (R 4.2.2)
    pkgload       1.3.2   2022-11-16 [1] CRAN (R 4.2.2)
    prettyunits   1.1.1   2020-01-24 [1] CRAN (R 4.2.2)
 VP processx      3.8.0   2023-04-18 [2] CRAN (R 4.3.0) (on disk 3.8.1)
    profvis       0.3.7   2020-11-02 [1] CRAN (R 4.2.2)
    promises      1.2.0.1 2021-02-11 [1] CRAN (R 4.2.2)
 VP ps            1.7.2   2023-04-18 [2] CRAN (R 4.3.0) (on disk 1.7.5)
    purrr         1.0.1   2023-01-10 [1] CRAN (R 4.2.2)
    R6            2.5.1   2021-08-19 [2] CRAN (R 4.2.2)
    Rcpp          1.0.10  2023-01-22 [1] CRAN (R 4.3.0)
    remotes       2.4.2   2021-11-30 [2] CRAN (R 4.2.2)
 VP rlang         1.0.6   2023-04-28 [2] CRAN (R 4.3.0) (on disk 1.1.1)
    rprojroot     2.0.3   2022-04-02 [1] CRAN (R 4.2.2)
    sessioninfo   1.2.2   2021-12-06 [2] CRAN (R 4.2.2)
    shiny         1.7.4   2022-12-15 [1] CRAN (R 4.2.2)
    stringi       1.7.12  2023-01-11 [1] CRAN (R 4.2.2)
    stringr       1.5.0   2022-12-02 [1] CRAN (R 4.2.2)
    urlchecker    1.0.1   2021-11-30 [2] CRAN (R 4.2.2)
    usethis       2.1.6   2022-05-25 [1] CRAN (R 4.2.2)
 VP vctrs         0.5.2   2023-04-19 [2] CRAN (R 4.3.0) (on disk 0.6.2)
    withr         2.5.0   2022-03-03 [2] CRAN (R 4.2.2)
    xtable        1.8-4   2019-04-21 [1] CRAN (R 4.2.2)

 [1] /home/jamielh/lib/R/library
 [2] /usr/local/lib/R/site-library
 [3] /usr/lib/R/site-library
 [4] /usr/lib/R/library

 V ── Loaded and on-disk version mismatch.
 P ── Loaded and on-disk path mismatch.

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

I thought about trying to use an earlier version, but it didn't look like one was available. Googling things, it looked like undefined exports occurs when one try to export an object that doesn't exist. Further googling made it seem like "gaussiandiffusion" was a pyTorch package? Have others run into this issue?

Any thoughts are much appreciated!
Jamie.

Dice metric is not working

If one runs the 2-D u-net example here with training, the following error occurs:

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  ValueError: Dimensions must be equal, but are 4 and 256 for 'loss/conv2d_134_loss/mul' (op: 'Mul') with input shapes: [4,256,256], [4,256,256,3].

CUDA and tensorflow-gpu on WSL2

This is not a bug, a comment.

It appears that it is now possible to run tensorflow-gpu with docker [1] or even without docker [2] through WSL2.
This requires using the a specific version of Nvidia drivers on windows. I lost the link Nvidia provided for WSL2 specific drivers, but I am using 465.12, which is not even listed on the regular driver download page.

I tried to follow the instructions and experiment on using ubuntu 20.04 LTS. I got as far as this:

> library(tensorflow)
> tf$config$list_physical_devices("GPU")
2020-12-11 11:08:30.076717: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-12-11 11:08:32.100652: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/maga/.local/share/r-miniconda/envs/r-reticulate/lib:/usr/lib/R/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/default-java/lib/server
2020-12-11 11:08:32.100688: W tensorflow/stream_executor/cuda/cuda_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303)
2020-12-11 11:08:32.100701: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (Maga-XPS15): /proc/driver/nvidia/version does not exist

I receive a similar error on the docker side as well:


maga@Maga-XPS15:~$ docker run --gpus all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
docker: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: Running hook #0:: error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: initialization error: driver error: failed to process request: unknown.
ERRO[0000] error waiting for container: context canceled

Instructions are flaky and I am not familiar with CUDA or tensorflow all that much to begin with. At this point I am not sure what to change or try. I brought this up, because if someone more knowledgeable figure out the instructions, this can greatly facilitate the use of whole ANTsR thing on windows. I am also happy to help test.

[1] https://docs.nvidia.com/cuda/wsl-user-guide/index.html
[2] https://stackoverflow.com/questions/63679865/install-tensorflow-gpu-on-wsl2

Converging in single cluster in DEC (Deep embedded clustering), R implementation

Speaking briefly, I noticed a strange performance difference in equal implementations of Deep embedded clustering (DEC) in R and Python (which is available at: https://github.com/XifengGuo/DEC-keras/blob/master/DEC.py ).

My question,
According to the figures below, the implementation in R coverage in the stop condition by putting all the observations(i.e. data samples) in one cluster (Figure2).

Here are some evidences:

Figure1
Figure1 after first initializing with kmeans
Figure2
Figure2 converging in one cluster after the stop condition
Train on 70000 samples Epoch 1/10 70000/70000 [==============================] - 4s 57us/sample - loss: 0.0770 Epoch 2/10 70000/70000 [==============================] - 3s 44us/sample - loss: 0.0444 Epoch 3/10 70000/70000 [==============================] - 3s 44us/sample - loss: 0.0360 Epoch 4/10 70000/70000 [==============================] - 3s 45us/sample - loss: 0.0312 Epoch 5/10 70000/70000 [==============================] - 3s 46us/sample - loss: 0.0279 Epoch 6/10 70000/70000 [==============================] - 3s 44us/sample - loss: 0.0263 Epoch 7/10 70000/70000 [==============================] - 3s 45us/sample - loss: 0.0252 Epoch 8/10 70000/70000 [==============================] - 3s 45us/sample - loss: 0.0243 Epoch 9/10 70000/70000 [==============================] - 3s 45us/sample - loss: 0.0236 Epoch 10/10 70000/70000 [==============================] - 3s 45us/sample - loss: 0.0231 <tensorflow.python.keras.callbacks.History>

Figure 3 training AE with 100 epochs

ACC =1, NMI= 1 Iteration 1: (out of 20000): loss = 1e+08, deltaLabel = 0 ACC =0.5117571, NMI= 0.4666276 Iteration 11: (out of 20000): loss = 0.8442134, deltaLabel = 0.4882429 ACC =0.4964714, NMI= 0.4784229 Iteration 21: (out of 20000): loss = 0.4245124, deltaLabel = 0.5035286 ACC =0.6418429, NMI= 0.3421767 Iteration 31: (out of 20000): loss = 1.214075, deltaLabel = 0.3581571 ACC =0.9478857, NMI= 0.7269456 Iteration 41: (out of 20000): loss = 1.183661, deltaLabel = 0.05211429 ACC =0.6602286, NMI= 0.8314889 Iteration 51: (out of 20000): loss = 1.712941, deltaLabel = 0.3397714 ACC =0.6393429, NMI= 0 Iteration 61: (out of 20000): loss = 2.514483, deltaLabel = 0.3606571 ACC =0, NMI= NaN Iteration 71: (out of 20000): loss = 2.386619, deltaLabel = 1 ACC =0.9999857, NMI= 0 Iteration 81: (out of 20000): loss = 2.373431, deltaLabel = 1.428571e-05

Figure 4 fitting the DEC model

Which it was accordingly respect to Figure 5 and Figure 6 in Python

image

Figure 5 Initializing the labels by kmeans

image

Figure 6 final labeling after the model coverage (x-axis is the samples and y-axis is the labels)

Could you please let me know why this is happening? Is “klb” really works (What I guess) in this code (R implementation)?

Information about the machine:
1- Python 3.7 lunched by Spyder 4.1
2- Rstodio Version 1.2.5033

The implementation in R :
https://www.dropbox.com/s/cgavozr1c1rm60s/DEC_test_original.R?dl=0
The implementation in Python:
https://www.dropbox.com/s/c8zd47mv3nsfo3w/DEC_original.py?dl=0

I am waiting for your reply and solution,
Please let me know if any information I can provide!
Thanks for reading!

Sincerely,
Reza

Template-Based Data Augmentation comprehension issue

Hi,

I'm trying to implement data augmentation for U-net training on MRI images using template-based augmentation method described in "Convolutional Neural Networks with Template-Based Data Augmentation for Functional Lung Image Quantification" (https://www.ncbi.nlm.nih.gov/pubmed/30195415).

What i'm trying to understand is how the new data is created. The following formula is used :

Snew = Ssource(φinvtarget(φsource)).

My understanding of the formula is : Ssource will be mapped to the template space, and then mapped with the inverse φ to Starget, this result is Snew. In my comprehension, Ssource will be mapped to the target space, and if φ is a perfect mapping, the result Snew will be exactly similar to Starget.

My question is, is Snew exactly similar to Starget ?
If yes, how the data could be augmented ?

Thanks for your answer,

Regards

Poor results in brainExtraction

Sometimes brainExtraction gives poor results---specifically, nonzero probabilities in the face area. This is due to the training data, in many cases, being defaced. In the short term before adding more training data, in order to improve results for such cases, one can modify the input t1 as follows:

t1 <- antsImageRead(t1_file)

kirby <- antsImageRead(getANTsXNetData("kirby"))
kirby_mask <- thresholdImage(brainExtraction(kirby, modality = "t1", verbose=TRUE), 0.5, 1, 1, 0)
kirby_dilated_mask <- iMath(kirby_mask, "MD", 25)

reg <- antsRegistration(fixed=t1, moving=kirby, typeofTransform="antsRegistrationSyNQuick[a]") 
t1_dilated_mask <- antsApplyTransforms(fixed=t1, moving=kirby_dilated_mask, 
    transformlist=reg$fwdtransforms, interpolator="nearestNeighbor")

t1_defaced <- t1 * t1_dilated_mask   
mask <- brainExtraction(t1_defaced, modality="t1")

Are ANTsRNet functions available for **training** and **testing** UNet models?

Hi Nick et al,

I'm quite new to ANTsRNet. I see that the ANTsRNet package offers several different script examples for creating UNet models (such as createUnetModel3D(), etc). I also see that ANTsRNet also provides UNet ulitities for encoding and decoding the labels.

But are there ANTsRNet functions (or example ANTsRNet scripts) available for training and for testing 3D ANTsRNet models?

Thanks,
Jay

P.S. (1) Background: I wish to write an ANTsRNet script for segmenting non-brain structures. So I don't have the option of using the pre-trained weights of models trained on brain structures. I tried to look at the UNet training examples in Nick's GitHub (https://github.com/ntustison/ANTsRNetExamples/tree/master/Examples/UnetExample), but it says the examples are deprecated. I tried to press ahead anyway, but have been stumped by errors.

(2) I see that the aforementioned UNet scripts in Nick's GitHub use evaluate() and predict() for testing purposes. Is this still the correct way for testing trained UNet models?

Code error in the example for "createUnetModel2D"

Hi, authors!
I got an error message in the example code for "createUnetModel2D" as follows.

>  track <- model %>% fit( X_train, Y_train,
+               epochs = 100, batch_size = 4, verbose = 1, shuffle = TRUE,
+               callbacks = list(
+                 callback_model_checkpoint( "unetModelInterimWeights.h5",
+                     monitor = 'val_loss', save_best_only = TRUE ),
+                 callback_reduce_lr_on_plateau( monitor = "val_loss", factor = 0.1 )
+               ),
+               validation_split = 0.2 )
WARNING:tensorflow:Can save best model only with val_loss available, skipping.
WARNING:tensorflow:Reduce LR on plateau conditioned on metric `val_loss` which is not available. Available metrics are: lr
Train on 4 samples, validate on 2 samples
Epoch 1/100
4/4 [==============================] - 0s 58ms/sample
error in py_call_impl(callable, dots$args, dots$keywords) : (I just modified Japanese to English.)
  RuntimeError: Evaluation error: ValueError: Dimension must be 4 but is 5 for 'loss/conv2d_44_loss/transpose' (op: 'Transpose') with input shapes: [4,256,256,3], [5].. 

In this case, I think that "batch_size = 5" is correct and it's code worked.

track <- model %>% fit( X_train, Y_train,
              epochs = 100, batch_size = 5, verbose = 1, shuffle = TRUE,
              callbacks = list(
                callback_model_checkpoint( "unetModelInterimWeights.h5",
                    monitor = 'val_loss', save_best_only = TRUE ),
                callback_reduce_lr_on_plateau( monitor = "val_loss", factor = 0.1 )
              ), validation_split = 0.2 )

I hope you find this report helpful.

Thank you for your great work in R.

Ssd7 Model

createSsd7Model2D fails for 2D

library(ANTsRNet)
createSsd7Model2D(c(256, 256, 3), 2)
#> Error in py_call_impl(callable, dots$args, dots$keywords): ValueError: Duplicate node name in graph: 'packed'
#> 
#> Detailed traceback: 
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/backend.py", line 3014, in tile
#>     return array_ops.tile(x, n)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_array_ops.py", line 11293, in tile
#>     input, multiples, name=name, ctx=_ctx)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_array_ops.py", line 11340, in tile_eager_fallback
#>     _attr_Tmultiples, (multiples,) = _execute.args_to_matching_eager([multiples], _ctx, _dtypes.int32)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/eager/execute.py", line 257, in args_to_matching_eager
#>     t, dtype, preferred_dtype=default_dtype, ctx=ctx))
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1296, in internal_convert_to_tensor
#>     ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 1278, in _autopacking_conversion_function
#>     return _autopacking_helper(v, dtype, name or "packed")
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 1214, in _autopacking_helper
#>     return gen_array_ops.pack(elems_as_tensors, name=scope)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_array_ops.py", line 6304, in pack
#>     "Pack", values=values, axis=axis, name=name)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/op_def_library.py", line 793, in _apply_op_helper
#>     op_def=op_def)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/func_graph.py", line 548, in create_op
#>     compute_device)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 3429, in _create_op_internal
#>     op_def=op_def)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1773, in __init__
#>     control_input_ops)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1613, in _create_c_op
#>     raise ValueError(str(e))

Also fails for 3D

library(ANTsRNet)
createSsd7Model3D(c(256, 256, 100, 3), 2)
#> Error in py_call_impl(callable, dots$args, dots$keywords): ValueError: Negative dimension size caused by subtracting 3 from 1 for 'classes7_1/Conv3D' (op: 'Conv3D') with input shapes: [?,4,4,1,32], [3,3,3,32,10].
#> 
#> Detailed traceback: 
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 842, in __call__
#>     outputs = call_fn(cast_inputs, *args, **kwargs)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/convolutional.py", line 197, in call
#>     outputs = self._convolution_op(inputs, self.kernel)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/ops/nn_ops.py", line 1134, in __call__
#>     return self.conv_op(inp, filter)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/ops/nn_ops.py", line 639, in __call__
#>     return self.call(inp, filter)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/ops/nn_ops.py", line 238, in __call__
#>     name=self.name)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_nn_ops.py", line 1553, in conv3d
#>     dilations=dilations, name=name)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/op_def_library.py", line 793, in _apply_op_helper
#>     op_def=op_def)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/func_graph.py", line 548, in create_op
#>     compute_device)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 3429, in _create_op_internal
#>     op_def=op_def)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1773, in __init__
#>     control_input_ops)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1613, in _create_c_op
#>     raise ValueError(str(e))

Created on 2020-01-30 by the reprex package (v0.3.0.9001)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       macOS Mojave 10.14.6        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2020-01-30                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version     date       lib source                             
#>  ANTsR         0.5.4.2     2019-11-14 [1] local                              
#>  ANTsRCore     0.7.3       2019-12-11 [1] Github (ANTsX/ANTsRCore@416d8f1)   
#>  ANTsRNet    * 1.1         2020-01-30 [1] local                              
#>  assertthat    0.2.1       2019-03-21 [1] CRAN (R 3.6.0)                     
#>  backports     1.1.5       2019-10-02 [1] CRAN (R 3.6.0)                     
#>  base64enc     0.1-3       2015-07-28 [1] CRAN (R 3.6.0)                     
#>  cli           2.0.1       2020-01-08 [1] CRAN (R 3.6.0)                     
#>  crayon        1.3.4       2017-09-16 [1] CRAN (R 3.6.0)                     
#>  digest        0.6.23      2019-11-23 [1] CRAN (R 3.6.0)                     
#>  evaluate      0.14        2019-05-28 [1] CRAN (R 3.6.0)                     
#>  fansi         0.4.1       2020-01-08 [1] CRAN (R 3.6.0)                     
#>  fs            1.3.1       2019-05-06 [1] CRAN (R 3.6.0)                     
#>  generics      0.0.2       2018-11-29 [1] CRAN (R 3.6.0)                     
#>  glue          1.3.1       2019-03-12 [1] CRAN (R 3.6.0)                     
#>  highr         0.8         2019-03-20 [1] CRAN (R 3.6.0)                     
#>  htmltools     0.4.0       2019-10-04 [1] CRAN (R 3.6.0)                     
#>  ITKR          0.5.2       2019-11-05 [1] Github (stnava/ITKR@fe97efa)       
#>  jsonlite      1.6         2018-12-07 [1] CRAN (R 3.6.0)                     
#>  keras         2.2.5.0     2019-10-08 [1] CRAN (R 3.6.0)                     
#>  knitr         1.26.1      2020-01-05 [1] Github (muschellij2/knitr@f5af631) 
#>  lattice       0.20-38     2018-11-04 [1] CRAN (R 3.6.0)                     
#>  magrittr      1.5         2014-11-22 [1] CRAN (R 3.6.0)                     
#>  Matrix        1.2-17      2019-03-22 [1] CRAN (R 3.6.0)                     
#>  mvtnorm       1.0-11      2019-06-19 [1] CRAN (R 3.6.0)                     
#>  pillar        1.4.3       2019-12-20 [1] CRAN (R 3.6.0)                     
#>  pkgconfig     2.0.3       2019-09-22 [1] CRAN (R 3.6.0)                     
#>  purrr         0.3.3       2019-10-18 [1] CRAN (R 3.6.0)                     
#>  R6            2.4.1       2019-11-12 [1] CRAN (R 3.6.0)                     
#>  Rcpp          1.0.3       2019-11-08 [1] CRAN (R 3.6.0)                     
#>  RcppEigen     0.3.3.7.0   2019-11-16 [1] CRAN (R 3.6.0)                     
#>  reprex        0.3.0.9001  2020-01-05 [1] Github (tidyverse/reprex@5ae0b29)  
#>  reticulate    1.13        2019-07-24 [1] CRAN (R 3.6.0)                     
#>  rlang         0.4.2       2019-11-23 [1] CRAN (R 3.6.0)                     
#>  rmarkdown     2.0.7       2020-01-17 [1] Github (rstudio/rmarkdown@2faf16a) 
#>  rstudioapi    0.10.0-9003 2020-01-05 [1] Github (rstudio/rstudioapi@abe596d)
#>  sessioninfo   1.1.1       2018-11-05 [1] CRAN (R 3.6.0)                     
#>  stringi       1.4.5       2020-01-11 [1] CRAN (R 3.6.0)                     
#>  stringr       1.4.0       2019-02-10 [1] CRAN (R 3.6.0)                     
#>  styler        1.1.1       2019-05-06 [1] CRAN (R 3.6.0)                     
#>  tensorflow    2.0.0       2019-10-02 [1] CRAN (R 3.6.0)                     
#>  tfruns        1.4         2018-08-25 [1] CRAN (R 3.6.0)                     
#>  tibble        2.1.3       2019-06-06 [1] CRAN (R 3.6.0)                     
#>  whisker       0.4         2019-08-28 [1] CRAN (R 3.6.0)                     
#>  withr         2.1.2       2018-03-15 [1] CRAN (R 3.6.0)                     
#>  xfun          0.11        2019-11-12 [1] CRAN (R 3.6.0)                     
#>  yaml          2.2.0       2018-07-25 [1] CRAN (R 3.6.0)                     
#>  zeallot       0.1.0       2018-01-28 [1] CRAN (R 3.6.0)                     
#> 
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

Cortical thickness evaluation inconsistency!!!

Hi there. I tried two versions cortical thickness evaluation methods, python one and R one. It turned out the evaluated thickness varied in two approaches. I think this could be the difference of probability maps evaluation in two sessions of deep atropos? How can I fix this?

3D image dataset for a tutorial of image segmentation

Do you have any 3D image dataset and codes as a tutorial of 3D image segmentation in this package?

I would like to check the 3D segmentation accuracy using 3D U-NET and other models in ANTsRNet, but I did not find any tutorial executable code for the 3D image segmentation in the package.

It would be helpful to get some advice.

Thank you.

Satoshi.

Reference for DeepFlash

Hi,
Is there a reference for the DeepFlash hippocampal segmentation tool? Paper/ conference abstract?

Some feedback: it works really well, even at 7T! Thanks for the tool. :D

Training with template base data augmentation

Dear ANTs expert.

I'm not reporting a bug , I have basic question regarding the usage of antsRnet.

Objectives

I wish to perform segmentation using antsRnet. I have a small database of mouse brain in nifti format with the corresponding masks and I would like to test the template base data augmentation strategy. So far I've been able to :

  • install antsR, antsPy, antsRnet, ansPynet on Ubuntu 20.04, and cuda and cudnn are happy.

  • check that keras is working on my computer from Python and from R independlty of ANTs with typical example coming from the official documentation

  • use different examples from the depreciated repository ANTsXNet

  • BrainExtraction example (extraction) is working using the Python and R

  • PigLungSegmentation example (extraction) is working using the Python and R

  • ProtonMRILungSegmentation (extraction) is working using the Python and R

  • BrainExtraction is working in Python with multiple MPRAGE data coming from our 3T Prisma, (result are really really good in 98% of the brain and completely wrong for the remaining 2%, I need to open later an another issue on this topics)

  • the mouse data are available in 3 matrix size in 32x32x32 , 64x64x64 , 128x128x128, only one is used

  • creation of the template for each using ANTs in bash was also fine and I get all usual transformations

Case 1:

  • I try to use the training script from https://github.com/ANTsXNet/PigLungSegmentation/blob/master/Scripts/Training/trainUnetModel.R (I should have use the script from BrainExtraction but this one was slightly simpler).

  • the script_training.R (enclosed) runs until the fit. All images, masks and transformation are correctly loaded.

  • the error (Log1.txt enclosed) is the following : ValueError: Failed to find data adapter that can handle input: <class 'NoneType'>, <class 'NoneType'>,

Case 2:

so I tried to look to another training example from ProtonMRILungSegmentation

  • I found that small adjustment was necessary regarding the depreciated example when creating the model, for instance the loss function must be defined in the script
metric_multilabel_dice_coefficient <-
  custom_metric( "multilabel_dice_coefficient",
                 multilabel_dice_coefficient )

loss_dice <- function( y_true, y_pred ) {
  -multilabel_dice_coefficient(y_true, y_pred)
}
attr(loss_dice, "py_function_name") <- "multilabel_dice_coefficient"
  • nevertheless the model crash during the fit (see Log2.txt)

Case 3:

I tried to test the simplest example I could find and I pick an example from the documentation https://github.com/ANTsX/ANTsRNet/blob/master/docs/reference/createUnetModel2D.html

library( ANTsR )
library( ANTsRNet )
library( keras )
keras::backend()$clear_session()
Sys.setenv( "CUDA_VISIBLE_DEVICES" = 1 )

imageIDs <- c( "r16", "r27", "r30", "r62", "r64", "r85" )
trainingBatchSize <- length( imageIDs )

# Perform simple 3-tissue segmentation.

segmentationLabels <- c( 1, 2, 3 )
numberOfLabels <- length( segmentationLabels )
initialization <- paste0( 'KMeans[', numberOfLabels, ']' )

domainImage <- antsImageRead( getANTsRData( imageIDs[1] ) )

X_train <- array( data = NA, dim = c( trainingBatchSize, dim( domainImage ), 1 ) )
Y_train <- array( data = NA, dim = c( trainingBatchSize, dim( domainImage ) ) )

images <- list()
segmentations <- list()

for( i in seq_len( trainingBatchSize ) )
{
  cat( "Processing image", imageIDs[i], "\n" )
  image <- antsImageRead( getANTsRData( imageIDs[i] ) )
  mask <- getMask( image )
  segmentation <- atropos( image, mask, initialization )$segmentation
  
  X_train[i,,, 1] <- as.array( image )
  Y_train[i,,] <- as.array( segmentation )
}
#> Processing image r16 
#> Processing image r27 
#> Processing image r30 
#> Processing image r62 
#> Processing image r64 
#> Processing image r85 
Y_train <- encodeUnet( Y_train, segmentationLabels )

# Perform a simple normalization

X_train <- ( X_train - mean( X_train ) ) / sd( X_train )

# Create the model

model <- createUnetModel2D( c( dim( domainImage ), 1 ),
                            numberOfOutputs = numberOfLabels )

metric_multilabel_dice_coefficient <-
  custom_metric( "multilabel_dice_coefficient",
                 multilabel_dice_coefficient )

loss_dice <- function( y_true, y_pred ) {
  -multilabel_dice_coefficient(y_true, y_pred)
}
attr(loss_dice, "py_function_name") <- "multilabel_dice_coefficient"

model %>% compile( loss = loss_dice,
                   optimizer = optimizer_adam( lr = 0.0001 ),
                   metrics = metric_multilabel_dice_coefficient )

# Comment out the rest due to travis build constraints

# Fit the model


print(model)
summary(model)


print(dim(X_train))
print(dim(Y_train))

track <- model %>% fit( X_train, Y_train,
              epochs = 100, batch_size = 5, verbose = 1, shuffle = TRUE,
              callbacks = list(
                callback_model_checkpoint( "unetModelInterimWeights.h5",
                    monitor = 'val_loss', save_best_only = TRUE ),
                callback_reduce_lr_on_plateau( monitor = "val_loss", factor = 0.1 )
              ),
              validation_split = 0.2 )

  • Again the code crash during the fit (see log3.txt enclosed). The script is also enclosed

Disclaim

  • R and Keras are mostly new to me.

Questions:

I wish first to solve the simplest example related to case 3.

  • Question a) is the issue related to keras or to antsRnet or to a mistake in the script ?
  • Question b) what would be the best way to debug such error ? I wish to debug this kind of issue myself but I'm lost by the error messages until now.
  • Question c) My GPU have only 4Go but I don't think that an issue , could you confirm ?
  • Question d) For all cases. If the definition of the model or the loss evaluation doesn't match the dimension of my data, I'm expected that the error message will be more explicit, is it true ?
  • Question e) Is there any other test/script I could launch to check my installation or usage of antsRnet.

Thanks in advance for your help.
Valéry

Script

case_1_trainUnetModel.R.txt
case_2_trainUnetModel_Valery.R.txt
case_3_example_ants_createUnetModel2D.R.txt

Log

Log1.txt
Log2.txt
Log3.txt

Regarding 'desikanKillianyTourvilleLabeling'

I am testing 'desikanKillianyTourvilleLabeling' function implemented in ANTsRNet. It works great with huge memory on my virtual machine (VirtualBox). It takes up around 60 GB out of 64 GB. However, it crashes when I ran on other data. When I restart VirtualMachine, then it works great for one data and it crashes again in the middle of processing the next data. I did a few things to refresh the memory. However, it seems not to refresh the memory completely.

I wonder if I reduce the memory usage by controlling the number of CPU cores used in the process. I anticipate that it will reduce the processing speed but it won't crash by maxing out the memory working on the next data. To test this, I want to reduce the number of CPU cores being used by 'desikanKillianyTourvilleLabeling' but I cannot find that option in the help file.

Is there any method I can limit the memory usage by desikanKillianyTourvilleLabeling function?

Other segmentation functions (e.g., deepAtropos or deepFalsh) are working great without any issue of crashing (presumably less intensive memory and/or CPU use).

Thank you.

creating createResNetModel1D

Hello, interesting project, thanks for sharing.
I am trying to write createResNetModel1D.
I have just taken createResNetModel2D and tried to convert to 1D layers.
I have some doubts on the following lines in squeezeAndExciteBlock2D:


    if( K$image_data_format() == "channels_first" )
      {
      block <- block %>% layer_permute( c( 4, 2, 3 ) )
      }
    x <- list( initial, block ) %>% layer_multiply()

I am using the following instead of c(4, 2, 3):

layer_permute( c( 4, 3 ) )

Not sure if it might be correct. What is the meaning of this permutation and when is supposed to be applied?

Any possibility of refining DKT labels

The results seemed good, in general, without any complex parameter setup step. However, a fair amount of sulcal CSF area seemed included in the cortical GM (overestimated cortical GM).

In the following link, I can see a few options, which are helpful, but not enough.
https://rdrr.io/github/ANTsX/ANTsRNet/man/desikanKillianyTourvilleLabeling.html
If possible, it would be great to know any fine-tuning parameters (or options) available to refine the result of DKT labeling to deal with an over/under-estimated tissue area.

Alternatively, it would be great to have some pre- and/or post-processing options for the DKT labeling to improve the results.

Currently, I understand that T1w is only accepted as an input image. I wonder if any other optional images can be loaded (as multiple inputs) or a single input of another contrast, such as T2 FLAIR.

Thank you,
-SC

Huge memory usage after using desikanKillianyTourvilleLabeling()

Hi there.
After I ran dkt <- desikanKillianyTourvilleLabeling(T1), it apeared that the memory was up to 22GB for a single run, even after I ran rm(list = ls()).
Further more, if I looped subjects using this function, the memory would be accumulated and finally caused memory failure. I guess the problem might be the parameters of the deep learning model?
Can you help to check it out, solutions will be much appreciated.
Thank you!

net structure

Hello
I was trying to run the brainextraction exsample and the trained net does not load. The number of layers of the net in the r code and the trained net seem not to fit, after some searching it gives a message that the r net has 15 layers, and the trained net 18. Could someone probably help with that. I am aware that the main work is training the net, so I would appreciate any help

A 'tensorflow not found' error

Hello,

I'm trying to familiarize myself about how ANTsRNet works. To this end, I'm trying to run some example ANTsRNet script.

The 'tensor flow not found' error occurs with every single one of the ANTsRNet scripts I've tried to run so far.

For instance, this is what happens when I try to run "ANTsRNet.quick.example.r" from https://github.com/ANTsX/ANTsPyNet/wiki/Quick-example.

The script terminates with the following tensorflow error:

Error: Python module tensorflow.keras was not found.

This error occurs when the createUnetModel2D() call in the script is encountered (please see the attached log and the script I'm running). In general (as far as I can tell; I'm not positive), the error seems to occur anytime anything in the keras:: domain is called either directly or through a dependent package. But keras seems to be installed fine on my machine; for instance, library(keras) executes fine without errors.

I tried simple-minded things like
> install.packages( "tensorflow" )
It ran without error, but the aforementioned tensorflow error still occurs.

FYI, the GPU on my laptop (Windows 11 64-bit home edition) is not set up.

Thank you,
Jay

ANTsRNet_error.log.TXT
ANTsRNet.quick.example.r.TXT

Limit threading

Just a follow up to an earlier ANTsR issue I raised---

Tensorflow also grabs all resources so to limit that, we have to do:

library( keras )
library( tensorflow )

k_clear_session()
threads <- 1L
config <- tf$ConfigProto( intra_op_parallelism_threads = threads,
                          inter_op_parallelism_threads = threads )
session <- tf$Session( config = config )
k_set_session( session )

although for Tensorflow 2.0, one has to replace tf$ with tf$compat$v1$.

Installation failed.

ANTsR and ANTsRCore were successfully installed. However, I got the following error when I attempted to install ANTsRNet on Ubuntu 20.04. I have tried two methods. Using github (Option 1) and compiling from source (Option 2). I attached the error message from both attempts.

Option 1

devtools::install_github("ANTsX/ANTsRNet")
Downloading GitHub repo ANTsX/ANTsRNet@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?

1: All
2: CRAN packages only
3: None
4: keras (2.13.0 -> b7a381d36...) [GitHub]

Enter one or more numbers, or an empty line to skip updates:
── R CMD build ───────────────────────────────────────────────────────────────────
✔ checking for file ‘/tmp/RtmpfvvnCE/remotes1d97c5cd36e60/ANTsX-ANTsRNet-ddd3d76/DESCRIPTION’ ...
─ preparing ‘ANTsRNet’:
✔ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘ANTsRNet_1.1.tar.gz’

Installing package into ‘/home/xubuntu/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)

  • installing source package ‘ANTsRNet’ ...
    ** using non-staged installation via StagedInstall field
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    Error: object ‘antsAverageImages’ is not exported by 'namespace:ANTsRCore'
    Execution halted
    ERROR: lazy loading failed for package ‘ANTsRNet’
  • removing ‘/home/xubuntu/R/x86_64-pc-linux-gnu-library/3.6/ANTsRNet’
    Warning message:
    In i.p(...) :
    installation of package ‘/tmp/RtmpfvvnCE/file1d97c1b0665b2/ANTsRNet_1.1.tar.gz’ had non-zero exit status

Option 2
(base) xubuntu@ubuntu:~$ R CMD INSTALL ANTsRNet

  • installing to library ‘/home/xubuntu/R/x86_64-pc-linux-gnu-library/3.6’
  • installing source package ‘ANTsRNet’ ...
    ** using non-staged installation via StagedInstall field
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    Error: object ‘antsAverageImages’ is not exported by 'namespace:ANTsRCore'
    Execution halted
    ERROR: lazy loading failed for package ‘ANTsRNet’
  • removing ‘/home/xubuntu/R/x86_64-pc-linux-gnu-library/3.6/ANTsRNet’

Please instruct me on what I should do to resolve this issue.

Best,
SC

Cortical thickness: Error in atropos$probabilityImages[[4]] + atropos$probabilityimages[[5]] :

Hi, I run this:
library(ANTsRNet)
library(ANTsR)
library(keras)
t1 <- antsImageRead('t1_test.nii')
ct <- corticalThickness(t1, antsxnetCacheDirectory = './', verbose = TRUE)

which produce an error:

The composite transform comprises the following transforms (in order):

  1. inverse of /var/folders/k6/j4kr_q3s5w345njb9dbh1v5m0000gn/T//RtmpVKxCUD/file1484265f99ab0GenericAffine.mat (type = AffineTransform)
    =============================================================================
    Default pixel value: 0.0000e+00
    Interpolation type: LinearInterpolateImageFunction
    Output warped image: 0x7ffb5e6175d0
    Error in atropos$probabilityImages[[4]] + atropos$probabilityimages[[5]] :
    non-numeric argument to binary operator

#######
I've tested the pipeline on two computer, which all produced this error, can you help to fix this?

Thank you.

Super resolution GAN Model

Default for SuperResolutionGanModel is bad for 64x64x3, but needs to be 112x112x3. Technically the product needs to be 25088/2 = 12544

library( keras )
library( ANTsRNet )

keras::backend()$clear_session()
ganModel <- SuperResolutionGanModel$new(lowResolutionImageSize = c( 112, 112, 3 ))
ganModel <- SuperResolutionGanModel$new(lowResolutionImageSize = c( 64, 64, 3 ))
#> Error in py_call_impl(callable, dots$args, dots$keywords): ValueError: Input 0 of layer dense_7 is incompatible with the layer: expected axis -1 of input shape to have value 25088 but received input with shape [None, 8192]
#> 
#> Detailed traceback: 
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 842, in __call__
#>     outputs = call_fn(cast_inputs, *args, **kwargs)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/sequential.py", line 256, in call
#>     return super(Sequential, self).call(inputs, training=training, mask=mask)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/network.py", line 708, in call
#>     convert_kwargs_to_constants=base_layer_utils.call_context().saving)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/network.py", line 860, in _run_internal_graph
#>     output_tensors = layer(computed_tensors, **kwargs)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 812, in __call__
#>     self.name)
#>   File "/Users/johnmuschelli/.virtualenvs/r-reticulate/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/input_spec.py", line 213, in assert_input_compatibility
#>     ' but received input with shape ' + str(shape))

Created on 2020-01-30 by the reprex package (v0.3.0.9001)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.6.0 (2019-04-26)
#>  os       macOS Mojave 10.14.6        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  ctype    en_US.UTF-8                 
#>  tz       America/New_York            
#>  date     2020-01-30                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                            
#>  ANTsR         0.5.4.2    2019-11-14 [1] local                             
#>  ANTsRCore     0.7.3      2019-12-11 [1] Github (ANTsX/ANTsRCore@416d8f1)  
#>  ANTsRNet    * 1.1        2020-01-30 [1] local                             
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 3.6.0)                    
#>  backports     1.1.5      2019-10-02 [1] CRAN (R 3.6.0)                    
#>  base64enc     0.1-3      2015-07-28 [1] CRAN (R 3.6.0)                    
#>  cli           2.0.1      2020-01-08 [1] CRAN (R 3.6.0)                    
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 3.6.0)                    
#>  digest        0.6.23     2019-11-23 [1] CRAN (R 3.6.0)                    
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 3.6.0)                    
#>  fansi         0.4.1      2020-01-08 [1] CRAN (R 3.6.0)                    
#>  fs            1.3.1      2019-05-06 [1] CRAN (R 3.6.0)                    
#>  generics      0.0.2      2018-11-29 [1] CRAN (R 3.6.0)                    
#>  glue          1.3.1      2019-03-12 [1] CRAN (R 3.6.0)                    
#>  highr         0.8        2019-03-20 [1] CRAN (R 3.6.0)                    
#>  htmltools     0.4.0      2019-10-04 [1] CRAN (R 3.6.0)                    
#>  ITKR          0.5.2      2019-11-05 [1] Github (stnava/ITKR@fe97efa)      
#>  jsonlite      1.6        2018-12-07 [1] CRAN (R 3.6.0)                    
#>  keras       * 2.2.5.0    2019-10-08 [1] CRAN (R 3.6.0)                    
#>  knitr         1.26.1     2020-01-05 [1] Github (muschellij2/knitr@f5af631)
#>  lattice       0.20-38    2018-11-04 [1] CRAN (R 3.6.0)                    
#>  magrittr      1.5        2014-11-22 [1] CRAN (R 3.6.0)                    
#>  Matrix        1.2-17     2019-03-22 [1] CRAN (R 3.6.0)                    
#>  mvtnorm       1.0-11     2019-06-19 [1] CRAN (R 3.6.0)                    
#>  pillar        1.4.3      2019-12-20 [1] CRAN (R 3.6.0)                    
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 3.6.0)                    
#>  purrr         0.3.3      2019-10-18 [1] CRAN (R 3.6.0)                    
#>  R6            2.4.1      2019-11-12 [1] CRAN (R 3.6.0)                    
#>  Rcpp          1.0.3      2019-11-08 [1] CRAN (R 3.6.0)                    
#>  RcppEigen     0.3.3.7.0  2019-11-16 [1] CRAN (R 3.6.0)                    
#>  reprex        0.3.0.9001 2020-01-05 [1] Github (tidyverse/reprex@5ae0b29) 
#>  reticulate    1.13       2019-07-24 [1] CRAN (R 3.6.0)                    
#>  rlang         0.4.2      2019-11-23 [1] CRAN (R 3.6.0)                    
#>  rmarkdown     2.0.7      2020-01-17 [1] Github (rstudio/rmarkdown@2faf16a)
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 3.6.0)                    
#>  stringi       1.4.5      2020-01-11 [1] CRAN (R 3.6.0)                    
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 3.6.0)                    
#>  styler        1.1.1      2019-05-06 [1] CRAN (R 3.6.0)                    
#>  tensorflow    2.0.0      2019-10-02 [1] CRAN (R 3.6.0)                    
#>  tfruns        1.4        2018-08-25 [1] CRAN (R 3.6.0)                    
#>  tibble        2.1.3      2019-06-06 [1] CRAN (R 3.6.0)                    
#>  whisker       0.4        2019-08-28 [1] CRAN (R 3.6.0)                    
#>  withr         2.1.2      2018-03-15 [1] CRAN (R 3.6.0)                    
#>  xfun          0.11       2019-11-12 [1] CRAN (R 3.6.0)                    
#>  yaml          2.2.0      2018-07-25 [1] CRAN (R 3.6.0)                    
#>  zeallot       0.1.0      2018-01-28 [1] CRAN (R 3.6.0)                    
#> 
#> [1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

ANTsRNet/ANTsPyNet approaches to image registration

Hi NIck,

I'm trying to register images of non-brain bodily structures. ANTsR routines work rather well in my hands for this purpose, but not great. So I was wondering if deep learning-based (i.e., written in ANTsRNet/ANTsPyNet) solutions to image registration exist.

I see that others have reported good success using FlowNet/FlowReg architectures implemented on non-ANTsX platforms. Some studies (e.g., Mocanu et al, 2021) even report that variations of FlowReg outperform ANTs. So I figured perhaps you and/or others have come up with ANTsRNet/ANTsPyNet DNNs that outperform FlowReg.

Best,
Jay

3D volume data augmentation demo

Dear author,

Great work for the practical R package of deep learning to medical image tasks. I have used the 3D vgg network function to classify 1000 patients' MRI data into two classes. The performance of training accuracy is quite good, but testing accuracy on average is no more than 80% after tweaking the different regularization techniques including dropout, batch normalization, l2 regularization.

I thought the amount of data may be not enough to get a good performance on testing dataset, so I turned to the data augmentation techniques, based on the ANTsR function of
image. I look at your https://github.com/ntustison/ANTsRNetExamples, but cannot figure out the way, is there any demos here for ANTsR data augmentation interface? Thanks in advance!

ATNsRNet processing error

I installed the latest ATNsR/ANTsRCore/ANTsRNet. (Xubuntu 20.04, Anaconda3, Python 3.10.13)
As a test, I attempted deepAtrpos and I encountered a Tensorflow-related error message shown at the end.

My Python environment has tensorflow package and my R environment also has tensorflow package.
Is there any required tensorflow version or python version?
Are there any matching versions of tensorflow versions between python and R environments?

I am not sure what I should I do further. Any guidance will be appreciated.

Error message that I encountered.

Working on 121-1247...
oro.nifti 0.11.4
Loading required package: ANTsRCore
ANTsR 0.6.0
Environment variables set either in .Renviron or with a seed (e.g. XXX):
Sys.setenv(ANTS_RANDOM_SEED = XXX)
Sys.setenv(ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS = 1)
may influence reproducibility in some methods. See
https://github.com/ANTsX/ANTs/wiki/antsRegistration-reproducibility-issues
for more information.Also see *repro methods in antsRegistration.

Attaching package: ‘ANTsR’

The following objects are masked from ‘package:ANTsRCore’:

antsApplyTransforms, antsApplyTransformsToPoints, antsImageClone,
antsImageHeaderInfo, antsImageIterator, antsImageMutualInformation,
antsImageRead, antsImageWrite, antsMotionCorr, antsRegistration,
cropImage, extractSlice, fastMarchingExtension,
fitBsplineDisplacementField, fitBsplineObjectToScatteredData,
fitThinPlateSplineDisplacementField, fsl2antsrTransform,
imagesToMatrix, integrateVelocityField, invertDisplacementField,
labelStats, makeImage, mergeChannels, reflectionMatrix,
reorientImage, robustMatrixTransform, smoothImage, splitChannels,
weingartenImageCurvature

The following objects are masked from ‘package:oro.nifti’:

origin, origin<-

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

[1] "/mnt/hgfs/Y/schoi/test_ANTs_atropos/deep_Atropos/121-1247"
[1] "File location is :/mnt/hgfs/Y/schoi/test_ANTs_atropos/deep_Atropos/121-1247/"
[1] "/mnt/hgfs/Y/schoi/test_ANTs_atropos/deep_Atropos/121-1247/121-1247_baseline_lesion_filled_T1W.nii.gz"
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 1832911 97.9 3623561 193.6 2446715 130.7
Vcells 2986259 22.8 8388608 64.0 5136416 39.2
2024-04-08 07:04:51.310617: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
Error: Valid installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
/home/xubuntu/anaconda3/envs/py310/bin/python3.10

Python exception encountered:
Traceback (most recent call last):
File "/home/xubuntu/R/x86_64-pc-linux-gnu-library/3.6/reticulate/python/rpytools/loader.py", line 122, in _find_and_load_hook
return _run_hook(name, _hook)
File "/home/xubuntu/R/x86_64-pc-linux-gnu-library/3.6/reticulate/python/rpytools/loader.py", line 96, in _run_hook
module = hook()
File "/home/xubuntu/R/x86_64-pc-linux-gnu-library/3.6/reticulate/python/rpytools/loader.py", line 120, in _hook
return find_and_load(name, import)
File "/home/xubuntu/anaconda3/envs/py310/lib/python3.10/site-packages/tensorflow/init.py", line 37, in
from tensorflow.python.tools import module_util as _module_util
File "/home/xubuntu/R/x86_64-pc-linux-gnu-library/3.6/reticulate/python/rpytools/loader.py", line 122, in _find_and_load_hook
re
Execution halted

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.