NMatrix::IO::MATLAB, parsing doubles #23

Closed
tdy opened this Issue Oct 29, 2012 · 4 comments

Projects

None yet

2 participants

@tdy
tdy commented Oct 29, 2012

Hi, I tried loading some of my mat data like this:

require "nmatrix"
NMatrix::IO::Matlab::load_mat("r03_12_1.mat")

I was getting some strange values back, so I used some dummy data just for testing purposes. It seems that everything is fine as long as the original data only have integers, but as soon as any doubles are introduced, I get weird results.

For example, #load_mat is showing -1.5423487136706484e-180, but in MATLAB it's 1.1. Not sure if something is buggy or if I'm just missing something obvious.

Original data were from:

  • 64-bit Win7
  • MATLAB R2012a

Trying to parse the data on:

  • 64-bit Arch Linux
  • ruby 1.9.3-p286 rev 37165
  • nmatrix 0.0.2

Thanks!

@mohawkjohn
Member

Couple questions: is this a sparse or dense matrix you're trying to load?
And could you send a copy of the .mat file?

Many thanks!

On Monday, October 29, 2012, tdy wrote:

Hi, I tried loading some of my mat data like this:

require "nmatrix"
NMatrix::IO::Matlab::load_mat("r03_12_1.mat")

I was getting some strange values back, so I used some dummy data just for
testing purposes. It seems that everything is fine as long as the original
data only have integers, but as soon as any doubles are introduced, I get
weird results.

For example, 1.1 in MATLAB is coming out as -1.5423487136706484e-180after
#load_mat. Not sure if something is buggy or if I'm just missing
something obvious.

Original data were from:

  • 64-bit Win7
  • MATLAB R2012a

Trying to parse the data on:

  • 64-bit Arch Linux
  • ruby 1.9.3p286 rev 37165
  • nmatrix 0.0.2

Thanks!


Reply to this email directly or view it on GitHubhttps://github.com/SciRuby/sciruby/issues/23.

@tdy
tdy commented Oct 30, 2012

I had previously only tried dense matrices, but I just tried some sparse matrices. I only attached the simple test cases here because the real data are patient protected. I can throw together some fake data that are closer in form to what I’ll actually be using if it would help.

In MATLAB:

x = [1 2;3 4]; % saved as x.mat (attached)
y = [1.1 2;3 4]; % saved as y.mat (attached)
x_sparse = sparse(x); % saved as x_sparse.mat (attached)
y_sparse = sparse(y); % saved as y_sparse.mat (attached)

In MRI:

pry(main)> NMatrix::IO::Matlab::load_mat(“x.mat”)
=> [1, 2] [3, 4]

pry(main)> NMatrix::IO::Matlab::load_mat(“y.mat”)
=> [-1.5423487136706484e-180, 3.16e-322] [1.0435e-320, 2.0553e-320]

pry(main)> NMatrix::IO::Matlab::load_mat(“x_sparse.mat”)
indices: Requesting itype :uint8
No repack
=> [1.0, 3.0] [2.0, 4.0]

pry(main)> NMatrix::IO::Matlab::load_mat(“y_sparse.mat”)
indices: Requesting itype :uint8
No repack
=> [1.1, 3.0] [2.0, 4.0]

@mohawkjohn
Member

Yes, if you could attach some fake data where the same bug pops up, that would be great. I don't have easy access to MATLAB.

Incidentally, here would be the more appropriate place: SciRuby/nmatrix#48

@mohawkjohn mohawkjohn closed this Oct 30, 2012
@mohawkjohn
Member

By the way, I see that you indicated attachments, but I think they were stripped. Can you please email to john.woods at marcottelab dot org?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment