ANTsX / ANTsRCore

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

Can't read MATLAB Transform #81

Closed muschellij2 closed 1 month ago

muschellij2 commented 5 years ago

Couldn't read MATLAB transform with current ITKR/ANTsRCore build (installed using devtools::install_github):

tx = readAntsrTransform("matlab.mat")
ITK ExceptionObject caught !

itk::ExceptionObject (0x4abff30)
Location: "unknown" 
File: /tmp/RtmpEcopSb/R.INSTALL66f5549c74ac/ITKR/src/itks/Modules/IO/TransformBase/src/itkTransformFileReader.cxx
Line: 144
Description: itk::ERROR: TransformFileReaderTemplate(0x4abb460): Transform IO: MatlabTransformIOTemplate
   failed to read file: matlab.mat

terminate called after throwing an instance of 'Rcpp::exception'
  what():  ITK exception caught
sessioninfo::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value                                                 
 version  R version 3.5.3 Patched (2019-03-11 r76311)           
 os       Red Hat Enterprise Linux Server release 6.9 (Santiago)
 system   x86_64, linux-gnu                                     
 ui       X11                                                   
 language (EN)                                                  
 collate  en_US.UTF-8                                           
 ctype    en_US.UTF-8                                           
 tz       US/Eastern                                            
 date     2019-04-17                                            

─ Packages ───────────────────────────────────────────────────────────────────
 package     * version   date       lib source                            
 ANTsR       * 0.4.8     2019-03-15 [1] Github (ANTsX/ANTsR@9ebcc2c)      
 ANTsRCore   * 0.6.3.2   2019-03-15 [1] Github (ANTsX/ANTsRCore@8ad70dd)  
 assertthat    0.2.1     2019-03-21 [2] CRAN (R 3.5.1)                    
 cli           1.1.0     2019-03-19 [2] CRAN (R 3.5.1)                    
 colormap      0.1.4     2016-11-15 [1] CRAN (R 3.5.1)                    
 colorout    * 1.2-0     2018-05-10 [1] Github (jalvesaq/colorout@c42088d)
 crayon        1.3.4     2017-09-16 [2] CRAN (R 3.5.0)                    
 curl          3.3       2019-01-10 [2] CRAN (R 3.5.1)                    
 ITKR          0.4.19    2019-03-15 [1] Github (stnava/ITKR@26962af)      
 jsonlite      1.6       2018-12-07 [2] CRAN (R 3.5.1)                    
 lattice       0.20-38   2018-11-04 [3] CRAN (R 3.5.3)                    
 magrittr      1.5       2014-11-22 [2] CRAN (R 3.5.0)                    
 Matrix        1.2-15    2018-11-01 [3] CRAN (R 3.5.3)                    
 Rcpp          1.0.1     2019-03-17 [1] CRAN (R 3.5.1)                    
 RcppEigen     0.3.3.5.0 2018-11-24 [2] CRAN (R 3.5.1)                    
 sessioninfo   1.1.1     2018-11-05 [2] CRAN (R 3.5.1)                    
 V8            2.0       2019-02-07 [1] CRAN (R 3.5.1)                    
 withr         2.1.2     2018-03-15 [2] CRAN (R 3.5.0)                    

Tried locally on OSX machine (also installed using devtools::install_github)

tx = readAntsrTransform("matlab.mat")
ITK ExceptionObject caught !

itk::ExceptionObject (0x7f7ffda00240)
Location: "unknown" 
File: /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpgjAHcE/R.INSTALL101940f742b3/ITKR/src/itks/Modules/IO/TransformBase/src/itkTransformFileReader.cxx
Line: 144
Description: itk::ERROR: TransformFileReaderTemplate(0x7f7ffd9fa860): Transform IO: MatlabTransformIOTemplate
   failed to read file: matlab.mat

libc++abi.dylib: terminating with uncaught exception of type Rcpp::exception: ITK exception caught
Abort trap: 6

matlab.mat.gz

stnava commented 5 years ago

R.matlab says:

