Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Can't read MATLAB Transform #81

Open
muschellij2 opened this issue Apr 17, 2019 · 5 comments
Open

Can't read MATLAB Transform #81

muschellij2 opened this issue Apr 17, 2019 · 5 comments

Comments

@muschellij2
Copy link
Collaborator

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
Copy link
Member

stnava commented Apr 17, 2019

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
Copy link
Collaborator Author

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
Copy link
Member

stnava commented Apr 17, 2019

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

@muschellij2
Copy link
Collaborator Author

muschellij2 commented Apr 17, 2019 via email

@stnava
Copy link
Member

stnava commented Apr 17, 2019 via email

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

No branches or pull requests

2 participants