MRIQC Docker to MRIQC Singularity

409 views
Skip to first unread message

ben...@umich.edu

unread,
Oct 1, 2017, 9:20:41 AM10/1/17
to mriqc-users
I converted the MRIQC Docker container to a Singularity container.

I download the OpenfMRI.org dataset d008, which is in BIDS format.  The uncompressed,
top-level directory of the data looks like

$ ls ds008_R2.0.0/
CHANGES                   sub-02  sub-07  sub-13
dataset_description.json  sub-03  sub-09  sub-14
participants.tsv          sub-04  sub-10  sub-15
README                    sub-05  sub-11  task-conditionalstopsignal_bold.json
sub-01                    sub-06  sub-12  task-stopsignal_bold.json


I read at http://mriqc.readthedocs.io/en/stable/docker.html that to run Docker, I would use

$ docker run -it --rm -v <bids_dir>:/data:ro -v <output_dir>:/out \
poldracklab/mriqc:latest /data /out group

I am presuming that the -v option translates to -B for Singularity, and maps a folder on the
host to a folder in the container, so I should have something like

$ singularity exec -B $HOME/bids:/data:ro -B $HOME/out:/out \
mriqc.simg mrqc <mriqs arguments>


However, it seems that the permissions inside the container are set so that an uprivileged user
cannot run mriqc.

This is output from a run with an uprivileged user:

$ singularity exec -B /home/bennet/Projects/mpeckins/MRIQC/ds008_R2.0.0:/data:ro -B $PWD/out:/out \
mriqc.simg mriqc --help
Traceback (most recent call last):
File "/usr/local/miniconda/bin/mriqc", line 6, in <module>
from pkg_resources import load_entry_point
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
[ .... elided for brevity ... ]
File "/usr/local/miniconda/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg/pkg_resources/__init__.py", line 1861, in get_metadata
PermissionError: [Errno 13] Permission denied: '/usr/local/miniconda/lib/python3.6/site-packages/.wh.conda-4.3.11-py3.6.egg-info'

$ singularity exec -B /home/bennet/Projects/mpeckins/MRIQC/ds008_R2.0.0:/data:ro -B $PWD/out:/out \
mriqc.simg ls -l /usr/local/miniconda/lib/python3.6/site-packages/.wh.conda-4.3.11-py3.6.egg-info
-rw------- 1 root root 0 Aug 30 04:23 /usr/local/miniconda/lib/python3.6/site-packages/.wh.conda-4.3.11-py3.6.egg-info


and output running with sudo:

$ sudo singularity exec -B /home/bennet/Projects/mpeckins/MRIQC/ds008_R2.0.0:/data:ro -B $PWD/out:/out \
mriqc.simg mriqc --help

usage: mriqc [-h] [--version]
[--participant_label PARTICIPANT_LABEL [PARTICIPANT_LABEL ...]]
[--session-id SESSION_ID [SESSION_ID ...]]
[--run-id RUN_ID [RUN_ID ...]] [--task-id TASK_ID [TASK_ID ...]]
[ ... elided for brevity ... ]

Is this something I should solve on my own, or is this something I should report as an issue at https://github.com/poldracklab/mriqc/?

Even as root, it seems to be having minor indigestion:

$ sudo singularity exec -B /home/bennet/Projects/mpeckins/MRIQC/ds008_R2.0.0:/data:ro -B $PWD/out:/out mriqc.simg \
 mriqc /data /out participant --participant_label sub-15
2017-10-01 13:11:20,245 interface:WARNING AFNI is outdated, detected version Debian-16.2.07~dfsg.1-5~nd16.04+1 and AFNI_17.2.17 is available.
2017-10-01 13:11:20,600 interface:WARNING AFNI is outdated, detected version Debian-16.2.07~dfsg.1-5~nd16.04+1 and AFNI_17.2.17 is available.
2017-10-01 13:11:21,056 mriqc.cli:WARNING No T2w scans were found in /data
2017-10-01 13:11:21,056 mriqc.cli:WARNING Anonymized quality metrics will be submitted to MRIQC's metrics repository. Use --no-sub to disable submission.
2017-10-01 13:12:02,684 workflow:ERROR ['Node skullstrip.a0 failed to run on host brainbox.']
[ ... output elided for brevity ... ]


