Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.

Pages: [1]
Author Topic: Mex files not defined
Posts: 5
Post Mex files not defined
on: October 16, 2013, 12:56

Hi Stefano,

I think I have managed to get the installation working, but perhaps not. When trying to run the demos, none of the functions appended by '_mex' are defined. Was there something missing in the installation here or can this be bypassed?

For your information, I installed on Windows using the binary self-installer, without CUDA.

Thanks a lot,

Posts: 22
Post Re: Mex files not defined
on: October 16, 2013, 13:22

Hi Paul,

Very likely the problem is that the binary installer of NiftyRec is for Windows 32 bit, while your Windows installation is 64 bit. Keep reading to figure it out.

Matlab functions can be defined in two ways: as an .m file, containing matlab code, or as a mex file. The mex file is nothing but a dynamic library (.dll) renamed right after compilation with the extension .mex32 (that is under Windows 32; Matlab by convention uses different extension names in different operating systems, e.g. .mexa64 under Linux 64 bit). To cut short, such library exposes an interface that lets Matlab recognise it as an extension and make use of it.
When you invoke a function with name foo, Matlab looks for foo.m and, if it doesn't find it, for foo.mex32 (assuming Windows 32 bit).
Therefore when you invoke a function Matlab, under the hood, may execute the code contained in .m file or is a mex file, without you knowing.
As a naming convention, NiftyRec appends '_mex' to all the mex extensions, so that you recognise them in the Matlab workspace.
All the functions of the NiftyRec Matlab toolkit API are .m files, however many of them are wrappers of a corresponding mex file whose name is obtained by appending '_mex'. Edit for example et_project.m and you will see that there are only a few lines of code; these check the input parameters and then call et_project_mex.

When you type et_project(..) then Matlab launches et_project.m and subsequently the mex file et_project_mex.mex32.
The mex file, in order to be found, just like any other library, has to be in the current working directory or in the system path.
The .m files and the mex files of NiftyRec are all in the same folder. Since in your case Matlab can find the .m files, I guess that it does not find the mex files because they have the wrong extension for your operating system (e.g. mismatching architecture 64 vs 32 bit).

I am looking to automate the building of NiftyRec on a few platforms, in the meantime the solution is to compile NiftyRec from source. See the instructions on the Wiki.

I hope this helps,


Posts: 1
Post Re: Mex files not defined
on: December 5, 2013, 06:32

Hi Stefano,
I think I came across the same problem as Paul. I did compile NiftyRec from source. I used cmake and then VS to install. Everything seemed to be fine until I tried to run a demo in matlab. The error is:

??? Undefined command/function 'et_project_mex'.

Error in ==> et_project at 91
sinogram = et_project_mex(activity, cameras, attenuation, psf, use_gpu, background, background_attenuation, truncate_negative_values);

Error in ==> et_demo_osem at 56
ideal_sinogram = et_project(phantom, cameras, attenuation, psf, GPU);

I did what the user guide instructed. I added the lib folder in the system directory and added niftyrec into matlab folder. I can see the et_project_mex file in the work directory but not sure why it cannot find it. Could you help me with that?


Posts: 3
Post Re: Mex files not defined
on: June 1, 2016, 18:32

hi Nancy, did you solve this problem?

Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.083 seconds.
{lang: 'en-GB'}