From 948f4b008bccda445cecd29f8058da0295d613d3 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 23 Oct 2018 09:33:24 -0400 Subject: [PATCH 1/4] This needed for modification to be compatible with ZHH 1. The problem was that 1. all spin Echo has to have both AP and PA as Intended for 2. For whatever reason the Phase Encoding Directin comes out incorrect in the metatag for field maps, that is why we need this modification (both "j-" 3. In the future conversion to check if files that has Intended For exists or not. --- run.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index 5a30727..3fbdb6b 100644 --- a/run.py +++ b/run.py @@ -362,11 +362,17 @@ def run_diffusion_processsing(**args): SEPhaseNeg = None SEPhasePos = None for fieldmap in fieldmap_set: - enc_dir = layout.get_metadata(fieldmap["epi"])["PhaseEncodingDirection"] - if "-" in enc_dir: + enc_dir = fieldmap['epi'].split('_dir-')[1].split('_')[0] + if "AP" in enc_dir: SEPhaseNeg = fieldmap['epi'] else: SEPhasePos = fieldmap['epi'] + #for fieldmap in fieldmap_set: + # enc_dir = layout.get_metadata(fieldmap["epi"])["PhaseEncodingDirection"] + # if "-" in enc_dir: + # SEPhaseNeg = fieldmap['epi'] + # else: + # SEPhasePos = fieldmap['epi'] echospacing = layout.get_metadata(fmritcs)["EffectiveEchoSpacing"] unwarpdir = layout.get_metadata(fmritcs)["PhaseEncodingDirection"] unwarpdir = unwarpdir.replace("i","x").replace("j", "y").replace("k", "z") From 6bcd4311ab0c4962bbc3baf9e225690e76002376 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 29 Nov 2018 14:39:37 -0500 Subject: [PATCH 2/4] ICA FIX This is an attempt to implement ICA FIX with MCR in the docker. The cifti part of fix does not work (no complied version of CIFTIMATLABWriteRead comes with the fix.tar.gz) but the other part (nii) seemed to run well. --- Dockerfile | 78 ++++++++++++++++++++++++++++++------ hcp_fix | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++ run.py | 20 ++++++++-- settings.sh | 105 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 300 insertions(+), 15 deletions(-) create mode 100755 hcp_fix create mode 100755 settings.sh diff --git a/Dockerfile b/Dockerfile index 0a11213..4bcd122 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,19 @@ ARG DEBIAN_FRONTEND=noninteractive ENV LANG="C.UTF-8" \ LC_ALL="C.UTF-8" +#adding jessie backport +#Installing R prerequisites for fix + +RUN sh -c 'echo "deb http://ftp.debian.org/debian jessie-backports main" >> /etc/apt/sources.list' && \ + apt-get -qq update && \ + apt-get -t jessie-backports -y install r-base r-base-dev mc nano wget + +RUN Rscript -e 'install.packages(c("kernlab","ROCR", "class", "party", "e1071", "randomForest"), dependencies=TRUE,repos="http://cran.cnr.berkeley.edu/")' +#older version of party is required (I do it this way, becasue otherwise I would need all the dependencies of party which was already installed above) +RUN wget https://cran.r-project.org/src/contrib/Archive/party/party_1.0-25.tar.gz && \ + R CMD INSTALL party_1.0-25.tar.gz && \ + rm party_1.0-25.tar.gz + # Download FreeSurfer RUN apt-get -qq update && \ apt-get install -yq --no-install-recommends \ @@ -55,10 +68,6 @@ ENV OS=Linux \ 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:$PATH -# Install MCR 2016b -ENV MATLABCMD="/opt/matlabmcr-2016b/v91/toolbox/matlab" \ - MATLAB_COMPILER_RUNTIME="/opt/matlabmcr-2016b/v91" \ - LD_LIBRARY_PATH="/opt/matlabmcr-2016b/v91/runtime/glnxa64:/opt/matlabmcr-2016b/v91/bin/glnxa64:/opt/matlabmcr-2016b/v91/sys/os/glnxa64:$LD_LIBRARY_PATH" RUN apt-get update -qq \ && apt-get install -y -q --no-install-recommends \ @@ -67,12 +76,36 @@ RUN apt-get update -qq \ libxt6 \ unzip \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && echo "Downloading MATLAB Compiler Runtime ..." \ - && curl -fsSL --retry 5 -o /tmp/mcr.zip https://ssd.mathworks.com/supportfiles/downloads/R2016b/deployment_files/R2016b/installers/glnxa64/MCR_R2016b_glnxa64_installer.zip \ - && unzip -q /tmp/mcr.zip -d /tmp/mcrtmp \ - && /tmp/mcrtmp/install -destinationFolder /opt/matlabmcr-2016b -mode silent -agreeToLicense yes \ - && rm -rf /tmp/* + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + + +# \ +# && echo "Downloading MATLAB Compiler Runtime ..." \ +# && curl -fsSL --retry 5 -o /tmp/mcr.zip https://ssd.mathworks.com/supportfiles/downloads/R2016b/deployment_files/R2016b/installers/glnxa64/MCR_R2016b_glnxa64_installer.zip \ +# && unzip -q /tmp/mcr.zip -d /tmp/mcrtmp \ +# && /tmp/mcrtmp/install -destinationFolder /opt/matlabmcr-2016b -mode silent -agreeToLicense yes \ +# && rm -rf /tmp/* + +# Install MCR 2016b +#ENV MATLABCMD="/opt/matlabmcr-2016b/v91/toolbox/matlab" +#ENV MATLAB_COMPILER_RUNTIME="/opt/matlabmcr-2016b/v91" +#ENV LD_LIBRARY_PATH="/opt/matlabmcr-2016b/v91/runtime/glnxa64:/opt/matlabmcr-2016b/v91/bin/glnxa64:/opt/matlabmcr-2016b/v91/sys/os/glnxa64:$LD_LIBRARY_PATH" + + + + ##download and install fix +RUN wget http://www.fmrib.ox.ac.uk/~steve/ftp/fix.tar.gz -O fix.tar.gz && \ + cd /opt/ && \ + tar zxvf /fix.tar.gz && \ + mv /opt/fix* /opt/fix && \ + rm /fix.tar.gz && \ + cd /opt/fix && \ + cd / + + +##environmnetal variables mode=0 means MATLAB compiled version , mode=2 would mean Octave +ENV FSL_FIX_MATLAB_MODE=0 +ENV FSL_FIXDIR=/opt/fix # Install miniconda2 ENV PATH="/usr/local/miniconda/bin:$PATH" @@ -154,12 +187,33 @@ RUN echo "deb http://ftp.de.debian.org/debian stretch main" >> /etc/apt/sources. apt-get install -y libstdc++6 # overwrite matlab mcr shared object -RUN rm /opt/matlabmcr-2016b/v91/sys/os/glnxa64/libstdc++.so.6 && \ - ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /opt/matlabmcr-2016b/v91/sys/os/glnxa64/libstdc++.so.6 +#RUN rm /opt/matlabmcr-2016b/v91/sys/os/glnxa64/libstdc++.so.6 && \ +# ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /opt/matlabmcr-2016b/v91/sys/os/glnxa64/libstdc++.so.6 + +RUN ln -s $FSLDIR /usr/local/fsl +RUN mkdir -p /vols/Data/HCP && \ + cd /vols/Data/HCP && \ + wget https://ftp.humanconnectome.org/workbench/workbench-linux64-v1.2.3.zip && \ + unzip workbench-linux64-v1.2.3.zip && \ + cd / # install gradient_unwarp.py (v1.0.3) RUN pip install https://github.com/Washington-University/gradunwarp/archive/v1.0.3.zip +#try MALTAB already compiled +RUN cd $FSL_FIXDIR/compiled/Linux/x86_64 && \ + cp MCRInstaller.zip /tmp && \ + cd /tmp && \ + unzip MCRInstaller.zip && \ + ./install -mode silent -agreeToLicense yes + +COPY settings.sh /opt/fix/settings.sh +RUN chmod +x /opt/fix/settings.sh +RUN mv /opt/fix/hcp_fix /opt/fix/hcp_fix.old +COPY hcp_fix /opt/fix/hcp_fix +RUN chmod +x /opt/fix/hcp_fix + +#COPY MCR.version /opt/fix/MCR.version COPY run.py version / RUN chmod +x /run.py diff --git a/hcp_fix b/hcp_fix new file mode 100755 index 0000000..eb99359 --- /dev/null +++ b/hcp_fix @@ -0,0 +1,112 @@ +#!/bin/sh + +# hcp_fix - wrapper script for FIX, for HCP pipelines +# +# Stephen Smith, FMRIB Analysis Group +# +# Copyright (C) 2012-2013 University of Oxford +# +# SHCOPYRIGHT + +FSL_FIXDIR=$( cd $(dirname $0) ; pwd) +export FSL_FIXDIR +# All fix settings are held in the settings.sh file - edit this file to suit your setup +. ${FSL_FIXDIR}/settings.sh + +############################################################# + +Usage() { + cat < + with being the temporal highpass full-width (2*sigma) in seconds + +e.g. hcp_fix BOLD_REST1_RL/BOLD_REST1_RL.nii.gz 200 + +for detrending-like behaviour, set to 2000 + +EOF + exit 1 +} + +[ "$2" = "" ] && Usage + +fmri=$1 +cd `dirname $fmri` +fmri=`basename $fmri` +fmri=`$FSLDIR/bin/imglob $fmri` +[ `imtest $fmri` != 1 ] && echo No valid 4D_FMRI input file specified && exit 1 +fmri_orig=$fmri + +hp=$2 + +tr=`$FSLDIR/bin/fslval $fmri pixdim4` + +echo "processing FMRI file $fmri with highpass $hp" + +if [ $hp -gt 0 ] ; then + echo "running highpass" + hptr=`echo "10 k $hp 2 / $tr / p" | dc -` + ${FSLDIR}/bin/fslmaths $fmri -Tmean ${fmri}_Tmean + ${FSLDIR}/bin/fslmaths $fmri -bptf $hptr -1 -add ${fmri}_Tmean ${fmri}_hp$hp + fmri=${fmri}_hp$hp +fi + +echo "running MELODIC" +mkdir -p ${fmri}.ica +$FSLDIR/bin/melodic -i $fmri -o ${fmri}.ica/filtered_func_data.ica -d -250 --nobet --report --Oall --tr=$tr + +cd ${fmri}.ica + +$FSLDIR/bin/imln ../$fmri filtered_func_data +$FSLDIR/bin/imln filtered_func_data.ica/mask mask + +if [ `$FSLDIR/bin/imtest ../${fmri_orig}_SBRef` = 1 ] ; then + $FSLDIR/bin/imln ../${fmri_orig}_SBRef mean_func +else + $FSLDIR/bin/imln filtered_func_data.ica/mean mean_func +fi + +if [ -f ../${fmri_orig}_Atlas.dtseries.nii ] ; then + $FSLDIR/bin/imln ../${fmri_orig}_Atlas.dtseries.nii Atlas.dtseries.nii +fi + +mkdir -p mc +if [ -f ../Movement_Regressors.txt ] ; then + cat ../Movement_Regressors.txt | awk '{ print $4 " " $5 " " $6 " " $1 " " $2 " " $3}' > mc/prefiltered_func_data_mcf.par +else + echo "ERROR: Movement_Regressors.txt not retrieved properly." + exit -1 +fi + +${FSL_FIXDIR}/call_matlab.sh -l .fix.log -f functionmotionconfounds $tr $hp + +mkdir -p reg +cd reg +$FSLDIR/bin/imln ../../../../T1w_restore_brain highres +$FSLDIR/bin/imln ../../../../wmparc wmparc +$FSLDIR/bin/imln ../mean_func example_func +$FSLDIR/bin/makerot --theta=0 > highres2example_func.mat +if [ `$FSLDIR/bin/imtest ../../../../T2w` = 1 ] ; then + $FSLDIR/bin/fslmaths ../../../../T1w -div ../../../../T2w veins -odt float + $FSLDIR/bin/flirt -in ${FSL_FIXDIR}/mask_files/hcp_0.7mm_brain_mask -ref veins -out veinbrainmask -applyxfm + $FSLDIR/bin/fslmaths veinbrainmask -bin veinbrainmask + $FSLDIR/bin/fslmaths veins -div `$FSLDIR/bin/fslstats veins -k veinbrainmask -P 50` -mul 2.18 -thr 10 -min 50 -div 50 veins + $FSLDIR/bin/flirt -in veins -ref example_func -applyxfm -init highres2example_func.mat -out veins_exf + $FSLDIR/bin/fslmaths veins_exf -mas example_func veins_exf +fi +cd ../.. + +echo "running FIX" +if [ $hp != 2000 ] ; then + ${FSL_FIXDIR}/fix ${fmri}.ica ${FSL_FIXDIR}/training_files/HCP_hp200.RData 10 -m -h 200 +else + ${FSL_FIXDIR}/fix ${fmri}.ica ${FSL_FIXDIR}/training_files/HCP_hp2000.RData 10 -m -h 2000 +fi + +$FSLDIR/bin/immv ${fmri}.ica/filtered_func_data_clean ${fmri}_clean + +if [ -f ${fmri}.ica/Atlas_clean.dtseries.nii ] ; then + /bin/mv ${fmri}.ica/Atlas_clean.dtseries.nii ${fmri_orig}_Atlas_hp${hp}_clean.dtseries.nii +fi + diff --git a/run.py b/run.py index 3fbdb6b..23033af 100644 --- a/run.py +++ b/run.py @@ -152,6 +152,12 @@ def run_generic_fMRI_surface_processsing(**args): '--regname="{regname}"' cmd = cmd.format(**args) run(cmd, cwd=args["path"], env={"OMP_NUM_THREADS": str(args["n_cpus"])}) + +def run_generic_fMRI_ICAFIX_processsing(**args): + args.update(os.environ) + cmd = '/opt/fix/hcp_fix ' + '{path}' + '/' + '{subject}' + '/MNINonLinear/Results/' + '{fmriname}' + '/' + '{fmriname}' + '.nii.gz 2000' + cmd = cmd.format(**args) + run(cmd, cwd=args["path"], env={"OMP_NUM_THREADS": str(args["n_cpus"])}) def run_diffusion_processsing(**args): args.update(os.environ) @@ -191,9 +197,9 @@ def run_diffusion_processsing(**args): parser.add_argument('--stages', help='Which stages to run. Space separated list.', nargs="+", choices=['PreFreeSurfer', 'FreeSurfer', 'PostFreeSurfer', 'fMRIVolume', - 'fMRISurface', 'DiffusionPreprocessing'], + 'fMRISurface', 'ICAFIX', 'DiffusionPreprocessing'], default=['PreFreeSurfer', 'FreeSurfer', 'PostFreeSurfer', - 'fMRIVolume', 'fMRISurface', + 'fMRIVolume', 'fMRISurface', 'ICAFIX', 'DiffusionPreprocessing']) parser.add_argument('--coreg', help='Coregistration method to use', choices=['MSMSulc', 'FS'], default='MSMSulc') @@ -418,7 +424,15 @@ def run_diffusion_processsing(**args): n_cpus=args.n_cpus, grayordinatesres=grayordinatesres, lowresmesh=lowresmesh, - regname=args.coreg)) + regname=args.coreg)), + ("ICAFIX", partial(run_generic_fMRI_ICAFIX_processsing, + path=args.output_dir, + subject="sub-%s"%subject_label, + fmriname=fmriname, + fmrires=fmrires, + n_cpus=args.n_cpus, + grayordinatesres=grayordinatesres, + lowresmesh=lowresmesh)) ]) for stage, stage_func in func_stages_dict.iteritems(): if stage in args.stages: diff --git a/settings.sh b/settings.sh new file mode 100755 index 0000000..2a42ff6 --- /dev/null +++ b/settings.sh @@ -0,0 +1,105 @@ +# Settings file for FIX +# Modify these settings based on your system setup +FIXVERSION=1.06 +# (actually this version is 1.065 - see wiki page for details) + +# Get the OS and CPU type +FSL_FIX_OS=`uname -s` +FSL_FIX_ARCH=`uname -m` + +if [ -z "${FSL_FIXDIR}" ]; then + FSL_FIXDIR=$( cd $(dirname $0) ; pwd) + export FSL_FIXDIR +fi + +# edit the following variables according to your local setup + +# Part I MATLAB settings +# ======================= +# Point this variable at your MATLAB install folder +if [ -z "${FSL_FIX_MATLAB_ROOT}" ]; then + FSL_FIX_MATLAB_ROOT=/opt/fmrib/matlab + # On OS X this will most likely be something like /Applications/MATLAB_R20XX.app +fi +# On OS X this will most likely be something like /Applications/MATLAB_R20XX.app + +# Point this variable at your MATLAB command - this is usually in +# $FSL_FIX_MATLAB_ROOT/bin/matlab +FSL_FIX_MATLAB=${FSL_FIX_MATLAB_ROOT}/bin/matlab + +# Point this variable at your MATLAB compiler command - this is +# usually $FSL_FIX_MATLAB_ROOT/bin/mcc +FSL_FIX_MCC=${FSL_FIX_MATLAB_ROOT}/bin/mcc + +# Point this variable at an installed MATLAB compiler runtime. This +# MUST be the same as the version given in the file MCR.version +# (which is populated when the software is compiled). +FSL_FIX_MCRROOT=/usr/local/MATLAB/MATLAB_Compiler_Runtime + + +if [ -f ${FSL_FIXDIR}/MCR.version ]; then + FSL_FIX_MCRV=`cat ${FSL_FIXDIR}/MCR.version` +fi + +if [ ! -z "${FSL_FIX_MCRV}" ]; then + FSL_FIX_MCR=${FSL_FIX_MCRROOT}/${FSL_FIX_MCRV} +fi + +# This is name of the folder containing the compiled MATLAB functions +FSL_FIX_MLCDIR=${FSL_FIXDIR}/compiled/${FSL_FIX_OS}/${FSL_FIX_ARCH} + +# See README for instructions on compilation of the MATLAB portions + +# Set this to the MATLAB start-up options. Typically you will +# want to disable Java, display output, the desktop environment +# and the splash screen +FSL_FIX_MLOPTS="-nojvm -nodisplay -nodesktop -nosplash" + +# Set this to the MATLAB 'evaluate string' option +FSL_FIX_MLEVAL="-r" +# Set this to the pass in file option +FSL_FIX_MLFILE="\<" + +# Part II Octave settings +# ======================= +# Point this variable at your Octave command (or leave it blank to +# disable Octave mode +# Linux: +FSL_FIX_OCTAVE=/usr/bin/octave +# Mac OS X installed via MacPorts +#FSL_FIX_OCTAVE=/opt/local/bin/octave +# Disable Octave mode +#FSL_FIX_OCTAVE= + +# Set this to the Octave start-up options. Typically you will need to +# enable 'MATLAB' mode (--traditional) and disable display output +FSL_FIX_OCOPTS="--traditional -q --no-window-system" + +# Set this to the Octave 'evaluate string' option +FSL_FIX_OCEVAL="--eval" +# Set this to the pass in file option +FSL_FIX_OCFILE="" + +# Part III General settings +# ========================= +# This variable selects how we run the MATLAB portions of FIX. +# It takes the values 0-2: +# 0 - Try running the compiled version of the function +# 1 - Use the MATLAB script version +# 2 - Use Octave script version +FSL_FIX_MATLAB_MODE=0 + +# Set this to CIFTI Matlab Reader/Writer for use within HCP pipelines +FSL_FIX_CIFTIRW='/vols/Data/HCP/workbench/CIFTIMatlabReaderWriter'; +# Set this to the location of the HCP Workbench command for your platform +FSL_FIX_WBC='/vols/Data/HCP/workbench/bin_linux64/wb_command'; +export FSL_FIX_CIFTIRW FSL_FIX_WBC + +# Set this to the location of the FSL MATLAB scripts +if [ -z "${FSLDIR}" ]; then + echo "FSLDIR is not set!" + exit 1 +fi +FSL_FIX_FSLMATLAB=${FSLDIR}/etc/matlab + +############################################################# From 904786aa82af52c9e778904da15a7a422edef4cb Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 25 Jan 2019 15:08:42 -0500 Subject: [PATCH 3/4] This is the implementations of ZHH classifier in the pipeline. THe code runs the ZHH classifier at 1 2 5 10 20 30 40 50 threshold in addition to HCP 10 threshold. Thsi will be build into amiklos/hcppipeline:4.11 --- Dockerfile | 5 +++ run.py | 5 ++- zhh_fix | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 zhh_fix diff --git a/Dockerfile b/Dockerfile index 4bcd122..8373b62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -213,6 +213,11 @@ RUN mv /opt/fix/hcp_fix /opt/fix/hcp_fix.old COPY hcp_fix /opt/fix/hcp_fix RUN chmod +x /opt/fix/hcp_fix +RUN wget http://argyelan.com/ZHH/ZHH30_hp2000.RData +COPY ZHH30_hp2000.RData /opt/fix/training_files/ZHH30_hp2000.RData +COPY zhh_fix /opt/fix/zhh_fix +RUN chmod +x /opt/fix/zhh_fix + #COPY MCR.version /opt/fix/MCR.version COPY run.py version / RUN chmod +x /run.py diff --git a/run.py b/run.py index 23033af..a605d09 100644 --- a/run.py +++ b/run.py @@ -158,7 +158,10 @@ def run_generic_fMRI_ICAFIX_processsing(**args): cmd = '/opt/fix/hcp_fix ' + '{path}' + '/' + '{subject}' + '/MNINonLinear/Results/' + '{fmriname}' + '/' + '{fmriname}' + '.nii.gz 2000' cmd = cmd.format(**args) run(cmd, cwd=args["path"], env={"OMP_NUM_THREADS": str(args["n_cpus"])}) - + cmd = '/opt/fix/zhh_fix ' + '{path}' + '/' + '{subject}' + '/MNINonLinear/Results/' + '{fmriname}' + '/' + '{fmriname}' + '.nii.gz 2000' + cmd = cmd.format(**args) + run(cmd, cwd=args["path"], env={"OMP_NUM_THREADS": str(args["n_cpus"])}) + def run_diffusion_processsing(**args): args.update(os.environ) cmd = '{HCPPIPEDIR}/DiffusionPreprocessing/DiffPreprocPipeline.sh ' + \ diff --git a/zhh_fix b/zhh_fix new file mode 100644 index 0000000..9353ea6 --- /dev/null +++ b/zhh_fix @@ -0,0 +1,118 @@ +#!/bin/sh + +# hcp_fix - wrapper script for FIX, for HCP pipelines +# +# Stephen Smith, FMRIB Analysis Group +# +# Copyright (C) 2012-2013 University of Oxford +# +# SHCOPYRIGHT + +FSL_FIXDIR=$( cd $(dirname $0) ; pwd) +export FSL_FIXDIR +# All fix settings are held in the settings.sh file - edit this file to suit your setup +. ${FSL_FIXDIR}/settings.sh + +############################################################# + +Usage() { + cat < + with being the temporal highpass full-width (2*sigma) in seconds + +e.g. hcp_fix BOLD_REST1_RL/BOLD_REST1_RL.nii.gz 200 + +for detrending-like behaviour, set to 2000 + +EOF + exit 1 +} + +[ "$2" = "" ] && Usage + +fmri=$1 +cd `dirname $fmri` +fmri=`basename $fmri` +fmri=`$FSLDIR/bin/imglob $fmri` +[ `imtest $fmri` != 1 ] && echo No valid 4D_FMRI input file specified && exit 1 +fmri_orig=$fmri + +hp=$2 + +tr=`$FSLDIR/bin/fslval $fmri pixdim4` + +echo "processing FMRI file $fmri with highpass $hp" + +if [ $hp -gt 0 ] ; then + echo "running highpass" + hptr=`echo "10 k $hp 2 / $tr / p" | dc -` + ${FSLDIR}/bin/fslmaths $fmri -Tmean ${fmri}_Tmean + ${FSLDIR}/bin/fslmaths $fmri -bptf $hptr -1 -add ${fmri}_Tmean ${fmri}_hp$hp + fmri=${fmri}_hp$hp +fi + +echo "running MELODIC" +mkdir -p ${fmri}.ica +$FSLDIR/bin/melodic -i $fmri -o ${fmri}.ica/filtered_func_data.ica -d -250 --nobet --report --Oall --tr=$tr + +cd ${fmri}.ica + +$FSLDIR/bin/imln ../$fmri filtered_func_data +$FSLDIR/bin/imln filtered_func_data.ica/mask mask + +if [ `$FSLDIR/bin/imtest ../${fmri_orig}_SBRef` = 1 ] ; then + $FSLDIR/bin/imln ../${fmri_orig}_SBRef mean_func +else + $FSLDIR/bin/imln filtered_func_data.ica/mean mean_func +fi + +if [ -f ../${fmri_orig}_Atlas.dtseries.nii ] ; then + $FSLDIR/bin/imln ../${fmri_orig}_Atlas.dtseries.nii Atlas.dtseries.nii +fi + +mkdir -p mc +if [ -f ../Movement_Regressors.txt ] ; then + cat ../Movement_Regressors.txt | awk '{ print $4 " " $5 " " $6 " " $1 " " $2 " " $3}' > mc/prefiltered_func_data_mcf.par +else + echo "ERROR: Movement_Regressors.txt not retrieved properly." + exit -1 +fi + +${FSL_FIXDIR}/call_matlab.sh -l .fix.log -f functionmotionconfounds $tr $hp + +mkdir -p reg +cd reg +$FSLDIR/bin/imln ../../../../T1w_restore_brain highres +$FSLDIR/bin/imln ../../../../wmparc wmparc +$FSLDIR/bin/imln ../mean_func example_func +$FSLDIR/bin/makerot --theta=0 > highres2example_func.mat +if [ `$FSLDIR/bin/imtest ../../../../T2w` = 1 ] ; then + $FSLDIR/bin/fslmaths ../../../../T1w -div ../../../../T2w veins -odt float + $FSLDIR/bin/flirt -in ${FSL_FIXDIR}/mask_files/hcp_0.7mm_brain_mask -ref veins -out veinbrainmask -applyxfm + $FSLDIR/bin/fslmaths veinbrainmask -bin veinbrainmask + $FSLDIR/bin/fslmaths veins -div `$FSLDIR/bin/fslstats veins -k veinbrainmask -P 50` -mul 2.18 -thr 10 -min 50 -div 50 veins + $FSLDIR/bin/flirt -in veins -ref example_func -applyxfm -init highres2example_func.mat -out veins_exf + $FSLDIR/bin/fslmaths veins_exf -mas example_func veins_exf +fi +cd ../.. + +echo "running FIX" +if [ $hp != 2000 ] ; then + ${FSL_FIXDIR}/fix ${fmri}.ica ${FSL_FIXDIR}/training_files/HCP_hp200.RData 10 -m -h 200 +else + #${FSL_FIXDIR}/fix ${fmri}.ica ${FSL_FIXDIR}/training_files/HCP_hp2000.RData 10 -m -h 2000 + for t in 1 2 5 10 20 30 40 50; + do + ${FSL_FIXDIR}/fix ${fmri}.ica ${FSL_FIXDIR}/training_files/ZHH30_hp2000.RData ${t} -m -h 2000 + $FSLDIR/bin/immv ${fmri}.ica/filtered_func_data_clean ${fmri}_clean_th_${t} + if [ -f ${fmri}.ica/Atlas_clean.dtseries.nii ] ; then + /bin/mv ${fmri}.ica/Atlas_clean.dtseries.nii ${fmri_orig}_Atlas_hp${hp}_clean_th_${t}.dtseries.nii + fi + done +fi + + + + + From c22c65eda8b2bc3c07c130a044882c5d76ff838c Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 25 Jan 2019 15:17:48 -0500 Subject: [PATCH 4/4] Dockerfile corrected --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8373b62..bfc3ec7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -213,8 +213,8 @@ RUN mv /opt/fix/hcp_fix /opt/fix/hcp_fix.old COPY hcp_fix /opt/fix/hcp_fix RUN chmod +x /opt/fix/hcp_fix -RUN wget http://argyelan.com/ZHH/ZHH30_hp2000.RData -COPY ZHH30_hp2000.RData /opt/fix/training_files/ZHH30_hp2000.RData +RUN wget http://argyelan.com/ZHH/ZHH30_hp2000.RData && \ + mv ZHH30_hp2000.RData /opt/fix/training_files/ZHH30_hp2000.RData COPY zhh_fix /opt/fix/zhh_fix RUN chmod +x /opt/fix/zhh_fix