Error running spm.Smooth on Sherlock server

nipype
sherlock

#1

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(),
                   iterfield=['in_file'],
                   name='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)
smoothingWorkflow.connect([
    (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')])
])

smoothingWorkflow.run()

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

RuntimeError: Command:
/opt/spm12/run_spm12.sh /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
 application.
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!


#2

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


#3

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


#4

@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 spm.zip http://www.fil.ion.ucl.ac.uk/spm/download/restricted/utopia/dev/spm12_latest_Linux_R2017a.zip \
    && unzip -q spm.zip -d /opt \
    && chmod -R 777 /opt/spm* \
    && rm -rf spm.zip \
    && /opt/spm12/run_spm12.sh /opt/mcr/v92/ quit \
    && sed -i '$iexport SPMMCRCMD=\"/opt/spm12/run_spm12.sh /opt/mcr/v92/ script\"' $ND_ENTRYPOINT
ENV MATLABCMD=/opt/mcr/v92/toolbox/matlab \
    FORCE_SPMMCR=1 \
    LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/opt/mcr/v92/runtime/glnxa64:/opt/mcr/v92/bin/glnxa64:/opt/mcr/v92/sys/os/glnxa64:$LD_LIBRARY_PATH

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/run_spm12.sh /opt/mcr/v92/ quit


#5

Thank you—I’ll try this next!