Unable to symbolically link wmfod and mask images to template directory

Hi Mrtrix3 experts,

I’m currently creating a population template following the steps in Fibre density and cross-section - Multi-tissue CSD. However, when I try to link my wmfod_norm.mif and dwi_mask_upsampled.mif images into a single input folder via:

foreach * : ln -sr IN/wmfod_norm.mif ../template/fod_input/PRE.mif

I get the following error message:

ln: illegal option -- r
usage: ln [-Ffhinsv] source_file [target_file]
       ln [-Ffhinsv] source_file ... target_dir
       link source_file target_file

Is there anything that I might have missed or have done incorrectly?
Many thanks in advance for your help :grinning:

Mervyn Singh

Hi Mervyn!

Looks like this might relate to the version of ln you’re using. Are you on a mac? If so, does this help:

:question:

Cheers,
Thijs

Hi Thijs!

Thanks for your reply! Yes, I’m currently working on a Mac (macOS Mojave Ver. 10.14.6). I just tried brew install coreutils but unfortunately I’m still running into the same error messages when I run the command to link the images and masks.

Many Thanks,
Mervyn

Strange! I’m not a Mac user myself, so this was more or less just a guess. That said, it looks like something that has come up elsewhere before though, and it was always recommended to install coreutils to bring in a version of ln that does support the -r option. Not sure if these things require a restart or other steps to make them available on a Mac though…

…aha, literally seconds after I posted, I came across this one: https://apple.stackexchange.com/questions/69223/how-to-replace-mac-os-x-utilities-with-gnu-core-utilities

Main point being (from that page):

All commands have been installed with the prefix 'g'.

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

So basically, you should now have a gln, if I interpret that correctly. Alternatively, you can follow those instructions to add versions without a g prefix to your path.

Hope that makes sense!

1 Like

Hi Thijs,

No problems at all, I’m not usually a Mac user myself, having just swapped over recently, so I’m learning the ins and outs of the macOS command line environment as I go through the MRtrix3 pipeline.

The above instructions worked perfectly! That was an excellent resource you have found! :smile: I basically followed what was recommended on the website (i.e. creating a path to by bashrc using PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH").

Once that was set, I was able to symbolically link all .mif files to the template directory.

Many thanks for your assistance here, it was much appreciated! :grinning:

Mervyn

1 Like