Error running spm.Smooth on Sherlock server



Hi everyone,

A little bit of context: I’m writing a workflow that takes the functional files processed through fmriprep and smooths them using SPM. I’m currently running Nipype on the Sherlock server using a singularity container that contains Nipype (version: 0.13.1) and Jupyter.

My pipeline (ostensibly) takes the functional files, unzips them, smooths them, and puts them in a new directory. Here’s what it looks like:

infosource = pe.Node(util.IdentityInterface(fields=['subject_id']), name = 'infosource')
infosource.iterables = ('subject_id', ['sub-04', 'sub-05'])

datasource = pe.Node(nio.DataGrabber(infields=['subject_id']), name = 'datasource')
datasource.inputs.base_directory = in_dir
datasource.inputs.template = '%s/func/*preproc.nii.gz'
datasource.inputs.sort_filelist = True

gunzip = pe.MapNode(interface = misc.Gunzip(),

smooth = pe.Node(interface= spm.Smooth(),
                name = 'smooth')

datasink = pe.Node(interface=nio.DataSink(), name="datasink", iterfield = 'container')
datasink.inputs.base_directory = out_dir

smoothingWorkflow = pe.Workflow(name = 'smoothingWorkflow', base_dir=working_dir)
    (infosource, datasource, [('subject_id', 'subject_id')]),
    (infosource, datasink, [('subject_id', 'container')]),
    (datasource, gunzip, [('outfiles', 'in_file')]),
    (gunzip, smooth, [('out_file', 'in_files')]),
    (smooth, datasink, [('smoothed_files', 'func')])

However, I get the following error when I try to execute the smoothing node:

RuntimeError: Command:
/opt/spm12/ /opt/mcr/v85/ script /scratch/users/nvelez/myProject/smoothing_wf/smoothingWorkflow/_subject_id_sub-04/smooth/pyscript_smooth.m
Standard output:

Standard error:
Failed to create a directory required to extract the CTF file.
 Please make sure that you have appropriate permissions and re-run the
Error initializing CTF Archive
Return code: 255
Interface MatlabCommand failed to run. 
Interface Smooth failed to run. 

Does anyone know what might be causing this error? I thought that I might be writing temporary files on a directory where I have no business writing, so I tried changing the working directory to a directory within $SCRATCH, but this didn’t seem to fix it.

Thanks in advance!


I haven’t encountered this error - but could you try setting the environmental variable MCR_INHIBIT_CTF_LOCK=1?


Thanks! I tried that, but I still get the exact same error. What is MCR_INHIBIT_CTF_LOCK=1 supposed to do?


@nataliavelez - this has to do with how the original container is setup. when SPM-MCR is installed inside a container a few things need to happen before the container becomes readonly as is the case with singularity.

# Install standalone SPM
RUN echo "Downloading standalone SPM ..." \
    && curl -sSL -o \
    && unzip -q -d /opt \
    && chmod -R 777 /opt/spm* \
    && rm -rf \
    && /opt/spm12/ /opt/mcr/v92/ quit \
    && sed -i '$iexport SPMMCRCMD=\"/opt/spm12/ /opt/mcr/v92/ script\"' $ND_ENTRYPOINT
ENV MATLABCMD=/opt/mcr/v92/toolbox/matlab \

if you create the container with Neurodocker, it will automatically take care of the above. the key line is to run this during container construction: /opt/spm12/ /opt/mcr/v92/ quit


Thank you—I’ll try this next!