Skip to content

Commit

Permalink
Merge pull request #27 from mgxd/enh/msm
Browse files Browse the repository at this point in the history
enh: msm support
  • Loading branch information
chrisgorgo authored May 11, 2018
2 parents 20b761f + 04b5000 commit 440fa38
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 58 deletions.
103 changes: 55 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ RUN apt-get -y update \
--exclude='freesurfer/average/mult-comp-cor' \
--exclude='freesurfer/lib/cuda' \
--exclude='freesurfer/lib/qt' && \
apt-get install -y tcsh bc tar libgomp1 perl-modules curl
apt-get install -y tcsh bc tar libgomp1 perl-modules curl

# Set up the environment
ENV OS Linux
ENV FS_OVERRIDE 0
ENV FIX_VERTEX_AREA=
ENV SUBJECTS_DIR /opt/freesurfer/subjects
ENV FSF_OUTPUT_FORMAT nii.gz
ENV MNI_DIR /opt/freesurfer/mni
ENV LOCAL_DIR /opt/freesurfer/local
ENV FREESURFER_HOME /opt/freesurfer
ENV FSFAST_HOME /opt/freesurfer/fsfast
ENV MINC_BIN_DIR /opt/freesurfer/mni/bin
ENV MINC_LIB_DIR /opt/freesurfer/mni/lib
ENV MNI_DATAPATH /opt/freesurfer/mni/data
ENV FMRI_ANALYSIS_DIR /opt/freesurfer/fsfast
ENV PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5
ENV MNI_PERL5LIB /opt/freesurfer/mni/lib/perl5/5.8.5
ENV PATH /opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
ENV OS=Linux \
FS_OVERRIDE=0 \
FIX_VERTEX_AREA= \
SUBJECTS_DIR=/opt/freesurfer/subjects \
FSF_OUTPUT_FORMAT=nii.gz \
MNI_DIR=/opt/freesurfer/mni \
LOCAL_DIR=/opt/freesurfer/local \
FREESURFER_HOME=/opt/freesurfer \
FSFAST_HOME=/opt/freesurfer/fsfast \
MINC_BIN_DIR=/opt/freesurfer/mni/bin \
MINC_LIB_DIR=/opt/freesurfer/mni/lib \
MNI_DATAPATH=/opt/freesurfer/mni/data \
FMRI_ANALYSIS_DIR=/opt/freesurfer/fsfast \
PERL5LIB=/opt/freesurfer/mni/lib/perl5/5.8.5 \
MNI_PERL5LIB=/opt/freesurfer/mni/lib/perl5/5.8.5 \
PATH=/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH

# Install FSL 5.0.9
RUN apt-get update && \
Expand All @@ -57,50 +57,57 @@ RUN apt-get update && \

# Configure environment
ENV FSLDIR=/usr/share/fsl/5.0
ENV FSL_DIR="${FSLDIR}"
ENV FSLOUTPUTTYPE=NIFTI_GZ
ENV PATH=/usr/lib/fsl/5.0:$PATH
ENV FSLMULTIFILEQUIT=TRUE
ENV POSSUMDIR=/usr/share/fsl/5.0
ENV LD_LIBRARY_PATH=/usr/lib/fsl/5.0:$LD_LIBRARY_PATH
ENV FSLTCLSH=/usr/bin/tclsh
ENV FSLWISH=/usr/bin/wish
ENV FSLOUTPUTTYPE=NIFTI_GZ
ENV FSL_DIR="${FSLDIR}" \
FSLOUTPUTTYPE=NIFTI_GZ \
PATH=/usr/lib/fsl/5.0:$PATH \
FSLMULTIFILEQUIT=TRUE \
POSSUMDIR=/usr/share/fsl/5.0 \
LD_LIBRARY_PATH=/usr/lib/fsl/5.0:$LD_LIBRARY_PATH \
FSLTCLSH=/usr/bin/tclsh \
FSLWISH=/usr/bin/wish \
FSLOUTPUTTYPE=NIFTI_GZ

RUN echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh

# Install Connectome Workbench
RUN apt-get update && apt-get -y install connectome-workbench=1.2.3-1~nd14.04+1

ENV CARET7DIR=/usr/bin

