NrgXnat / docker-images

Dockerfiles and metadata for XNAT's container service
18 stars 21 forks source link

Issue with running deface on NIFTI images #12

Open nshreyasvi opened 1 year ago

nshreyasvi commented 1 year ago

Hello, I was trying to run mri_deface after running DICOM to NIFTY converter. For the output of DICOM 2 NIFTY converter, I am used the argument -z y which generates a .nii.gz file as an output. However, when I try to run mri_deface over the .nii.gz files, I am getting the error GCAalloc: could not allocate nodes Cannot allocate memory My commands.json file looks as follows:

{
    "name": "mri_deface",
    "description": "Runs MRI_Deface",
    "label": "mri_deface",
    "info-url": "https://github.com/rordenlab/dcm2niix",
    "version": "1.6",
    "schema-version": "1.0",
    "type": "docker",
    "image": "nshreyasvi/mri_deface",
    "command-line": "./mri_deface [BIDS] [OTHER_OPTIONS] talairach_mixed_with_skull.gca face.gca /input/*.nii.gz /output",
    "mounts": [
        {
            "name": "nifti-in",
            "writable": "false",
            "path": "/input"
        },
        {
            "name": "deface-out",
            "writable": "true",
            "path": "/output"
        }
    ],
    "inputs": [
        {
            "name": "bids",
            "description": "Create BIDS metadata file",
            "type": "boolean",
            "required": false,
            "default-value": false,
            "replacement-key": "[BIDS]",
            "command-line-flag": "-b",
            "true-value": "y",
            "false-value": "n"
        },
        {
            "name": "other-options",
            "description": "Other command-line flags to pass to dcm2niix",
            "type": "string",
            "required": false,
            "replacement-key": "[OTHER_OPTIONS]"
        }
    ],
    "outputs": [
        {
            "name": "deface",
            "description": "The defaced files",
            "mount": "deface-out",
            "required": "true"
        }
    ],
    "xnat": [
        {
            "name": "deface-on-scan",
            "description": "Run pydeface on a Scan",
            "label": "defacing",
            "contexts": ["xnat:imageScanData"],
            "external-inputs": [
                {
                    "name": "scan",
                    "description": "Input scan",
                    "type": "Scan",
                    "required": true,
                    "matcher": "'NIFTI' in @.resources[*].label"
                }
            ],
            "derived-inputs": [
                {
                    "name": "scan-nifti",
                    "description": "The nifti resource on the scan",
                    "type": "Resource",
                    "derived-from-wrapper-input": "scan",
                    "provides-files-for-command-mount": "nifti-in",
                    "matcher": "@.label == 'NIFTI'"
                }
            ],
            "output-handlers": [
                {
                    "name": "deface-resource",
                    "accepts-command-output": "deface",
                    "as-a-child-of-wrapper-input": "scan",
                    "type": "Resource",
                    "label": "DEFACE"
                }
            ]
        }
    ]
}

And Dockerfile looks as follows:

FROM debian:stretch

ARG DEBIAN_FRONTEND=noninteractive

#----------------------------------------------------------
# Install common dependencies and create default entrypoint
#----------------------------------------------------------
ENV LANG="en_US.UTF-8" \
    LC_ALL="C.UTF-8" \
    ND_ENTRYPOINT="/neurodocker/startup.sh"
RUN apt-get update -qq && apt-get install -yq --no-install-recommends  \
        apt-utils bzip2 ca-certificates curl locales unzip \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
    && localedef --force --inputfile=en_US --charmap=UTF-8 C.UTF-8 \
    && chmod 777 /opt && chmod a+s /opt \
    && mkdir -p /neurodocker \
    && if [ ! -f "$ND_ENTRYPOINT" ]; then \
         echo '#!/usr/bin/env bash' >> $ND_ENTRYPOINT \
         && echo 'set +x' >> $ND_ENTRYPOINT \
         && echo 'if [ -z "$*" ]; then /usr/bin/env bash; else $*; fi' >> $ND_ENTRYPOINT; \
       fi \
    && chmod -R 777 /neurodocker && chmod a+s /neurodocker
ENTRYPOINT ["/neurodocker/startup.sh"]

USER root

RUN apt-get update -qq \
    && apt-get install -y -q --no-install-recommends git \
                                                     vim \
                                                     wget \
                                                     unzip \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN apt-get update
RUN apt-get install libgomp1
RUN wget https://surfer.nmr.mgh.harvard.edu/pub/dist/mri_deface/mri_deface_linux
RUN mv mri_deface_linux mri_deface
RUN chmod a+x mri_deface
RUN wget https://surfer.nmr.mgh.harvard.edu/pub/dist/mri_deface/talairach_mixed_with_skull.gca.gz
RUN wget https://surfer.nmr.mgh.harvard.edu/pub/dist/mri_deface/face.gca.gz
RUN gunzip talairach_mixed_with_skull.gca.gz
RUN gunzip face.gca.gz

LABEL org.nrg.commands="[{\"name\": \"mri_deface\", \"description\": \"Runs MRI_Deface\", \"label\": \"mri_deface\", \"info-url\": \"https://github.com/rordenlab/dcm2niix\", \"version\": \"1.6\", \"schema-version\": \"1.0\", \"type\": \"docker\", \"image\": \"nshreyasvi/mri_deface\", \"command-line\": \"./mri_deface [BIDS] [OTHER_OPTIONS] talairach_mixed_with_skull.gca face.gca /input/*.nii.gz /output\", \"mounts\": [{\"name\": \"nifti-in\", \"writable\": \"false\", \"path\": \"/input\"}, {\"name\": \"deface-out\", \"writable\": \"true\", \"path\": \"/output\"}], \"inputs\": [{\"name\": \"bids\", \"description\": \"Create BIDS metadata file\", \"type\": \"boolean\", \"required\": false, \"default-value\": false, \"replacement-key\": \"[BIDS]\", \"command-line-flag\": \"-b\", \"true-value\": \"y\", \"false-value\": \"n\"}, {\"name\": \"other-options\", \"description\": \"Other command-line flags to pass to dcm2niix\", \"type\": \"string\", \"required\": false, \"replacement-key\": \"[OTHER_OPTIONS]\"}], \"outputs\": [{\"name\": \"deface\", \"description\": \"The defaced files\", \"mount\": \"deface-out\", \"required\": \"true\"}], \"xnat\": [{\"name\": \"deface-on-scan\", \"description\": \"Run pydeface on a Scan\", \"label\": \"defacing\", \"contexts\": [\"xnat:imageScanData\"], \"external-inputs\": [{\"name\": \"scan\", \"description\": \"Input scan\", \"type\": \"Scan\", \"required\": true, \"matcher\": \"'NIFTI' in @.resources[*].label\"}], \"derived-inputs\": [{\"name\": \"scan-nifti\", \"description\": \"The nifti resource on the scan\", \"type\": \"Resource\", \"derived-from-wrapper-input\": \"scan\", \"provides-files-for-command-mount\": \"nifti-in\", \"matcher\": \"@.label == 'NIFTI'\"}], \"output-handlers\": [{\"name\": \"deface-resource\", \"accepts-command-output\": \"deface\", \"as-a-child-of-wrapper-input\": \"scan\", \"type\": \"Resource\", \"label\": \"DEFACE\"}]}]}]"

I would like to know what would be the cause of the error and how could I fix it?