Skip to content

Commit

Permalink
Merge pull request #84 from oesteban/agave
Browse files Browse the repository at this point in the history
Agave app description generator
  • Loading branch information
oesteban committed Apr 19, 2016
2 parents 6e5f6f0 + 2d979ae commit 73eb202
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 6 deletions.
21 changes: 21 additions & 0 deletions agave/app/wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# @Author: oesteban
# @Date: 2015-10-21 11:58:53
# @Last Modified by: oesteban
# @Last Modified time: 2015-11-13 10:00:55

OUTPUT_FOLDER=$SCRATCH/${AGAVE_JOB_NAME}-${AGAVE_JOB_ID}
# Create output folder in scratch
mkdir -p ${OUTPUT_FOLDER}

echo "Running mriqc on ${bidsFile}" >> ${OUTPUT_FOLDER}/${AGAVE_JOB_NAME}.out

# Activate anaconda env
source activate crn-2.7

# Call mriqcp
FSLOUTPUTTYPE='NIFTI_GZ' mriqc -i ${bidsFile} -o ${OUTPUT_FOLDER}/out -w ${OUTPUT_FOLDER}/tmp 2>> ${OUTPUT_FOLDER}/${AGAVE_JOB_NAME}.err 1>> ${OUTPUT_FOLDER}/${AGAVE_JOB_NAME}.out

# Collect outputs
archivepath=$(echo ${OUTPUT_FOLDER}/out | cut -d: -f2 | xargs)
ln -s $archivepath .
43 changes: 43 additions & 0 deletions agave/docker-app/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "mriqc-docker",
"version": "0.1.0",
"helpURI": "http://mriqc.readthedocs.org",
"label": "The MRIQC workflow in docker",
"defaultNodeCount": 1,
"defaultRequestedTime": "48:00:00",
"shortDescription": "Run CRN's workflows in Agave's Dockerized cloud.",
"longDescription": "Generic template for running an arbitrary application in Agave's hosted Docker cloud. Apps should be a gzipped archive.",
"executionSystem": "docker.tacc.utexas.edu",
"executionType": "CLI",
"parallelism": "SERIAL",
"deploymentPath": "apps/mriqc-docker",
"deploymentSystem": "openfmri-storage",
"templatePath": "wrapper.sh",
"testPath": "test/test.sh",
"tags": [
"docker", "qc", "preprocessing"
],
"modules": [],
"inputs": [
{
"id": "bidsFolder",
"details": {
"label": "folder",
"description": "input folder, should be BIDS compliant",
"argument": null,
"showArgument": false
},
"value": {
"visible": true,
"required": true,
"type": "string",
"default": "agave://openfmri-storage/ds003_downsampled.tar"
},
"semantics": {
"ontology": []
}
}
],
"parameters": [],
"checkpointable": false
}
6 changes: 6 additions & 0 deletions agave/docker-app/test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -x
export AGAVE_JOB_ID="test123345"
export AGAVE_JOB_NAME="testuser-runner"
export AGAVE_JOB_CALLBACK_FAILURE=""

23 changes: 23 additions & 0 deletions agave/docker-app/wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#set -x

echo "Running mriqc-docker on ${bidsFolder}" >> ${AGAVE_JOB_NAME}.out

# Run the container in docker, mounting the current job directory as /scratch in the container
# Note that here the docker container image must exist for the container to run. If it was
# not built using a passed in Dockerfile, then it will be downloaded here prior to
# invocation. Also note that all output is written to the mounted directory. This allows
# Agave to stage out the data after running.

docker run -i --rm -v `pwd`:/scratch -w /scratch oesteban/mriqc -i ${bidsFolder} -o outputs -w workdir 2>> ${AGAVE_JOB_NAME}.err 1>> ${AGAVE_JOB_NAME}.out

if [ ! $? ]; then
echo "Docker process exited with an error status." >&2
${AGAVE_JOB_CALLBACK_FAILURE}
exit
fi

# Good practice would suggest that you clean up your image after running. For throughput
# you may want to leave it in place. iPlant's docker servers will clean up after themselves
# using a purge policy based on size, demand, and utilization.

#sudo docker rmi $DOCKER_IMAGE
10 changes: 6 additions & 4 deletions mriqc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
"""

__version__ = '0.5.0a3'
__versionbase__ = '0.6.0'
__versionrev__ = 'a1'
__version__ = __versionbase__ + __versionrev__
__author__ = 'Oscar Esteban'
__email__ = 'code@oscaresteban.es'
__maintainer__ = 'Oscar Esteban'
Expand All @@ -42,10 +44,10 @@
__status__ = 'Prototype'
__description__ = 'NR-IQMs (no-reference Image Quality Metrics) for MRI'
__longdesc__ = """
MRIQC provides a series of image processing workflows to extract and compute a series of
NR (no-reference), IQMs (image quality metrics) to be used in QAPs (quality assessment
MRIQC provides a series of image processing workflows to extract and compute a series of
NR (no-reference), IQMs (image quality metrics) to be used in QAPs (quality assessment
protocols) for MRI (magnetic resonance imaging).
This open-source neuroimaging data processing tool is being developed as a part of the
This open-source neuroimaging data processing tool is being developed as a part of the
MRI image analysis and reproducibility platform offered by the CRN. This pipeline derives
from, and is heavily influenced by, the PCP Quality Assessment Protocol.
This tool extracts a series of IQMs from structural and functional MRI data. It is also
Expand Down
2 changes: 0 additions & 2 deletions mriqc/interfaces/qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
# pylint: disable=no-member
#
# @Author: oesteban
# @Date: 2016-01-05 11:29:40
Expand Down Expand Up @@ -324,4 +323,3 @@ def _run_interface(self, runtime):
'perc_fd': num_fd * 100 / (len(fddata) + 1)
}
return runtime

84 changes: 84 additions & 0 deletions mriqc/utils/agave_appgen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: oesteban
# @Date: 2016-03-16 11:28:27
# @Last Modified by: oesteban
# @Last Modified time: 2016-03-16 15:12:13

"""
Agave app generator
"""
import json
from argparse import ArgumentParser, RawTextHelpFormatter
import mriqc

agaveapp = {
'name': mriqc.__name__,
'version': mriqc.__versionbase__,
'helpURI': 'http://mriqc.readthedocs.org',
'label': 'mriqc',
'shortDescription': mriqc.__description__,
'longDescription': mriqc.__longdesc__,
'executionSystem': 'slurm-ls5.tacc.utexas.edu',
'executionType': 'HPC',
'parallelism': 'PARALLEL',
'defaultQueue': 'normal',
'defaultNodeCount': 1,
'deploymentPath': 'apps/mriqc',
'deploymentSystem': 'openfmri-storage',
'templatePath': 'wrapper.sh',
'testPath': 'test/test.sh',
'tags': ['qc', 'sMRI', 'fMRI'],
'modules': [],
'inputs': [{
'id': 'bidsFolder',
'details': {
'label': 'folder',
'description': 'input root folder of a BIDS-compliant tree',
'argument': None,
'showArgument': False
},
'value': {
'visible': True,
'required': True,
'type': 'string',
'default': 'agave://openfmri-storage/data/ds003_downsampled'
},
'semantics': {
'ontology': []
}
}],
'parameters': [],
'checkpointable': False
}

def main():
"""Entry point"""

parser = ArgumentParser(description='ABIDE2BIDS downloader',
formatter_class=RawTextHelpFormatter)
g_inputs = parser.add_argument_group('Inputs')
g_inputs.add_argument('--help-uri', action='store')
g_inputs.add_argument('--input-name', action='store')
g_inputs.add_argument('-E', '--exec-system', action='store')


g_outputs = parser.add_argument_group('Outputs')
g_outputs.add_argument('-o', '--output', action='store',
default='app.json')

opts = parser.parse_args()

if opts.input_name is not None:
agaveapp['inputs'][0]['id'] = opts.input_name
if opts.exec_system:
agaveapp['executionSystem'] = opts.exec_system

with open(opts.output, 'w') as appfile:
json.dump(agaveapp, appfile, indent=4)



if __name__ == '__main__':
main()

0 comments on commit 73eb202

Please sign in to comment.