# Install HCP Pipelines
# Install HCP Pipelines and MSM binaries
WORKDIR /opt
RUN apt-get -y update \
&& apt-get install -y --no-install-recommends python-numpy && \
wget https://github.com/Washington-University/Pipelines/archive/v3.17.0.tar.gz -O pipelines.tar.gz && \
cd /opt/ && \
tar zxvf /pipelines.tar.gz && \
wget -q https://github.com/Washington-University/Pipelines/archive/v3.17.0.tar.gz -O pipelines.tar.gz && \
tar zxf pipelines.tar.gz && \
mv /opt/Pipelines-* /opt/HCP-Pipelines && \
rm /pipelines.tar.gz && \
cd /
rm pipelines.tar.gz && \
wget -q https://www.doc.ic.ac.uk/~ecr05/MSM_HOCR_v1/MSM_HOCR_v1-download.tgz -O MSMs.tar.gz && \
tar zxf MSMs.tar.gz && \
rm MSMs.tar.gz && \
mv MSM_HOCR_v1/Ubuntu /opt/HCP-Pipelines/MSMBinaries && \
rm -rf MSM_HOCR_v1

WORKDIR /

ENV HCPPIPEDIR=/opt/HCP-Pipelines
ENV HCPPIPEDIR_Templates=${HCPPIPEDIR}/global/templates
ENV HCPPIPEDIR_Bin=${HCPPIPEDIR}/global/binaries
ENV HCPPIPEDIR_Config=${HCPPIPEDIR}/global/config
ENV HCPPIPEDIR_PreFS=${HCPPIPEDIR}/PreFreeSurfer/scripts
ENV HCPPIPEDIR_FS=${HCPPIPEDIR}/FreeSurfer/scripts
ENV HCPPIPEDIR_PostFS=${HCPPIPEDIR}/PostFreeSurfer/scripts
ENV HCPPIPEDIR_fMRISurf=${HCPPIPEDIR}/fMRISurface/scripts
ENV HCPPIPEDIR_fMRIVol=${HCPPIPEDIR}/fMRIVolume/scripts
ENV HCPPIPEDIR_tfMRI=${HCPPIPEDIR}/tfMRI/scripts
ENV HCPPIPEDIR_dMRI=${HCPPIPEDIR}/DiffusionPreprocessing/scripts
ENV HCPPIPEDIR_dMRITract=${HCPPIPEDIR}/DiffusionTractography/scripts
ENV HCPPIPEDIR_Global=${HCPPIPEDIR}/global/scripts
ENV HCPPIPEDIR_tfMRIAnalysis=${HCPPIPEDIR}/TaskfMRIAnalysis/scripts
ENV MSMBin=${HCPPIPEDIR}/MSMBinaries
ENV HCPPIPEDIR_Templates=${HCPPIPEDIR}/global/templates \
HCPPIPEDIR_Bin=${HCPPIPEDIR}/global/binaries \
HCPPIPEDIR_Config=${HCPPIPEDIR}/global/config \
HCPPIPEDIR_PreFS=${HCPPIPEDIR}/PreFreeSurfer/scripts \
HCPPIPEDIR_FS=${HCPPIPEDIR}/FreeSurfer/scripts \
HCPPIPEDIR_PostFS=${HCPPIPEDIR}/PostFreeSurfer/scripts \
HCPPIPEDIR_fMRISurf=${HCPPIPEDIR}/fMRISurface/scripts \
HCPPIPEDIR_fMRIVol=${HCPPIPEDIR}/fMRIVolume/scripts \
HCPPIPEDIR_tfMRI=${HCPPIPEDIR}/tfMRI/scripts \
HCPPIPEDIR_dMRI=${HCPPIPEDIR}/DiffusionPreprocessing/scripts \
HCPPIPEDIR_dMRITract=${HCPPIPEDIR}/DiffusionTractography/scripts \
HCPPIPEDIR_Global=${HCPPIPEDIR}/global/scripts \
HCPPIPEDIR_tfMRIAnalysis=${HCPPIPEDIR}/TaskfMRIAnalysis/scripts \
MSMBin=${HCPPIPEDIR}/MSMBinaries

RUN apt-get update && apt-get install -y --no-install-recommends python-pip python-six python-nibabel python-setuptools
RUN pip install pybids==0.0.1
RUN apt-get update && apt-get install -y --no-install-recommends python-pip python-six python-nibabel python-setuptools
RUN pip install pybids==0.5.1
ENV PYTHONPATH=""

