diff --git a/Dockerfile b/Dockerfile index 5628beb..f739c80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ # Generated by Neurodocker version 0.4.2-3-gf7055a1 -# Timestamp: 2020-06-04 13:51:08 UTC -# +# Timestamp: 2020-06-29 18:20:44 UTC +# # Thank you for using Neurodocker. If you discover any issues # or ways to improve this software, please submit an issue or # pull request on our GitHub repository: -# +# # https://github.com/kaczmarj/neurodocker FROM ubuntu:xenial @@ -48,15 +48,12 @@ RUN apt-get update -qq \ perl-modules \ wget \ curl \ - python3 \ - python3-pip \ - python3-pandas \ - python-pip \ libsm-dev \ libx11-dev \ libxt-dev \ libxext-dev \ libglu1-mesa \ + libpython2.7-stdlib \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -91,7 +88,31 @@ RUN apt-get update -qq \ --exclude='freesurfer/trctrain' \ && sed -i '$isource "/opt/freesurfer/SetUpFreeSurfer.sh"' "$ND_ENTRYPOINT" -RUN bash -c 'pip3 install nibabel pandas==0.21.0' +ENV CONDA_DIR="/opt/miniconda-latest" \ + PATH="/opt/miniconda-latest/bin:$PATH" +RUN 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 RUN bash -c 'curl -sL https://deb.nodesource.com/setup_6.x | bash -' @@ -111,8 +132,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="" \ @@ -128,7 +147,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 @@ -162,16 +181,12 @@ RUN echo '{ \ \n "perl-modules", \ \n "wget", \ \n "curl", \ - \n "python3", \ - \n "python3-pip", \ - \n "python3-pandas", \ - \n "python2.7", \ - \n "python-pip", \ \n "libsm-dev", \ \n "libx11-dev", \ \n "libxt-dev", \ \n "libxext-dev", \ - \n "libglu1-mesa" \ + \n "libglu1-mesa", \ + \n "libpython2.7-stdlib" \ \n ] \ \n ], \ \n [ \ @@ -182,8 +197,20 @@ RUN 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", \ @@ -212,10 +239,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", \ @@ -233,7 +256,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 da2a049..2251296 100644 --- a/Singularity +++ b/Singularity @@ -1,10 +1,10 @@ # Generated by Neurodocker version 0.4.2-3-gf7055a1 -# Timestamp: 2020-06-04 13:51:09 UTC -# +# Timestamp: 2020-06-29 18:20:45 UTC +# # Thank you for using Neurodocker. If you discover any issues # or ways to improve this software, please submit an issue or # pull request on our GitHub repository: -# +# # https://github.com/kaczmarj/neurodocker Bootstrap: docker @@ -43,15 +43,12 @@ apt-get install -y -q --no-install-recommends \ perl-modules \ wget \ curl \ - python3 \ - python3-pip \ - python3-pandas \ - python-pip \ libsm-dev \ libx11-dev \ libxt-dev \ libxext-dev \ - libglu1-mesa + libglu1-mesa \ + libpython2.7-stdlib apt-get clean rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -84,7 +81,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 -' @@ -96,8 +116,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 @@ -130,16 +148,12 @@ echo '{ \n "perl-modules", \n "wget", \n "curl", -\n "python3", -\n "python3-pip", -\n "python3-pandas", -\n "python2.7", -\n "python-pip", \n "libsm-dev", \n "libx11-dev", \n "libxt-dev", \n "libxext-dev", -\n "libglu1-mesa" +\n "libglu1-mesa", +\n "libpython2.7-stdlib" \n ] \n ], \n [ @@ -150,8 +164,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", @@ -180,10 +206,6 @@ echo '{ \n } \n ], \n [ -\n "run_bash", -\n "PATH=/usr/lib/fsl/5.0:$PATH" -\n ], -\n [ \n "env", \n { \n "OS": "Linux", @@ -201,7 +223,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 ], @@ -248,6 +270,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" @@ -270,7 +294,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 8443c8b..0c6e234 100644 --- a/generate_freesurfer_images.sh +++ b/generate_freesurfer_images.sh @@ -46,24 +46,22 @@ docker run --rm ${image} generate docker \ --base ubuntu:xenial \ --pkg-manager apt \ --install tcsh bc tar libgomp1 perl-modules wget curl \ - python3 python3-pip python3-pandas python-pip \ - libsm-dev libx11-dev libxt-dev libxext-dev libglu1-mesa \ + libsm-dev libx11-dev libxt-dev libxext-dev libglu1-mesa libpython2.7-stdlib\ --freesurfer version=6.0.1 install_path=/opt/freesurfer \ - --run-bash 'pip3 install nibabel pandas==0.21.0' \ + --miniconda use_env=base conda_install="python=3 pip pandas setuptools pandas=0.21.0" pip_install="nibabel" \ --run-bash 'curl -sL https://deb.nodesource.com/setup_6.x | bash -' \ --install nodejs \ --run-bash 'npm install -g bids-validator@0.19.8' \ --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' \ @@ -80,24 +78,22 @@ docker run --rm ${image} generate singularity \ --base ubuntu:xenial \ --pkg-manager apt \ --install tcsh bc tar libgomp1 perl-modules wget curl \ - python3 python3-pip python3-pandas python-pip \ - libsm-dev libx11-dev libxt-dev libxext-dev libglu1-mesa \ + libsm-dev libx11-dev libxt-dev libxext-dev libglu1-mesa libpython2.7-stdlib\ --freesurfer version=6.0.1 install_path=/opt/freesurfer \ - --run-bash 'pip3 install nibabel pandas==0.21.0' \ + --miniconda use_env=base conda_install="python=3 pip pandas setuptools pandas=0.21.0" pip_install="nibabel" \ --run-bash 'curl -sL https://deb.nodesource.com/setup_6.x | bash -' \ --install nodejs \ --run-bash 'npm install -g bids-validator@0.19.8' \ --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 3879f2a..f951b66 100755 --- a/run.py +++ b/run.py @@ -71,7 +71,9 @@ def run(command, env={}, ignore_errors=False): parser.add_argument('--license_file', help='Path to FreeSurfer license key file. To obtain it you need to register (for free) at https://surfer.nmr.mgh.harvard.edu/registration.html', type=str, default='/license.txt') parser.add_argument('--acquisition_label', help='If the dataset contains multiple T1 weighted images from different acquisitions which one should be used? Corresponds to "acq-"') +parser.add_argument('--reconstruction_label', help='If the dataset contains multiple T1 weighted images from different reconstructions which one should be used? Corresponds to "rec-"') parser.add_argument('--refine_pial_acquisition_label', help='If the dataset contains multiple T2 or FLAIR weighted images from different acquisitions which one should be used? Corresponds to "acq-"') +parser.add_argument('--refine_pial_reconstruction_label', help='If the dataset contains multiple T2 or FLAIR weighted images from different reconstructions which one should be used? Corresponds to "rec-"') parser.add_argument('--multiple_sessions', help='For datasets with multiday sessions where you do not want to ' 'use the longitudinal pipeline, i.e., sessions were back-to-back, ' 'set this to multiday, otherwise sessions with T1w data will be ' @@ -83,6 +85,8 @@ def run(command, env={}, ignore_errors=False): ' T1only to base surfaces on the T1 alone.', choices=['T2', 'FLAIR', 'None', 'T1only'], default=['T2']) +parser.add_argument('--allow_lowresT2', help='Use T2 images that are lower resolution than (~1x1x1), to refine pial surface.', + action='store_true') parser.add_argument('--hires_mode', help="Submilimiter (high resolution) processing. 'auto' - use only if <1.0mm data detected, 'enable' - force on, 'disable' - force off", choices=['auto', 'enable', 'disable'], default='auto') @@ -123,11 +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 = "*" - + 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: + 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 @@ -142,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 @@ -153,10 +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 = "*" subjects_to_analyze = [] # only for a subset of subjects @@ -195,7 +209,7 @@ def run(command, env={}, ignore_errors=False): "sub-%s" % subject_label, "ses-*", "anat", - "%s_T1w.nii*" % acq_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) @@ -209,7 +223,7 @@ def run(command, env={}, ignore_errors=False): "sub-%s" % subject_label, "ses-%s" % session_label, "anat", - "%s_T1w.nii*" % acq_tpl)) + "%s_T1w.nii*" % (ar_tpl))) input_args = "" if three_T == 'true': @@ -225,18 +239,18 @@ 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_T2w.nii*" % acq_t2)) + "%s_T2w.nii*" % (ar_t2))) FLAIRs = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "ses-%s" % session_label, "anat", - "*%s_FLAIR.nii*" % acq_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: + if (max(nibabel.load(T2).header.get_zooms()) < 1.2) | args.allow_lowresT2: input_args += " " + " ".join(["-T2 %s" % T2]) input_args += " -T2pial" elif args.refine_pial == "FLAIR": for FLAIR in FLAIRs: - if max(nibabel.load(FLAIR).header.get_zooms()) < 1.2: + if (max(nibabel.load(FLAIR).header.get_zooms()) < 1.2) | args.allow_lowresT2: input_args += " " + " ".join(["-FLAIR %s" % FLAIR]) input_args += " -FLAIRpial" @@ -325,7 +339,7 @@ def run(command, env={}, ignore_errors=False): "sub-%s" % subject_label, "ses-*", "anat", - "%s_T1w.nii*" % acq_tpl)) + "%s_T1w.nii*" % (ar_tpl))) input_args = "" if three_T == 'true': @@ -343,20 +357,20 @@ def run(command, env={}, ignore_errors=False): "sub-%s" % subject_label, "ses-*", "anat", - "*%s_T2w.nii*" % acq_t2)) + "%s_T2w.nii*" % (ar_t2))) FLAIRs = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "ses-*", "anat", - "*%s_FLAIR.nii*" % acq_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: + if (max(nibabel.load(T2).header.get_zooms()) < 1.2) | args.allow_lowresT2: input_args += " " + " ".join(["-T2 %s" % T2]) input_args += " -T2pial" elif args.refine_pial == "FLAIR": for FLAIR in FLAIRs: - if max(nibabel.load(FLAIR).header.get_zooms()) < 1.2: + if (max(nibabel.load(FLAIR).header.get_zooms()) < 1.2) | args.allow_lowresT2: input_args += " " + " ".join(["-FLAIR %s" % FLAIR]) input_args += " -FLAIRpial" @@ -395,7 +409,7 @@ def run(command, env={}, ignore_errors=False): T1s = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "anat", - "%s_T1w.nii*" % acq_tpl)) + "%s_T1w.nii*" % (ar_tpl))) if not T1s: print("No T1w nii files found for subject %s. Skipping subject." % subject_label) continue @@ -413,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_T2w.nii*" % acq_t2)) + "%s_T2w.nii*" % (ar_t2))) FLAIRs = glob(os.path.join(args.bids_dir, "sub-%s" % subject_label, "anat", - "*%s_FLAIR.nii*" % acq_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: