general-discussion > Error using niak in Matlab
Showing 1-8 of 8 posts
Display:
Results per page:
Jan 8, 2015  01:01 AM | Carina Jensen
Error using niak in Matlab
Hi everyone,
 
I'm trying to load some minc files into matlab 2014b on ubuntu14.04. I'm getting the following errror:
 
Error using niak_read_hdr_minc (line 97)
Error:read: Could not parse the minc header !
 
Error in niak_read_minc (line 66)
hdr = niak_read_hdr_minc(file_name);
 
Errir in LoadProstateData (line 16)
[HDR,T2WIIMG] = niak_read_minc(strcat(directory_mnc,im_T2WI));
 
I had the same error the first time I tried to load these images and somehow I got it working. This time I can't get it to work. I added niak (and subfolders) to the matlab path. I'm pretty new to ubuntu, niak and minc so it could possible a simple mistake I made :)
Any suggestions?
 
Thanks
Jan 8, 2015  07:01 AM | Pierre Bellec
RE: Error using niak in Matlab
Dear Carina,
 
I'm trying to load some minc files into matlab 2014b on ubuntu14.04. I'm getting the following errror:
 
Error using niak_read_hdr_minc (line 97)
Error:read: Could not parse the minc header !
 
Error in niak_read_minc (line 66)
hdr = niak_read_hdr_minc(file_name);
 
Errir in LoadProstateData (line 16)
[HDR,T2WIIMG] = niak_read_minc(strcat(directory_mnc,im_T2WI))
So, NIAK is using the minctools to access the image, and this is somehow breaking. The error message is not very explicit. Please try the following. In matlab, type:

system('mincinfo -version')

and let me know what it says. It is just to check that the minc tools are properly installed, and accessible through matlab. 

Also, open a terminal and

cd directory_mnc
mincinfo im_T2WI

where directory_mnc is the directory with your minc file, and im_T2WI is the name of the minc file. This is to check that the minc tools are accessible through the terminal, and that the minc volume is correct, at least superficially. 
 
I had the same error the first time I tried to load these images and somehow I got it working. This time I can't get it to work. I added niak (and subfolders) to the matlab path. I'm pretty new to ubuntu, niak and minc so it could possible a simple mistake I made :)

Not a problem, we'll figure it out, and welcome to the community :)

Best,

Pierre
Jan 8, 2015  10:01 PM | Carina Jensen
RE: Error using niak in Matlab
Hi Pierre,
 
Thank you for helping.
When it type system('mincinfo -version') in matlab i get the following output:
mincinfo: sysbol lookup error: /usr/lib/x86_64-linux-gnu/libminc2.so.3: undefined symbol: ncerr
 
ans =
127
- so I guess you're right that matlab can access minc..
 
In a terminal I get the imageinfo when typing mincinfo on an mnc image.
 
So how do I get matlab to access minc tools? I don't understand how it could work last week and not now :)
 
Thanks again.
 
Carina
Jan 9, 2015  06:01 AM | Pierre Bellec
RE: Error using niak in Matlab
Dear Carina,


I think I know what your problem is, it already surfaced years ago:
http://www.bic.mni.mcgill.ca/pipermail/m...

In summary the cause of the problem is that you are using a minc install based on dynamic libraries (.so). Matlab's installation on linux is not clean, and overwrites some libraries of the system, i.e. it forces any tools called from matlab to use a different version of the libraries than the default. These alternative libraries sometimes break minc. Why this issue appeared out of nowhere for you one week ago is unclear, but it very likely has to do with some software update. 

There are several work-arounds, but the cleanest is to have minc installed with:
http://www.bic.mni.mcgill.ca/ServicesSof...

These packages rely (as far as I know) on static libraries, and should work around the issue you are facing. They are also very easy to install (at least in my experience on ubuntu). Please let me know if that is an option for you and, if it is, if this solved your problem. If not, we have other (dirtier) work arounds. 

Best,

Pierre

Originally posted by Carina Jensen:
Hi Pierre,
 
Thank you for helping.
When it type system('mincinfo -version') in matlab i get the following output:
mincinfo: sysbol lookup error: /usr/lib/x86_64-linux-gnu/libminc2.so.3: undefined symbol: ncerr
 
ans =
127
- so I guess you're right that matlab can access minc..
 
In a terminal I get the imageinfo when typing mincinfo on an mnc image.
 
So how do I get matlab to access minc tools? I don't understand how it could work last week and not now :)
 
Thanks again.
 
Carina
Jan 11, 2015  11:01 PM | Carina Jensen
RE: Error using niak in Matlab
Hi Pierre,
 