COPY run.py /run.py
Expand Down
24 changes: 14 additions & 10 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def run_post_freesurfer(**args):
'--subcortgraylabels="{HCPPIPEDIR_Config}/FreeSurferSubcorticalLabelTableLut.txt" ' + \
'--freesurferlabels="{HCPPIPEDIR_Config}/FreeSurferAllLut.txt" ' + \
'--refmyelinmaps="{HCPPIPEDIR_Templates}/standard_mesh_atlases/Conte69.MyelinMap_BC.164k_fs_LR.dscalar.nii" ' + \
'--regname="FS" ' + \
'--regname="{regname}" ' + \
'--printcom=""'
cmd = cmd.format(**args)
run(cmd, cwd=args["path"], env={"OMP_NUM_THREADS": str(args["n_cpus"])})
Expand Down Expand Up @@ -148,7 +148,7 @@ def run_generic_fMRI_surface_processsing(**args):
'--fmrires={fmrires:s} ' + \
'--smoothingFWHM={fmrires:s} ' + \
'--grayordinatesres="{grayordinatesres:s}" ' + \
'--regname="FS"'
'--regname="{regname}"'
cmd = cmd.format(**args)
run(cmd, cwd=args["path"], env={"OMP_NUM_THREADS": str(args["n_cpus"])})

Expand All @@ -168,7 +168,7 @@ def run_diffusion_processsing(**args):

__version__ = open('/version').read()

parser = argparse.ArgumentParser(description='HCP Pipeliens BIDS App (T1w, T2w, fMRI)')
parser = argparse.ArgumentParser(description='HCP Pipelines BIDS App (T1w, T2w, fMRI)')
parser.add_argument('bids_dir', help='The directory with the input dataset '
'formatted according to the BIDS standard.')
parser.add_argument('output_dir', help='The directory where the output files '
Expand All @@ -194,6 +194,8 @@ def run_diffusion_processsing(**args):
default=['PreFreeSurfer', 'FreeSurfer', 'PostFreeSurfer',
'fMRIVolume', 'fMRISurface',
'DiffusionPreprocessing'])
parser.add_argument('--coreg', help='Coregistration method to use',
choices=['MSMSulc', 'FS'], default='MSMSulc')
parser.add_argument('--license_key', help='FreeSurfer license key - letters and numbers after "*" in the email you received after registration. To register (for free) visit https://surfer.nmr.mgh.harvard.edu/registration.html',
required=True)
parser.add_argument('-v', '--version', action='version',
Expand All @@ -205,7 +207,7 @@ def run_diffusion_processsing(**args):

run("bids-validator " + args.bids_dir)

layout = BIDSLayout(args.bids_dir)
layout = BIDSLayout(args.bids_dir, exclude=['derivatives'])
subjects_to_analyze = []
# only for a subset of subjects
if args.participant_label:
Expand Down Expand Up @@ -333,7 +335,8 @@ def run_diffusion_processsing(**args):
subject="sub-%s"%subject_label,
grayordinatesres=grayordinatesres,
lowresmesh=lowresmesh,
n_cpus=args.n_cpus))
n_cpus=args.n_cpus,
regname=args.coreg))
])
for stage, stage_func in struct_stages_dict.iteritems():
if stage in args.stages:
Expand All @@ -350,12 +353,12 @@ def run_diffusion_processsing(**args):
if not os.path.exists(fmriscout):
fmriscout = "NONE"

fieldmap_set = layout.get_fieldmap(fmritcs)
if fieldmap_set and fieldmap_set["type"] == "epi":
fieldmap_set = layout.get_fieldmap(fmritcs, return_list=True)
if fieldmap_set and len(fieldmap_set) == 2 and all(item["type"] == "epi" for item in fieldmap_set):
SEPhaseNeg = None
SEPhasePos = None
for fieldmap in fieldmap_set["epi"]:
enc_dir = layout.get_metadata(fieldmap)["PhaseEncodingDirection"]
for fieldmap in fieldmap_set:
enc_dir = layout.get_metadata(fieldmap["epi"])["PhaseEncodingDirection"]
if "-" in enc_dir:
SEPhaseNeg = fieldmap
else:
Expand Down Expand Up @@ -403,7 +406,8 @@ def run_diffusion_processsing(**args):
fmrires=fmrires,
n_cpus=args.n_cpus,
grayordinatesres=grayordinatesres,
lowresmesh=lowresmesh))
lowresmesh=lowresmesh,
regname=args.coreg))
])
for stage, stage_func in func_stages_dict.iteritems():
if stage in args.stages:
Expand Down

0 comments on commit 440fa38

Please sign in to comment.