bids-apps / SPM

BIDS App containing an instance of the SPM software.
https://hub.docker.com/r/bids/spm/tags
Apache License 2.0
14 stars 12 forks source link

FIX: copyfile()/symlinks on Linux, Matlab < R2020a #22

Open octomike opened 4 years ago

octomike commented 4 years ago

I tried running the SPM container on ds000001 which I pulled with datalad. It turns out that datalad is using symbolic links for the images in anat/ and func/ etc pointing to a .git-annex folder two levels above.

Unfortunately, copyfile() on Linux with Matlab <= 2019b does not dereference the file and when SPM is copying a relative symlink to the tmp/output folder, the link breaks.

This PR is checking if we are on Linux on Matlab < 2020a (with an ugly versioncmp hack) and uses system('cp -rL...') instead of copyfile().

Also, as I mention in the comment, it would probably be much nicer to keep the symbolic links for all platforms, but I'm having a hard time coming up with a portable solution for that. And I'm also not entirely sure this is compatible with SPM's behavior (would it modify source files in that case?)

gllmflndn commented 4 years ago

There is now a function spm_copy that could be used in spm_BIDS_App.m. The issue with symbolic links could then be dealt with there (spm_check_version might come handy) or we could just switch to the MATLAB Runtime R2020a as you mention. It seems safer to make hard copies as sources could be modified.

octomike commented 4 years ago

Okay, cool. So should I just revert the changes and change copyfile() to spm_copy() and leave this here until spm_copy is updated?

gllmflndn commented 4 years ago

Yes, spm_copy is just a wrapper around copyfile but it will also uncompress and move sidecar .json files as well. I will look building a new SPM12 standalone with R2020a that we could use here.