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

"mat2file.c not compiled" when running SPM12 realign and reslice in an Octave-kernel Jupyter notebook #1

Closed
jsheunis opened this issue Apr 11, 2020 · 11 comments

Comments

@jsheunis
Copy link

Hi @gllmflndn

I'm trying out SPM12 with Octave on Binder (see repository here). I've set up a Jupyter notebook environment with an Octave kernel basically like you have done here (thanks!).

Now I've started testing some SPM12 processing steps and I'm getting an error when trying to run realign and reslice with a batch script:

11-Apr-2020 12:46:14 - Failed  'Realign: Estimate & Reslice'
mat2file.c not compiled - see Makefile
In file "/home/jovyan/spm12/@file_array/private/mat2file.m" (v7147), function "mat2file" at line 16.
In file "/home/jovyan/spm12/@file_array/subsasgn.m" (v7147), function "subsasgn>subfun" at line 164.
In file "/home/jovyan/spm12/@file_array/subsasgn.m" (v7147), function "subsasgn" at line 85.
In file "/home/jovyan/spm12/spm_write_plane.m" (v6079), function "spm_write_plane" at line 31.
In file "/home/jovyan/spm12/spm_write_vol.m" (v5731), function "spm_write_vol" at line 84.
In file "/home/jovyan/spm12/spm_reslice.m" (v7141), function "spm_reslice>reslice_images" at line 248.
In file "/home/jovyan/spm12/spm_reslice.m" (v7141), function "spm_reslice" at line 136.
In file "/home/jovyan/spm12/config/spm_run_realign.m" (v7141), function "spm_run_realign" at line 44.

I've browsed some mailing list questions and it looks like this was previously solved by reinstalling SPM12, although I suspect most of these issues were on standalone desktops.

I'm guessing this line in the postBuild file is supposed to install everything correctly?

Do you have an idea if this issue could be Binder-related, or perhaps a suggestion of what else I could try?

Best, Stephan

@gllmflndn
Copy link
Contributor

Hi @jsheunis !

This is due to a bug in Octave that was fixed two years ago: https://savannah.gnu.org/bugs/?53856

So best would be to use a more recent version of Octave (5.2.0 instead of old 4.2.2) but there might be some restrictions about what is currently available from Binder - or use a Dockerfile but it seems to be recommended against.

Otherwise, a temporary fix could be to remove all mat2file.* apart from mat2file.mex?

@jsheunis
Copy link
Author

Thanks for the quick and useful reply! I will investigate these and update here with what works.

@jsheunis
Copy link
Author

Update:

Option 1 - use a recent version of Octave

I looked into this and didn't get it to work. I found that a related issue on the Binder examples repo. I commented on that issue detailing what I tried, basically putting the version number in the apt.txt file, e.g. octave=4.4.0. I'm hoping something comes out of that discussion.

Option 2 - using a Dockerfile

I haven't tried this yet. Will look at it as a last resort.

Option 3 - deleting all mat2file.* files except for mat2file.mex

This doesn't seem to work. I get the following error at the same point as the previous error:

no such file, '/home/jovyan/spm12/@file_array/private/mat2file.m'

From reading a bit it looks like, in Matlab, .mex files are called preferentially if a .m file with the same name exists? Is this true for Octave as well?

I also tried deleting all other mat2file.mex* files (e.g. .mexa64, .mexw32, .mexmaci64, etc) except for the single mat2file.mex file, and this still yielded the same error. Seems like Octave does not know the .mex file exists?

One of the files I'm deleting is mat2file.o, and when I try to open it in Binder it give this error:

Error! /home/jovyan/spm12/@file_array/private/mat2file.o is not UTF-8 encoded
Saving disabled.
See Console for more details.

Is this file necessary? I tried both deleting and keeping it before running my processing script, but both times yielded the same error as above.

@gllmflndn
Copy link
Contributor

Thank you @jsheunis - I would also want to use Binder for some SPM tutorials at some point so this is particularly useful.

Option 1
It seems that Binder is built on top of Ubuntu 18.04.3 LTS (Bionic Beaver) where only Octave 4.2.2 is available:
https://packages.ubuntu.com/search?keywords=octave
Ubuntu 20.04 LTS (Focal Fossa) will soon be released and comes with Octave 5.2.0:
https://packages.ubuntu.com/focal/octave
This is what I already use for spm-docker.
It would be useful to get some feedback from the Binder project about their plan in updating Ubuntu versions.

Option 2
Yes, probably not the priority.

Option 3
The *.mex file is meant to have precedence but there was a bug in Octave with private directories where this was not implemented properly. So the workaround here is to delete all files with the same basename (apart from *.mex) so that they don't take precedence accidentally. You should delete them in the postBuild script and not from within an Octave instance.

@jsheunis
Copy link
Author

Thanks! Deleting the extra mat2file files during postBuild instead of from within the octave instance did the trick. See here (there are probably smarter ways of accomplishing this).

My whole notebook now runs without errors. I'm now working on ways to view useful plot/figure outputs inline. At the moment, as suspected, not much of the output displays inline.

Also, thanks for filling in the blanks about the Ubuntu and Octave versions and compatibility / availability.

@gllmflndn
Copy link
Contributor

Great! There are other *.mex files in private directories so you might have to apply the same principle to these files if errors occur. Hopefully this is only temporary, until Ubuntu 20.04 and Octave 5.2 (or 6.1) is available from Binder.

If you find more info about how to improve the display of inline outputs and create widgets, let me know.

For now I am going to close this issue but keep me in the loop of what you come up with!

@jsheunis
Copy link
Author

@gllmflndn I just published a blog post with a step-by-step guide on how to set up a repo to do Reproducible fMRI analysis with SPM12, Octave, Jupyter and Binder. Thanks for your help!

@gllmflndn
Copy link
Contributor

Thanks @jsheunis, nice one! I will add a link to your tutorial in the spm-notebooks repository. To give credit where credit's due, all I know about Binder comes from @KirstieJane and colleagues after attending a "Boost your research reproducibility with Binder" workshop at the Turing Institute last year.

@Remi-Gau
Copy link

Remi-Gau commented Nov 1, 2020

FYI @gllmflndn and @jsheunis

Just saw that you solved this already but if you have any idea on a clean way to solve this issue when running locally.

@gllmflndn
Copy link
Contributor

I think the only clean way is to use the latest stable release of Octave, as the bug encountered here has been fixed two and a half years ago. As you noticed, a workaround for older Octave versions is to delete all but *.mex for MEX files.

@Remi-Gau
Copy link

Remi-Gau commented Nov 2, 2020

Noted: will check which octave version ships with my Ubuntu version. I know I can use a more recent version of Octave with Snap but the default one on my system is still 4.2.

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

3 participants