I can't open the first link you posted. But the minc installation you suggested is what I already have installed I think. I installed minc-toolkit.1.9.3. It suddenly worked again on friday and now monday it's not working again! Very annoying. Do you have any other suggestions that I can try? What worked friday - as far as I know was to type /opt/minc/minc-toolkit-config.sh in a terminal. But that didn't work this morning.
 
BR, Carina
Jan 12, 2015  08:01 PM | Pierre Bellec
RE: Error using niak in Matlab
Dear Carina,

As of the broken link here we go
http://www.bic.mni.mcgill.ca/pipermail/m...
Hoping this one will work, nitrc has done some wild truncation on my links in the past (in case it's still broken, add the l at the end of htm.

OK this bug is extremely weird indeed. Let's try something agressive. 

Do this in a terminal:
$ ldd /usr/local/bic/bin/mincinfo
linux-gate.so.1 => (0xb7ee8000)
libhdf5-1.6.5.so.0 => /usr/lib/libhdf5-1.6.5.so.0 (0xb7daa000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.

That tells you which netcdf and hdf5 you are using by default (when minc works). Now do the same in a matlab prompt, with a system call:
>>> system('ldd /usr/local/bic/bin/mincinfo')
linux-gate.so.1 => (0xb7f51000)
libhdf5-1.6.5.so.0 => /usr/lib/libhdf5-1.6.5.so.0 (0xb7e13000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7dfa000)
libz.so.1 => /usr/lib/libz.so.1 (0xb7de5000)
*libnetcdf.so.4 => /usr/local/matlabR2009b/bin/**glnx86/libnetcdf.so.4
(0xb7da9000)*
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7d84000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7c35000)
/lib/ld-linux.so.2 (0xb7f52000)

In this example, Matlab has ruthlessly redirected the netcdf libraries. Just copy the .so file under a new name, like libnetcdf.so.4.original, and then replace it with the default library (or a link to the default library). That's a dirty hack, but let's hope it will (consistently) solve your problem. Let me know how it goes. 

Best,

Pierre
Jan 12, 2015  11:01 PM | Carina Jensen
RE: Error using niak in Matlab
>> system('ldd /opt/minc/bin/mincinfo')
linux-vdso.so.1 => (0x00007fff1a9fe000)
libminc2.so.3.0.0 => /opt/minc/lib/libminc2.so.3.0.0 (0x00007fcef9434000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcef9055000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcef8d4f000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fcef8b4b000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcef9a59000)Hi Pierre,

Output from terminal:
carina@carina-X200MA:~$ ldd /opt/minc/bin/mincinfo
linux-vdso.so.1 => (0x00007fffb16c3000)
libminc2.so.3.0.0 => /opt/minc/lib/libminc2.so.3.0.0 (0x00007f839912a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f8398d4c000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f8398a45000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f8398841000)
/lib64/ld-linux-x86-64.so.2 (0x00007f839974f000)

Output from matlab:
>> system('ldd /opt/minc/bin/mincinfo')
linux-vdso.so.1 => (0x00007fff1a9fe000)
libminc2.so.3.0.0 => /opt/minc/lib/libminc2.so.3.0.0 (0x00007fcef9434000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcef9055000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcef8d4f000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fcef8b4b000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcef9a59000)

In my outputs I don't see anything about netcdf or hdf5 and today I have no problems loading images into matlab using niak/minc .In your reply you wrote the mincinfo path to be in /usr/local/bin/ is it a problem that my mincinfo file is in /opt/minc/bin ???

BR Carina.
Jan 12, 2015  11:01 PM | Carina Jensen
RE: Error using niak in Matlab
Now suddenly it stopped working again and now my output is totally different for matlab:

>> system('ldd /opt/minc/bin/mincinfo')
linux-vdso.so.1 => (0x00007fff799fe000)
libminc2.so.3.0.0 => /usr/lib/x86_64-linux-gnu/libminc2.so.3.0.0 (0x00007f0008f33000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0008b6c000)
libhdf5.so.7 => /usr/lib/x86_64-linux-gnu/libhdf5.so.7 (0x00007f00086d0000)
libnetcdf.so.7 => /home/carina/bin/glnxa64/libnetcdf.so.7 (0x00007f000838d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0008086000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0009181000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0007e68000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0007c4f000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0007a4a000)
libhdf5_hl.so.6 => /home/carina/bin/glnxa64/libhdf5_hl.so.6 (0x00007f000781d000)
libhdf5.so.6 => /home/carina/bin/glnxa64/libhdf5.so.6 (0x00007f000739e000)
libcurl.so.4 => /home/carina/bin/glnxa64/libcurl.so.4 (0x00007f0007157000)