From 4564b2c09b3745d38f9d1a483400fdb6dcccd965 Mon Sep 17 00:00:00 2001 From: Stefan Sunaert Date: Wed, 8 Sep 2021 15:22:57 +0200 Subject: [PATCH 1/7] Initial commit for synb0 --- README.md | 40 +++++++++ mrtrix3_connectome.py | 185 +++++++++++++++++++++++++----------------- 2 files changed, 152 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 31c7922..8bbbd1b 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,46 @@ normalisation. **NOTE**: App is still under development; script is not guaranteed to be operational for all use cases. +## Changes relative to the original (this is a fork) + +We try to adapt the code to incorporate synb0 processing an approach described in: +https://www.sciencedirect.com/science/article/pii/S0730725X18306179 + +See also: https://github.com/BIDS-Apps/MRtrix3_connectome/issues/81 + +First, you need to run synb0 (using e.g. https://github.com/treanus/KUL_NeuroImaging_Tools/blob/master/KUL_synb0.sh). +This will read BIDS data and store the output of topup in the BIDS derivatives. +E.g. +BIDS/derivatives/ +└── synb0 + ├── sub-iz01 + │   ├── ses-01 + │   │   └── topup + │   │   ├── topup_fieldcoef.nii.gz + │   │   └── topup_movpar.txt + │   └── ses-02 + │   └── topup + │   ├── topup_fieldcoef.nii.gz + │   └── topup_movpar.txt + ├── sub-iz02 + │   ├── ses-01 + │   │   └── topup + │   │   ├── topup_fieldcoef.nii.gz + │   │   └── topup_movpar.txt + │   └── ses-02 + │   └── topup + │   ├── topup_fieldcoef.nii.gz + │   └── topup_movpar.txt + └── sub-iz03 + └── ses-01 + └── topup + ├── topup_fieldcoef.nii.gz + └── topup_movpar.txt + +The above is then used as input to the dwifslproproc command of MRtrix3 (dev branch 3.1) + + + ## Requirements Due to use of the Anatomically-Constrained Tractography (ACT) framework, correction of diff --git a/mrtrix3_connectome.py b/mrtrix3_connectome.py index 4efbe6c..bcb10db 100755 --- a/mrtrix3_connectome.py +++ b/mrtrix3_connectome.py @@ -921,7 +921,7 @@ def get_t1w_preproc_images(import_path, def run_preproc(bids_dir, session, shared, - t1w_preproc_path, output_verbosity, output_app_dir): + t1w_preproc_path, topup_prefix, output_verbosity, output_app_dir): session_label = '_'.join(session) output_subdir = os.path.join(output_app_dir, @@ -1090,78 +1090,106 @@ def run_preproc(bids_dir, session, shared, 'DWI series not defined on same image grid; ' 'script not yet capable of handling such data') - # Go hunting for reversed phase-encode data - # dedicated to field map estimation - in_fmap_image_list = [] - fmap_dir = os.path.join(os.path.join(bids_dir, *session), 'fmap') - fmap_index = 0 - fmap_image_list = [] - if os.path.isdir(fmap_dir): - app.console('Importing fmap data into scratch directory') - in_fmap_image_list = sorted( - glob.glob(os.path.join(fmap_dir, '*_dir-*_epi.nii*'))) - for entry in in_fmap_image_list: - prefix = os.path.splitext(entry.rstrip('.gz'))[0] - json_path = prefix + '.json' - try: - with open(json_path, 'r') as f: - json_elements = json.load(f) - except OSError: - app.warn('No JSON file found for image "' - + entry - + '"; not importing') - continue - if 'IntendedFor' in json_elements: - if isinstance(json_elements['IntendedFor'], list) and \ - not any(any(i.endswith(target) for i in in_dwi_image_list) - for target in json_elements['IntendedFor']): - app.console('Image \'' + entry + '\' is not intended ' - 'for use with DWIs; skipping') - continue - if not any(i.endswith(json_elements['IntendedFor']) - for i in in_dwi_image_list): - app.console('Image \'' + entry + '\' is not intended ' - 'for use with DWIs; skipping') + if topup_prefix: + #if a topup prefix is given then check whether the fieldcoef exists + app.console('Importing topup data into scratch directory') + in_topup_path = os.path.join(bids_dir, + 'derivatives', + topup_prefix, + *session, + 'topup', + 'topup' + '*.nii*') + in_topup_image_list = sorted(glob.glob(in_topup_path)) + if not in_topup_image_list: + raise MRtrixError('No topup data found for session \'' + + session_label + + '\' (search location: ' + in_topup_path) + + topup_files_prefix = os.path.join(bids_dir, + 'derivatives', + topup_prefix, + *session, + 'topup', + 'topup') + dwifslpreproc_topup_files = ' ' + '-topup_files ' + str(topup_files_prefix) + ' ' + app.console('This option will be added to dwifslpreproc: ' + str(dwifslpreproc_topup_files)) + fmap_image_list = [] + + else: + dwifslpreproc_topup_files = '' + + # Go hunting for reversed phase-encode data + # dedicated to field map estimation + in_fmap_image_list = [] + fmap_dir = os.path.join(os.path.join(bids_dir, *session), 'fmap') + fmap_index = 0 + fmap_image_list = [] + if os.path.isdir(fmap_dir): + app.console('Importing fmap data into scratch directory') + in_fmap_image_list = sorted( + glob.glob(os.path.join(fmap_dir, '*_dir-*_epi.nii*'))) + for entry in in_fmap_image_list: + prefix = os.path.splitext(entry.rstrip('.gz'))[0] + json_path = prefix + '.json' + try: + with open(json_path, 'r') as f: + json_elements = json.load(f) + except OSError: + app.warn('No JSON file found for image "' + + entry + + '"; not importing') continue - if not os.path.isfile(json_path): - raise MRtrixError('No sidecar JSON file found ' - 'for image \'' + entry + '\'') - # fmap files will not come with any gradient encoding in the JSON; - # therefore we need to add it manually ourselves so that - # mrcat / mrconvert can appropriately handle the table once - # these images are concatenated with the DWIs - fmap_index += 1 - fmap_image_size = image.Header(entry).size() - fmap_image_num_volumes = \ - 1 if len(fmap_image_size) == 3 else fmap_image_size[3] - fmap_dwscheme_file = 'fmap' + str(fmap_index) + '.b' - with open(path.to_scratch(fmap_dwscheme_file, False), 'w') as f: - for _ in range(0, fmap_image_num_volumes): - f.write('0,0,1,0\n') - run.command('mrconvert ' - + entry + ' ' - + path.to_scratch('fmap' + str(fmap_index) + '.mif', - True) - + ' -json_import ' + json_path - + ' -grad ' + path.to_scratch(fmap_dwscheme_file, - True)) - app.cleanup(fmap_dwscheme_file) - - fmap_image_list = ['fmap' + str(index) + '.mif' - for index in range(1, fmap_index+1)] - - # No need to explicitly check whether fmap/ images are defined - # on a common image grid; these we are happy to resample - - # If there's no usable data in fmap/ directory, - # need to check to see if there's any phase-encoding - # contrast within the input DWI(s) - if not fmap_image_list and len(dwi_image_list) < 2: - raise MRtrixError('Inadequate data for pre-processing of session ' - '\"' + session_label + '": ' - 'No phase-encoding contrast in input DWIs, ' - 'and no fmap/ directory, ' - 'so EPI distortion correction cannot be performed') + if 'IntendedFor' in json_elements: + if isinstance(json_elements['IntendedFor'], list) and \ + not any(any(i.endswith(target) for i in in_dwi_image_list) + for target in json_elements['IntendedFor']): + app.console('Image \'' + entry + '\' is not intended ' + 'for use with DWIs; skipping') + continue + if not any(i.endswith(json_elements['IntendedFor']) + for i in in_dwi_image_list): + app.console('Image \'' + entry + '\' is not intended ' + 'for use with DWIs; skipping') + continue + if not os.path.isfile(json_path): + raise MRtrixError('No sidecar JSON file found ' + 'for image \'' + entry + '\'') + # fmap files will not come with any gradient encoding in the JSON; + # therefore we need to add it manually ourselves so that + # mrcat / mrconvert can appropriately handle the table once + # these images are concatenated with the DWIs + fmap_index += 1 + fmap_image_size = image.Header(entry).size() + fmap_image_num_volumes = \ + 1 if len(fmap_image_size) == 3 else fmap_image_size[3] + fmap_dwscheme_file = 'fmap' + str(fmap_index) + '.b' + with open(path.to_scratch(fmap_dwscheme_file, False), 'w') as f: + for _ in range(0, fmap_image_num_volumes): + f.write('0,0,1,0\n') + run.command('mrconvert ' + + entry + ' ' + + path.to_scratch('fmap' + str(fmap_index) + '.mif', + True) + + ' -json_import ' + json_path + + ' -grad ' + path.to_scratch(fmap_dwscheme_file, + True)) + app.cleanup(fmap_dwscheme_file) + + fmap_image_list = ['fmap' + str(index) + '.mif' + for index in range(1, fmap_index+1)] + + # No need to explicitly check whether fmap/ images are defined + # on a common image grid; these we are happy to resample + + # If there's no usable data in fmap/ directory, + # need to check to see if there's any phase-encoding + # contrast within the input DWI(s) + if not fmap_image_list and len(dwi_image_list) < 2: + raise MRtrixError('Inadequate data for pre-processing of session ' + '\"' + session_label + '": ' + 'No phase-encoding contrast in input DWIs, ' + 'and no fmap/ directory, ' + 'so EPI distortion correction cannot be performed') # Get T1-weighted image data # (could be generated from raw data, or grabbed from a @@ -1422,6 +1450,7 @@ def run_preproc(bids_dir, session, shared, + dwifslpreproc_output + dwifslpreproc_se_epi_option + dwifslpreproc_eddy_option + + dwifslpreproc_topup_files + ' -rpe_header -eddyqc_text eddyqc/' + ('' if app.DO_CLEANUP else ' -scratch ' + app.SCRATCH_DIR + ' -nocleanup')) @@ -1459,7 +1488,7 @@ def run_preproc(bids_dir, session, shared, # Step 5: Initial DWI brain mask dwi_mask_image = 'dwi_mask_init.mif' app.console('Performing intial DWI brain masking') - run.command('dwi2mask ' + dwifslpreproc_output + ' ' + dwi_mask_image) + run.command('dwi2mask fslbet -bet_f 0.2 ' + dwifslpreproc_output + ' ' + dwi_mask_image) # Step 6: Combined RF estimation / CSD / mtnormalise / mask revision # DWI brain masking may be inaccurate due to residual bias field. @@ -3727,6 +3756,11 @@ def usage(cmdline): #pylint: disable=unused-variable metavar='path', help='Provide a path by which pre-processed T1-weighted image data ' 'may be found for the processed participant(s) / session(s)') + preproc_participant_options.add_argument( + OPTION_PREFIX + 'topup_preproc', + metavar='prefix', + help='Provide a prefix by which pre-processed topup image data ' + 'may be found for the processed participant(s) / session(s)') participant_options = \ cmdline.add_argument_group( @@ -4111,6 +4145,10 @@ def execute(): #pylint: disable=unused-variable t1w_preproc_path = os.path.abspath(app.ARGS.t1w_preproc) \ if app.ARGS.t1w_preproc \ else None + topup_prefix = app.ARGS.topup_preproc + # if app.ARGS.topup_preproc \ + # else None + if app.ARGS.analysis_level == 'preproc': @@ -4123,6 +4161,7 @@ def execute(): #pylint: disable=unused-variable session_to_process, preproc_shared, t1w_preproc_path, + topup_prefix, app.ARGS.output_verbosity, output_app_path) From 62424a79744abd59b0b0ac9c8a81e2e73bec91a7 Mon Sep 17 00:00:00 2001 From: Stefan Sunaert Date: Wed, 8 Sep 2021 15:24:29 +0200 Subject: [PATCH 2/7] update --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8bbbd1b..a0ffd26 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,13 @@ First, you need to run synb0 (using e.g. https://github.com/treanus/KUL_NeuroIma This will read BIDS data and store the output of topup in the BIDS derivatives. E.g. BIDS/derivatives/ + └── synb0 + ├── sub-iz01 + │   ├── ses-01 + │   │   └── topup │   │   ├── topup_fieldcoef.nii.gz │   │   └── topup_movpar.txt From 89dfc9b9293dc56d963bc59db0560fab59177bfd Mon Sep 17 00:00:00 2001 From: Stefan Sunaert Date: Wed, 8 Sep 2021 15:33:10 +0200 Subject: [PATCH 3/7] update --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index a0ffd26..2a7b771 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,11 @@ See also: https://github.com/BIDS-Apps/MRtrix3_connectome/issues/81 First, you need to run synb0 (using e.g. https://github.com/treanus/KUL_NeuroImaging_Tools/blob/master/KUL_synb0.sh). This will read BIDS data and store the output of topup in the BIDS derivatives. E.g. -BIDS/derivatives/ +BIDS/derivatives/ └── synb0 - ├── sub-iz01 - │   ├── ses-01 - │   │   └── topup │   │   ├── topup_fieldcoef.nii.gz │   │   └── topup_movpar.txt From 66197490517ae0cf93670b2cadf5327264b2155f Mon Sep 17 00:00:00 2001 From: Stefan Sunaert <36293632+treanus@users.noreply.github.com> Date: Wed, 8 Sep 2021 15:41:40 +0200 Subject: [PATCH 4/7] Update README.md update --- README.md | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 2a7b771..107b1ef 100644 --- a/README.md +++ b/README.md @@ -20,31 +20,27 @@ First, you need to run synb0 (using e.g. https://github.com/treanus/KUL_NeuroIma This will read BIDS data and store the output of topup in the BIDS derivatives. E.g. -BIDS/derivatives/ -└── synb0 - ├── sub-iz01 - │   ├── ses-01 - │   │   └── topup - │   │   ├── topup_fieldcoef.nii.gz - │   │   └── topup_movpar.txt - │   └── ses-02 - │   └── topup - │   ├── topup_fieldcoef.nii.gz - │   └── topup_movpar.txt - ├── sub-iz02 - │   ├── ses-01 - │   │   └── topup - │   │   ├── topup_fieldcoef.nii.gz - │   │   └── topup_movpar.txt - │   └── ses-02 - │   └── topup - │   ├── topup_fieldcoef.nii.gz - │   └── topup_movpar.txt - └── sub-iz03 - └── ses-01 - └── topup - ├── topup_fieldcoef.nii.gz - └── topup_movpar.txt + BIDS/derivatives/ + └── synb0 + ├── sub-iz01 + │   ├── ses-01 + │   │   └── topup + │   │   ├── old_topup_fieldcoef.nii.gz + │   │   ├── topup_fieldcoef.nii.gz + │   │   └── topup_movpar.txt + │   └── ses-02 + │   └── topup + │   ├── topup_fieldcoef.nii.gz + │   └── topup_movpar.txt + ├── sub-iz02 + │   ├── ses-01 + │   │   └── topup + │   │   ├── topup_fieldcoef.nii.gz + │   │   └── topup_movpar.txt + │   └── ses-02 + │   └── topup + │   ├── topup_fieldcoef.nii.gz + │   └── topup_movpar.txt The above is then used as input to the dwifslproproc command of MRtrix3 (dev branch 3.1) From c5f0b4e852ac56218412230031083df42bfe9948 Mon Sep 17 00:00:00 2001 From: Stefan Sunaert Date: Wed, 8 Sep 2021 19:03:03 +0200 Subject: [PATCH 5/7] update mrtrix3 version to dev (3.1) --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8011740..4e52067 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:18.04 -MAINTAINER Robert E. Smith +LABEL org.opencontainers.image.authors="Robert E. Smith " # Core system capabilities required RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ @@ -148,7 +148,7 @@ ENV ANTSPATH=/usr/lib/ants \ # Commitish is 3.0.2 plus relevant hotfix RUN git clone https://github.com/MRtrix3/mrtrix3.git /opt/mrtrix3 && \ cd /opt/mrtrix3 && \ - git checkout 4ab54489f40997f7da1e1915c2adde3373cf6039 && \ + git checkout dev && \ python3 configure -nogui && \ python3 build -persistent -nopaginate && \ git describe --tags > /mrtrix3_version && \ From dc6871754414bfcb2796f36abc358a20f57834e1 Mon Sep 17 00:00:00 2001 From: Stefan Sunaert Date: Thu, 9 Sep 2021 10:21:53 +0200 Subject: [PATCH 6/7] update --- Dockerfile | 128 ++++++++++++++++++++++++++++++++++++----------------- README.md | 7 ++- 2 files changed, 92 insertions(+), 43 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4e52067..49ce780 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,6 @@ +# THIS DOCKERFILE IS BROKEN +# it is being developed to incorporate synb0 and dev branch of MRtrix3 + FROM ubuntu:18.04 LABEL org.opencontainers.image.authors="Robert E. Smith " @@ -18,7 +21,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ tcsh \ tzdata \ unzip \ - wget + wget \ + npm # PPA for newer version of nodejs, which is required for bids-validator RUN curl -sL https://deb.nodesource.com/setup_12.x -o nodesource_setup.sh && \ @@ -58,20 +62,31 @@ RUN wget -qO- https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.1.1/frees --exclude='freesurfer/lib/qt' RUN echo "cHJpbnRmICJyb2JlcnQuc21pdGhAZmxvcmV5LmVkdS5hdVxuMjg1NjdcbiAqQ3FLLjFwTXY4ZE5rXG4gRlNvbGRZRXRDUFZqNlxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh RUN apt-get install -y ants=2.2.0-1ubuntu1 + + # FSL installer appears to now be ready for use with version 6 # eddy is also now included in FSL6 -RUN wget -q http://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py && \ - chmod 775 fslinstaller.py && \ - python2 /fslinstaller.py -d /opt/fsl -V 6.0.4 -q && \ - rm -f /fslinstaller.py -RUN which immv || ( echo "FSLPython not properly configured; re-running" && rm -rf /opt/fsl/fslpython && /opt/fsl/etc/fslconf/fslpython_install.sh -f /opt/fsl || ( cat /tmp/fslpython*/fslpython_miniconda_installer.log && exit 1 ) ) +#RUN wget -q http://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py && \ +# chmod 775 fslinstaller.py && \ +# python2 /fslinstaller.py -d /opt/fsl -V 6.0.4 -q && \ +# rm -f /fslinstaller.py +#RUN which immv || ( echo "FSLPython not properly configured; re-running" && rm -rf /opt/fsl/fslpython && /opt/fsl/etc/fslconf/fslpython_install.sh -f /opt/fsl || ( cat /tmp/fslpython*/fslpython_miniconda_installer.log && exit 1 ) ) +FROM buildpack-deps:buster AS base-builder +FROM base-builder as fsl-installer +WORKDIR /opt/fsl +RUN curl -fsSL https://osf.io/dv258/download \ + | tar xz --strip-components 1 + +# ROBEX RUN wget -qO- "https://www.nitrc.org/frs/download.php/5994/ROBEXv12.linux64.tar.gz//?i_agree=1&download_now=1" | \ tar zx -C /opt -RUN npm install -gq bids-validator@1.5.3 + +# BIDS validator +#RUN npm install -gq bids-validator@1.5.3 # apt cleanup to recover as much space as possible -RUN apt-get remove -y libegl1-mesa-dev && \ - apt-get autoremove -y && \ +#RUN apt-get remove -y libegl1-mesa-dev && \ +RUN apt-get autoremove -y && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -95,30 +110,30 @@ RUN wget -q https://github.com/AlistairPerry/CCA/raw/master/parcellations/512inM # rm -f oasis.zip RUN wget -qO- http://www.nitrc.org/frs/download.php/5906/ADHD200_parcellations.tar.gz | \ tar zx -C /opt -RUN wget -q "https://s3-eu-west-1.amazonaws.com/pfigshare-u-files/5528816/lh.HCPMMP1.annot" \ - -O /opt/freesurfer/subjects/fsaverage/label/lh.HCPMMP1.annot && \ - wget -q "https://s3-eu-west-1.amazonaws.com/pfigshare-u-files/5528819/rh.HCPMMP1.annot" \ - -O /opt/freesurfer/subjects/fsaverage/label/rh.HCPMMP1.annot -RUN mkdir /opt/brainnetome && \ - ( wget -q "http://ddl.escience.cn/f/IiyU?func=download&rid=8135438" -O /opt/freesurfer/average/rh.BN_Atlas.gcs || \ - wget -q "https://osf.io/e6zkg/download" -O /opt/freesurfer/average/rh.BN_Atlas.gcs ) && \ - ( wget -q "http://ddl.escience.cn/f/IiyP?func=download&rid=8135433" -O /opt/freesurfer/average/lh.BN_Atlas.gcs || \ - wget -q "https://osf.io/af9ut/download" -O /opt/freesurfer/average/lh.BN_Atlas.gcs ) && \ - ( wget -q "http://ddl.escience.cn/f/PC7Q?func=download&rid=9882718" -O /opt/freesurfer/average/BN_Atlas_subcortex.gca || \ - wget -q "https://osf.io/k2cd8/download" -O /opt/freesurfer/average/BN_Atlas_subcortex.gca ) && \ - ( wget -q "http://ddl.escience.cn/f/PC7O?func=download&rid=9882716" -O /opt/brainnetome/BN_Atlas_246_LUT.txt || \ - wget -q "https://osf.io/eb7pm/download" -O /opt/brainnetome/BN_Atlas_246_LUT.txt ) && \ - ( wget -q "http://ddl.escience.cn/f/Bvhg?func=download&rid=6516020" -O /opt/brainnetome/BNA_MPM_thr25_1.25mm.nii.gz || \ - wget -q "https://osf.io/dbqep/download" -O /opt/brainnetome/BNA_MPM_thr25_1.25mm.nii.gz ) && \ - cp /opt/brainnetome/BN_Atlas_246_LUT.txt /opt/freesurfer/ -RUN wget -qO- "https://github.com/ThomasYeoLab/CBIG/archive/v0.11.1-Wu2017_RegistrationFusion.tar.gz" | \ - tar zx -C /opt && \ - cp /opt/CBIG-0.11.1-Wu2017_RegistrationFusion/stable_projects/brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/Yeo_JNeurophysiol11_SplitLabels/fsaverage5/label/*h.Yeo2011_*Networks_N1000.split_components.annot /opt/freesurfer/subjects/fsaverage5/label/ && \ - cp /opt/CBIG-0.11.1-Wu2017_RegistrationFusion/stable_projects/brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/Yeo_JNeurophysiol11_SplitLabels/project_to_individual/Yeo2011_*networks_Split_Components_LUT.txt /opt/freesurfer/ && \ - mkdir /opt/Yeo2011 && \ - cp /opt/CBIG-0.11.1-Wu2017_RegistrationFusion/stable_projects/brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/Yeo_JNeurophysiol11_SplitLabels/MNI152/Yeo2011_*Networks_N1000.split_components.FSL_MNI152_*mm.nii.gz /opt/Yeo2011/ && \ - cp /opt/CBIG-0.11.1-Wu2017_RegistrationFusion/stable_projects/brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/Yeo_JNeurophysiol11_SplitLabels/MNI152/*Networks_ColorLUT_freeview.txt /opt/Yeo2011/ && \ - rm -rf /opt/CBIG-0.11.1-Wu2017_RegistrationFusion +#RUN wget -q "https://s3-eu-west-1.amazonaws.com/pfigshare-u-files/5528816/lh.HCPMMP1.annot" \ +# -O /opt/freesurfer/subjects/fsaverage/label/lh.HCPMMP1.annot && \ +# wget -q "https://s3-eu-west-1.amazonaws.com/pfigshare-u-files/5528819/rh.HCPMMP1.annot" \ +# -O /opt/freesurfer/subjects/fsaverage/label/rh.HCPMMP1.annot +#RUN mkdir /opt/brainnetome && \ +# ( wget -q "http://ddl.escience.cn/f/IiyU?func=download&rid=8135438" -O /opt/freesurfer/average/rh.BN_Atlas.gcs || \ +# wget -q "https://osf.io/e6zkg/download" -O /opt/freesurfer/average/rh.BN_Atlas.gcs ) && \ +# ( wget -q "http://ddl.escience.cn/f/IiyP?func=download&rid=8135433" -O /opt/freesurfer/average/lh.BN_Atlas.gcs || \ +# wget -q "https://osf.io/af9ut/download" -O /opt/freesurfer/average/lh.BN_Atlas.gcs ) && \ +# ( wget -q "http://ddl.escience.cn/f/PC7Q?func=download&rid=9882718" -O /opt/freesurfer/average/BN_Atlas_subcortex.gca || \ +# wget -q "https://osf.io/k2cd8/download" -O /opt/freesurfer/average/BN_Atlas_subcortex.gca ) && \ +# ( wget -q "http://ddl.escience.cn/f/PC7O?func=download&rid=9882716" -O /opt/brainnetome/BN_Atlas_246_LUT.txt || \ +# wget -q "https://osf.io/eb7pm/download" -O /opt/brainnetome/BN_Atlas_246_LUT.txt ) && \ +# ( wget -q "http://ddl.escience.cn/f/Bvhg?func=download&rid=6516020" -O /opt/brainnetome/BNA_MPM_thr25_1.25mm.nii.gz || \ +# wget -q "https://osf.io/dbqep/download" -O /opt/brainnetome/BNA_MPM_thr25_1.25mm.nii.gz ) && \ +# cp /opt/brainnetome/BN_Atlas_246_LUT.txt /opt/freesurfer/ +#RUN wget -qO- "https://github.com/ThomasYeoLab/CBIG/archive/v0.11.1-Wu2017_RegistrationFusion.tar.gz" | \ +# tar zx -C /opt && \ +# cp /opt/CBIG-0.11.1-Wu2017_RegistrationFusion/stable_projects/brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/Yeo_JNeurophysiol11_SplitLabels/fsaverage5/label/*h.Yeo2011_*Networks_N1000.split_components.annot /opt/freesurfer/subjects/fsaverage5/label/ && \ +# cp /opt/CBIG-0.11.1-Wu2017_RegistrationFusion/stable_projects/brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/Yeo_JNeurophysiol11_SplitLabels/project_to_individual/Yeo2011_*networks_Split_Components_LUT.txt /opt/freesurfer/ && \ +# mkdir /opt/Yeo2011 && \ +# cp /opt/CBIG-0.11.1-Wu2017_RegistrationFusion/stable_projects/brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/Yeo_JNeurophysiol11_SplitLabels/MNI152/Yeo2011_*Networks_N1000.split_components.FSL_MNI152_*mm.nii.gz /opt/Yeo2011/ && \ +# cp /opt/CBIG-0.11.1-Wu2017_RegistrationFusion/stable_projects/brain_parcellation/Yeo2011_fcMRI_clustering/1000subjects_reference/Yeo_JNeurophysiol11_SplitLabels/MNI152/*Networks_ColorLUT_freeview.txt /opt/Yeo2011/ && \ +# rm -rf /opt/CBIG-0.11.1-Wu2017_RegistrationFusion # Setup envvars ENV ANTSPATH=/usr/lib/ants \ @@ -146,14 +161,45 @@ ENV ANTSPATH=/usr/lib/ants \ # MRtrix3 setup # Commitish is 3.0.2 plus relevant hotfix -RUN git clone https://github.com/MRtrix3/mrtrix3.git /opt/mrtrix3 && \ - cd /opt/mrtrix3 && \ - git checkout dev && \ - python3 configure -nogui && \ - python3 build -persistent -nopaginate && \ - git describe --tags > /mrtrix3_version && \ - rm -rf .git/ cmd/ core/ src/ testing/ tmp/ && \ - cd / +#RUN git clone https://github.com/MRtrix3/mrtrix3.git /opt/mrtrix3 && \ +# cd /opt/mrtrix3 && \ +# git checkout dev && \ +# python3 configure -nogui && \ +# python3 build -persistent -nopaginate && \ +# git describe --tags > /mrtrix3_version && \ +# rm -rf .git/ cmd/ core/ src/ testing/ tmp/ && \ +# cd / + +FROM base-builder AS mrtrix3-builder + +# Git commitish from which to build MRtrix3. +ARG MRTRIX3_GIT_COMMITISH="dev" +# Command-line arguments for `./configure` +ARG MRTRIX3_CONFIGURE_FLAGS="" +# Command-line arguments for `./build` +ARG MRTRIX3_BUILD_FLAGS="-persistent -nopaginate" + +RUN apt-get -qq update \ + && apt-get install -yq --no-install-recommends \ + libeigen3-dev \ + libfftw3-dev \ + libgl1-mesa-dev \ + libpng-dev \ + libqt5opengl5-dev \ + libqt5svg5-dev \ + libtiff5-dev \ + qt5-default \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* + +# Clone, build, and install MRtrix3. +ARG MAKE_JOBS="1" +#ARG MAKE_JOBS +WORKDIR /opt/mrtrix3 +RUN git clone -b $MRTRIX3_GIT_COMMITISH --depth 1 https://github.com/MRtrix3/mrtrix3.git . \ + && ./configure $MRTRIX3_CONFIGURE_FLAGS \ + && NUMBER_OF_PROCESSORS=$MAKE_JOBS ./build $MRTRIX3_BUILD_FLAGS \ + && rm -rf tmp # Acquire extra MRtrix3 data RUN wget -q "https://osf.io/v8n5g/download" -O /opt/mrtrix3/share/mrtrix3/labelconvert/Yeo2011_7N_split.txt && \ diff --git a/README.md b/README.md index 107b1ef..61a5b38 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ for all use cases. ## Changes relative to the original (this is a fork) -We try to adapt the code to incorporate synb0 processing an approach described in: +We tried to adapt the code to incorporate synb0 processing an approach described in: https://www.sciencedirect.com/science/article/pii/S0730725X18306179 See also: https://github.com/BIDS-Apps/MRtrix3_connectome/issues/81 @@ -25,7 +25,6 @@ E.g. ├── sub-iz01 │   ├── ses-01 │   │   └── topup - │   │   ├── old_topup_fieldcoef.nii.gz │   │   ├── topup_fieldcoef.nii.gz │   │   └── topup_movpar.txt │   └── ses-02 @@ -44,6 +43,10 @@ E.g. The above is then used as input to the dwifslproproc command of MRtrix3 (dev branch 3.1) +An new option was created: ++ **--topup_prefix prefix**
Provide a path by which fieldcoef image data and movpar.txt may be found for the processed participant(s) / session(s) + +**-topup_prefix synb0** means that thees data are in /BIDS/derivatives/synb0 and organised according to participant(s) / session(s) ## Requirements From b330b810d2e8d10416d6df6461ec85c2140261bd Mon Sep 17 00:00:00 2001 From: Stefan Sunaert <36293632+treanus@users.noreply.github.com> Date: Thu, 9 Sep 2021 10:44:03 +0200 Subject: [PATCH 7/7] Update README.md --- README.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 61a5b38..519d293 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,13 @@ for all use cases. ## Changes relative to the original (this is a fork) -We tried to adapt the code to incorporate synb0 processing an approach described in: +We tried to adapt the code to incorporate synb0 processing, an approach described in: https://www.sciencedirect.com/science/article/pii/S0730725X18306179 See also: https://github.com/BIDS-Apps/MRtrix3_connectome/issues/81 -First, you need to run synb0 (using e.g. https://github.com/treanus/KUL_NeuroImaging_Tools/blob/master/KUL_synb0.sh). -This will read BIDS data and store the output of topup in the BIDS derivatives. -E.g. +First, you need to run synb0 (e.g. using https://github.com/treanus/KUL_NeuroImaging_Tools/blob/master/KUL_synb0.sh). +This will use BIDS data is input, run synb0 with topup and store the relevant output in the BIDS derivatives as follows: BIDS/derivatives/ └── synb0 @@ -41,12 +40,25 @@ E.g. │   ├── topup_fieldcoef.nii.gz │   └── topup_movpar.txt -The above is then used as input to the dwifslproproc command of MRtrix3 (dev branch 3.1) - +The above is then used as input to the mrtrix3_connectome.py command. An new option was created: -+ **--topup_prefix prefix**
Provide a path by which fieldcoef image data and movpar.txt may be found for the processed participant(s) / session(s) ++ **--topup_preproc prefix**
Provide a prefix by which pre-processed topup image data may be found for the processed participant(s) / session(s) + +Using 'mrtrix3_connectome.py bids_dir output_dir preproc [ options ] **-topup_preproc synb0**' means that the synb0 data in /BIDS/derivatives/synb0 will be used. + +Internally this works since the dwifslpreproc command of MRtrix3 dev branch (3.1) has a new option '-topup_files'. See https://github.com/MRtrix3/mrtrix3/blob/dev/bin/dwifslpreproc + +You thus need to have the dev branch of MRtrix3 installed: + + git pull + git checkout dev + ./configure + ./build + + +Note: +For now this only works command line. There is no docker nor singularity container. -**-topup_prefix synb0** means that thees data are in /BIDS/derivatives/synb0 and organised according to participant(s) / session(s) ## Requirements