Am I missing something in the host's path to cause skullstripping to fail? I presume that the AFNI it is detecting is inside the container, since mine is different, as this, run from the host's prompt shows:

$ afni -version
Precompiled binary linux_openmp_64: Dec 22 2016 (Version AFNI_16.3.18)


Thanks, -- bennet

ben...@umich.edu

unread,
Oct 1, 2017, 9:29:40 AM10/1/17
to mriqc-users
Sorry to pile on, but it also finished with abnormal termination.

2017-10-01 13:22:34,129 mriqc.report:WARNING Building bold report: no exclude index was found
2017-10-01 13:22:34,189 workflow:ERROR could not run node: workflow_enumerator.anatMRIQCT1w.AFNISkullStripWorkflow.skullstrip.a0

Traceback (most recent call last):
  File "/usr/local/miniconda/bin/mriqc", line 11, in <module>
    load_entry_point('mriqc==0.9.8.post1', 'console_scripts', 'mriqc')()
  File "/usr/local/miniconda/lib/python3.6/site-packages/mriqc/bin/mriqc_run.py", line 325, in main
    workflow.run(**plugin_settings)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/engine/workflows.py", line 590, in run
    runner.run(execgraph, updatehash=updatehash, config=self.config)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/base.py", line 279, in run
    report_nodes_not_run(notrun)
  File "/usr/local/miniconda/lib/python3.6/site-packages/niworkflows/nipype/pipeline/plugins/base.py", line 101, in report_nodes_not_run
    raise RuntimeError(('Workflow did not execute cleanly. '
RuntimeError: Workflow did not execute cleanly. Check log for details


Since AFNI is installed inside the container, is this an indication that there is something amiss with the workflow connector?

Thanks,  -- bennet

ben...@umich.edu

unread,
Oct 7, 2017, 5:01:59 PM10/7/17
to mriqc-users
If you wish to convert the Docker image to Singularity, you will need to fix permissions and supply a missing library.  The following finally worked for me.

This mriqc.def file.
-------------------------
# Singularity bootstrap definition file; test with Singularity development version
# commit 9fabbd8843ffe44565d34586f07c817501be045d

Bootstrap: docker
From: poldracklab/mriqc:latest

%setup
# You must provide the libGL.so.1 from Ubuntu 16.04 LTS and copy it into
# the container, as it is missing and 3dSkullStrip will not run without it
cp /home/bennet/Projects/mpeckins/MRIQC/libGL.so.1 \
$SINGULARITY_ROOTFS/usr/lib/x86_64-linux-gnu/libGL.so.1

%post

# Miniconda or Conda doesn't set permissions properly. Make sure that
# everyone can read and execute what they should.
chmod -R a+rX /usr/local/miniconda

mkdir /data
-------------------------

Note that you need to get libGL.so.1 from an Ubuntu installation so you can copy into the container.  In the recent Xenial I have, it was under /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 and is a symlink.  Copy to the Singularity build directory.

Because of a change at Docker, I also had to compile the development version of Singularity, commit 9fabbd8843ffe44565d34586f07c817501be045d

Once the definition file is created and Singularity installed,

$ sudo singularity build mriqc.simg mriqc.def

As outlined above, I got the ds008 data from OpenfMRI.org to test, and upacked it in the Singularity build folder, as ds008_R2.0.0.

This runs mriqc successfully on subject 15

$ singularity exec -B $PWD/ds008_R2.0.0:/data:ro -B $PWD/out:/out mriqc.simg mriqc \
    /data /out participant --participant_label sub-15

Posting just in case anyone else finds this useful.
Reply all
Reply to author
Forward
0 new messages