> readMat( "/mnt/c/Users/bavants/Downloads/matlab.mat")
Error in readMat5(con, firstFourBytes = firstFourBytes, maxLength = maxLength) :
  Reading of MAT v7.3 files is not supported. If possible, save the data in MATLAB using 'save -V6'.

probably the same thing here but with a much worse message. reading a .mat written by ANTsR seems to work still.

muschellij2 commented 5 years ago

Fails also with MAT version 6.0 files from MATLAB mv6.mat.gz :

R.matlab::readMat works

library(R.matlab)
#> R.matlab v3.6.2 (2018-09-26) successfully loaded. See ?R.matlab for help.
#> 
#> Attaching package: 'R.matlab'
#> The following objects are masked from 'package:base':
#> 
#>     getOption, isOpen
v = readMat("mv6.mat")
v$regcorr.chain[,,1:3]
#> , , 1
#> 
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    0    1    0
#> [3,]    0    0    1
#> 
#> , , 2
#> 
#>              [,1]        [,2] [,3]
#> [1,]  1.000000000  0.00000000    0
#> [2,]  0.000000000  1.00000000    0
#> [3,] -0.005032132 -0.01083869    1
#> 
#> , , 3
#> 
#>             [,1]       [,2] [,3]
#> [1,] 1.000000000 0.00000000    0
#> [2,] 0.000000000 1.00000000    0
#> [3,] 0.009389645 0.01300057    1

Created on 2019-04-17 by the reprex package (v0.2.1)

ANTsRCore fails

library(ANTsRCore)
Attaching package: ‘ANTsRCore’

The following object is masked from ‘package:stats’:

    var

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

    all, any, apply, max, min, prod, range, sum
readAntsrTransform("mv6.mat")

ITK ExceptionObject caught !

itk::ExceptionObject (0x7fab37061a20) Location: "unknown" File: /private/var/folders/1s/wrtqcpxn685_zk570bnx9_rr0000gr/T/RtmpgjAHcE/R.INSTALL101940f742b3/ITKR/src/itks/Modules/IO/TransformBase/src/itkTransformFileReader.cxx Line: 144 Description: itk::ERROR: TransformFileReaderTemplate(0x7fab372b0a90): Transform IO: MatlabTransformIOTemplate failed to read file: mv6.mat

libc++abi.dylib: terminating with uncaught exception of type Rcpp::exception: ITK exception caught Abort trap: 6

stnava commented 5 years ago

i dont think this is a proper transform file. at least not according to antsr/ants .... how was it created?

muschellij2 commented 5 years ago

It's not one from ANTsR. I'm saying that ITK has a read function for MATLAB mat files that I thought ANTsR used to be able to read but the linking doesn't seem to work now. John

On Wed, Apr 17, 2019 at 3:47 PM stnava notifications@github.com wrote:

i dont think this is a proper transform file. at least not according to antsr/ants .... how was it created?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTsRCore/issues/81#issuecomment-484234777, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIGPLVJ2SLQKZHCFCFX533PQ55EXANCNFSM4HGWTWEQ .

stnava commented 5 years ago

Ok: maybe test to see if old versions work?

On Wed, Apr 17, 2019 at 4:02 PM John Muschelli notifications@github.com wrote:

It's not one from ANTsR. I'm saying that ITK has a read function for MATLAB mat files that I thought ANTsR used to be able to read but the linking doesn't seem to work now. John

On Wed, Apr 17, 2019 at 3:47 PM stnava notifications@github.com wrote:

i dont think this is a proper transform file. at least not according to antsr/ants .... how was it created?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTsRCore/issues/81#issuecomment-484234777, or mute the thread < https://github.com/notifications/unsubscribe-auth/AAIGPLVJ2SLQKZHCFCFX533PQ55EXANCNFSM4HGWTWEQ

.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTsRCore/issues/81#issuecomment-484239603, or mute the thread https://github.com/notifications/unsubscribe-auth/AATyfmByopJ6WPZ_ETuFUbFv5iUYmMbSks5vh329gaJpZM4c1p2J .

--

brian