diff --git a/Dockerfile b/Dockerfile index f7c8b50..75b7634 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Generated by Neurodocker version 0.4.2-3-gf7055a1 -# Timestamp: 2020-06-26 19:59:46 UTC +# Timestamp: 2020-06-29 16:04:34 UTC # # Thank you for using Neurodocker. If you discover any issues # or ways to improve this software, please submit an issue or @@ -131,8 +131,6 @@ ENV FSLDIR="/usr/share/fsl/5.0" \ FSLTCLSH="/usr/bin/tclsh" \ FSLWISH="/usr/bin/wish" -RUN bash -c 'PATH=/usr/lib/fsl/5.0:$PATH' - ENV OS="Linux" \ FS_OVERRIDE="0" \ FIX_VERTEX_AREA="" \ @@ -148,7 +146,7 @@ ENV OS="Linux" \ FMRI_ANALYSIS_DIR="/opt/freesurfer/fsfast" \ PERL5LIB="/opt/freesurfer/mni/share/perl5" \ MNI_PERL5LIB="/opt/freesurfer/mni/share/perl5/" \ - 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="/opt/miniconda-latest/bin:/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/lib/fsl/5.0:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ PYTHONPATH="" RUN mkdir root/matlab && touch root/matlab/startup.m @@ -239,10 +237,6 @@ RUN echo '{ \ \n } \ \n ], \ \n [ \ - \n "run_bash", \ - \n "PATH=/usr/lib/fsl/5.0:$PATH" \ - \n ], \ - \n [ \ \n "env", \ \n { \ \n "OS": "Linux", \ @@ -260,7 +254,7 @@ RUN echo '{ \ \n "FMRI_ANALYSIS_DIR": "/opt/freesurfer/fsfast", \ \n "PERL5LIB": "/opt/freesurfer/mni/share/perl5", \ \n "MNI_PERL5LIB": "/opt/freesurfer/mni/share/perl5/", \ - \n "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", \ + \n "PATH": "/opt/miniconda-latest/bin:/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/lib/fsl/5.0:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", \ \n "PYTHONPATH": "" \ \n } \ \n ], \ diff --git a/Singularity b/Singularity index 84b216c..7f7ef26 100644 --- a/Singularity +++ b/Singularity @@ -1,5 +1,5 @@ # Generated by Neurodocker version 0.4.2-3-gf7055a1 -# Timestamp: 2020-06-26 19:59:47 UTC +# Timestamp: 2020-06-29 16:04:35 UTC # # Thank you for using Neurodocker. If you discover any issues # or ways to improve this software, please submit an issue or @@ -43,11 +43,6 @@ apt-get install -y -q --no-install-recommends \ perl-modules \ wget \ curl \ - python3 \ - python3-pip \ - python3-pandas \ - python-pip \ - python3-setuptools \ libsm-dev \ libx11-dev \ libxt-dev \ @@ -85,7 +80,30 @@ curl -fsSL --retry 5 ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.1/ --exclude='freesurfer/trctrain' sed -i '$isource "/opt/freesurfer/SetUpFreeSurfer.sh"' "$ND_ENTRYPOINT" -bash -c 'pip3 install nibabel pandas==0.21.0' +export PATH="/opt/miniconda-latest/bin:$PATH" +echo "Downloading Miniconda installer ..." +conda_installer="/tmp/miniconda.sh" +curl -fsSL --retry 5 -o "$conda_installer" https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh +bash "$conda_installer" -b -p /opt/miniconda-latest +rm -f "$conda_installer" +conda update -yq -nbase conda +conda config --system --prepend channels conda-forge +conda config --system --set auto_update_conda false +conda config --system --set show_channel_urls true +sync && conda clean -tipsy && sync +conda install -y -q --name base \ + 'python=3' \ + 'pip' \ + 'pandas' \ + 'setuptools' \ + 'pandas=0.21.0' +sync && conda clean -tipsy && sync +bash -c "source activate base + pip install --no-cache-dir \ + 'nibabel'" +rm -rf ~/.cache/pip/* +sync + bash -c 'curl -sL https://deb.nodesource.com/setup_6.x | bash -' @@ -97,8 +115,6 @@ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* bash -c 'npm install -g bids-validator@0.19.8' -bash -c 'PATH=/usr/lib/fsl/5.0:$PATH' - mkdir root/matlab && touch root/matlab/startup.m mkdir /scratch @@ -131,11 +147,6 @@ echo '{ \n "perl-modules", \n "wget", \n "curl", -\n "python3", -\n "python3-pip", -\n "python3-pandas", -\n "python-pip", -\n "python3-setuptools", \n "libsm-dev", \n "libx11-dev", \n "libxt-dev", @@ -151,8 +162,20 @@ echo '{ \n } \n ], \n [ -\n "run_bash", -\n "pip3 install nibabel pandas==0.21.0" +\n "miniconda", +\n { +\n "use_env": "base", +\n "conda_install": [ +\n "python=3", +\n "pip", +\n "pandas", +\n "setuptools", +\n "pandas=0.21.0" +\n ], +\n "pip_install": [ +\n "nibabel" +\n ] +\n } \n ], \n [ \n "run_bash", @@ -181,10 +204,6 @@ echo '{ \n } \n ], \n [ -\n "run_bash", -\n "PATH=/usr/lib/fsl/5.0:$PATH" -\n ], -\n [ \n "env", \n { \n "OS": "Linux", @@ -202,7 +221,7 @@ echo '{ \n "FMRI_ANALYSIS_DIR": "/opt/freesurfer/fsfast", \n "PERL5LIB": "/opt/freesurfer/mni/share/perl5", \n "MNI_PERL5LIB": "/opt/freesurfer/mni/share/perl5/", -\n "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", +\n "PATH": "/opt/miniconda-latest/bin:/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/lib/fsl/5.0:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", \n "PYTHONPATH": "" \n } \n ], @@ -249,6 +268,8 @@ export LC_ALL="en_US.UTF-8" export ND_ENTRYPOINT="/neurodocker/startup.sh" export FREESURFER_HOME="/opt/freesurfer" export PATH="/opt/freesurfer/bin:$PATH" +export CONDA_DIR="/opt/miniconda-latest" +export PATH="/opt/miniconda-latest/bin:$PATH" export FSLDIR="/usr/share/fsl/5.0" export FSLOUTPUTTYPE="NIFTI_GZ" export FSLMULTIFILEQUIT="TRUE" @@ -271,7 +292,7 @@ export MNI_DATAPATH="/opt/freesurfer/mni/data" export FMRI_ANALYSIS_DIR="/opt/freesurfer/fsfast" export PERL5LIB="/opt/freesurfer/mni/share/perl5" export MNI_PERL5LIB="/opt/freesurfer/mni/share/perl5/" -export 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" +export PATH="/opt/miniconda-latest/bin:/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/lib/fsl/5.0:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" export PYTHONPATH="" %files diff --git a/generate_freesurfer_images.sh b/generate_freesurfer_images.sh index 4f55b40..5d341a2 100644 --- a/generate_freesurfer_images.sh +++ b/generate_freesurfer_images.sh @@ -55,14 +55,13 @@ docker run --rm ${image} generate docker \ --env FSLDIR=/usr/share/fsl/5.0 FSLOUTPUTTYPE=NIFTI_GZ \ 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-bash 'PATH=/usr/lib/fsl/5.0:$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/share/perl5 \ MNI_PERL5LIB=/opt/freesurfer/mni/share/perl5/ \ - 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=/opt/miniconda-latest/bin:/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/lib/fsl/5.0:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ PYTHONPATH="" \ --run 'mkdir root/matlab && touch root/matlab/startup.m' \ --run 'mkdir /scratch' \ @@ -88,14 +87,13 @@ docker run --rm ${image} generate singularity \ --env FSLDIR=/usr/share/fsl/5.0 FSLOUTPUTTYPE=NIFTI_GZ \ 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-bash 'PATH=/usr/lib/fsl/5.0:$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/share/perl5 \ MNI_PERL5LIB=/opt/freesurfer/mni/share/perl5/ \ - 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=/opt/miniconda-latest/bin:/opt/freesurfer/bin:/opt/freesurfer/fsfast/bin:/opt/freesurfer/tktools:/opt/freesurfer/mni/bin:/usr/lib/fsl/5.0:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ PYTHONPATH="" \ --run 'mkdir root/matlab && touch root/matlab/startup.m' \ --run 'mkdir /scratch' \ diff --git a/run.py b/run.py index c7df396..f951b66 100755 --- a/run.py +++ b/run.py @@ -127,15 +127,25 @@ def run(command, env={}, ignore_errors=False): subject_dirs = glob(os.path.join(args.bids_dir, "sub-*")) -if args.acquisition_label: - acq_tpl = "*acq-%s*" % args.acquisition_label +#Got to combine acq_tpl and rec_tpl +if args.acquisition_label and not args.reconstruction_label: + ar_tpl = "*acq-%s*" % args.acquisition_label +elif args.reconstruction_label and not args.acquisition_label: + ar_tpl = "*rec-%s*" % args.reconstruction_label +elif args.reconstruction_label and args.acquisition_label: + ar_tpl = "*acq-%s*_rec-%s*" % (args.acquisition_label, args.reconstruction_label) else: - acq_tpl = "*" - -if args.reconstruction_label: - rec_tpl = "*rec-%s*" % args.reconstruction_label + ar_tpl = "*" + +#Got to combine acq_tpl and rec_tpl +if args.refine_pial_acquisition_label and not args.refine_pial_reconstruction_label: + ar_t2 = "*acq-%s*" % args.refine_pial_acquisition_label +elif args.refine_pial_reconstruction_label and not args.refine_pial_acquisition_label: + ar_t2 = "*rec-%s*" % args.refine_pial_reconstruction_label +elif args.refine_pial_reconstruction_label and args.refine_pial_acquisition_label: + ar_t2 = "*acq-%s*_rec-%s*" % (args.refine_pial_acquisition_label, args.refine_pial_reconstruction_label) else: - rec_tpl = "*" + ar_t2 = "*" # if there are session folders, check if study is truly longitudinal by # searching for the first subject with more than one valid sessions @@ -150,7 +160,7 @@ def run(command, env={}, ignore_errors=False): if glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "ses-%s" % session_label, "anat", - "%s_T1w.nii*" % acq_tpl)): + "%s_T1w.nii*" % ar_tpl)): n_valid_sessions += 1 if n_valid_sessions > 1: multi_session_study = True @@ -161,15 +171,6 @@ def run(command, env={}, ignore_errors=False): else: longitudinal_study = False -if args.refine_pial_acquisition_label: - acq_t2 = "*acq-%s*" % args.refine_pial_acquisition_label -else: - acq_t2 = "*" - -if args.refine_pial_reconstruction_label: - rec_t2 = "*rec-%s*" % args.refine_pial_reconstruction_label -else: - rec_t2 = "*" subjects_to_analyze = [] # only for a subset of subjects @@ -208,7 +209,7 @@ def run(command, env={}, ignore_errors=False): "sub-%s" % subject_label, "ses-*", "anat", - "%s_%s_T1w.nii*" % (acq_tpl, rec_tpl))) + "%s_T1w.nii*" % (ar_tpl))) sessions = set([os.path.normpath(t1).split(os.sep)[-3].split("-")[-1] for t1 in T1s]) if args.session_label: sessions = sessions.intersection(args.session_label) @@ -222,7 +223,7 @@ def run(command, env={}, ignore_errors=False): "sub-%s" % subject_label, "ses-%s" % session_label, "anat", - "%s_%s_T1w.nii*" % (acq_tpl, rec_tpl))) + "%s_T1w.nii*" % (ar_tpl))) input_args = "" if three_T == 'true': @@ -238,10 +239,10 @@ def run(command, env={}, ignore_errors=False): T2s = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "ses-%s" % session_label, "anat", - "%s_%s_T2w.nii*" % (acq_t2, rec_t2))) + "%s_T2w.nii*" % (ar_t2))) FLAIRs = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "ses-%s" % session_label, "anat", - "%s_%s_FLAIR.nii*" % (acq_t2, rec_t2))) + "%s_FLAIR.nii*" % (ar_t2))) if args.refine_pial == "T2": for T2 in T2s: if (max(nibabel.load(T2).header.get_zooms()) < 1.2) | args.allow_lowresT2: @@ -338,7 +339,7 @@ def run(command, env={}, ignore_errors=False): "sub-%s" % subject_label, "ses-*", "anat", - "%s_%s_T1w.nii*" % (acq_tpl, rec_tpl))) + "%s_T1w.nii*" % (ar_tpl))) input_args = "" if three_T == 'true': @@ -356,12 +357,12 @@ def run(command, env={}, ignore_errors=False): "sub-%s" % subject_label, "ses-*", "anat", - "%s_%s_T2w.nii*" % (acq_t2, rec_t2))) + "%s_T2w.nii*" % (ar_t2))) FLAIRs = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "ses-*", "anat", - "%s_%s_FLAIR.nii*" % (acq_t2, rec_t2))) + "%s_FLAIR.nii*" % (ar_t2))) if args.refine_pial == "T2": for T2 in T2s: if (max(nibabel.load(T2).header.get_zooms()) < 1.2) | args.allow_lowresT2: @@ -408,7 +409,7 @@ def run(command, env={}, ignore_errors=False): T1s = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "anat", - "%s_%s_T1w.nii*" % (acq_tpl, rec_tpl))) + "%s_T1w.nii*" % (ar_tpl))) if not T1s: print("No T1w nii files found for subject %s. Skipping subject." % subject_label) continue @@ -426,9 +427,9 @@ def run(command, env={}, ignore_errors=False): input_args += " -hires" input_args += " -i %s" % T1 T2s = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "anat", - "%s_%s_T2w.nii*" % (acq_t2, rec_t2))) + "%s_T2w.nii*" % (ar_t2))) FLAIRs = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "anat", - "%s_%s_FLAIR.nii*" % (acq_t2, rec_t2))) + "%s_FLAIR.nii*" % (ar_t2))) if args.refine_pial == "T2": for T2 in T2s: if max(nibabel.load(T2).header.get_zooms()) < 1.2: