Skip to main content

Scripts

Each script appears in full on the workflow page for its step. Table 1 lists the set in run order. All scripts read a single configuration file, 00_config.sh, which is edited once per project. The shell scripts source it themselves; the Python and R scripts read the exported settings, so source 00_config.sh is run in the shell before they are called, and again after every edit to the file. Each shell script writes a log to $OUT/logs/. Steps 0b, 1, 2, 3, 5, 6, 7 and 8a skip participants whose output already exists (FORCE=1 recomputes); Steps 4, 8, 8b and 9 recompute on every run. Missing inputs are reported by participant.

Table 1

Scripts, in Run Order

FileStepRequires
00_config.shProject paths, tract definition, parameters, covariate listbash
00b_fod_estimation.sh0b. Fibre orientation distributions, when preprocessing ended at the tensorMRtrix3
01_register_mni_to_t1.sh1. RegistrationANTs
02_warp_rois.sh2. Warping of seed, target and atlasANTs, FSL
03_build_corridor_mask.sh3. Corridor and exclusion maskFSL
04_tune_cutoff.sh4. Pilot sweep of the cutoffMRtrix3
04b_compare_cutoffs.py4. Side-by-side images, Dice overlap, summary tablePython, MRtrix3
05_tractography.sh5. TractographyMRtrix3
06_clean_bundles.py6. Cleaning; streamline count and length of the cleaned bundlePython, pyAFQ, DIPY
07_visual_qc.py7. Overlay images and flagsPython, MRtrix3
08a_noddi_fit.py8. NODDI fitPython, AMICO
08_node_profiles.py8. Along-tract profilesPython, DIPY
08b_build_analysis_csv.py8. Analysis files for Step 9Python
09a_tract_models.py9. Whole-tract and quartile modelsPython, statsmodels
09b_nodewise_permutation.R9. Node-wise permutation testR
09c_stack_for_explorer.py9. Explorer inputPython

Note. NODDI = neurite orientation dispersion and density imaging.

The complete set can be retrieved with the following command.

mkdir -p mesoconnect_scripts && cd mesoconnect_scripts
base="https://diffusiontensorimaging-repos.github.io/MesoConnect-Tutorial/scripts"
for f in 00_config.sh 00b_fod_estimation.sh 01_register_mni_to_t1.sh 02_warp_rois.sh \
03_build_corridor_mask.sh 04_tune_cutoff.sh 04b_compare_cutoffs.py \
05_tractography.sh 06_clean_bundles.py 07_visual_qc.py 08a_noddi_fit.py \
08_node_profiles.py 08b_build_analysis_csv.py 09a_tract_models.py \
09b_nodewise_permutation.R 09c_stack_for_explorer.py; do
curl -sSLO "$base/$f"
done

Validation status​

The scripts generalize those used to process the example dataset. Before release they were run from Step 0b to Step 8b on three participants of that dataset and compared with the outputs the dataset's own scripts had produced: warped regions and corridors overlapped at Dice ≥ .93, cleaned streamline counts and lengths agreed within the run-to-run variability of tractography, NODDI maps were identical, and along-tract profiles correlated at r ≥ .94 across nodes. The group-level scripts reproduce that dataset's whole-tract, quartile and node-wise results. The run used MRtrix3 3.0.7, FSL 6.0.5.1, ANTs 2.3.5, Python 3.8, DIPY 1.8.0, pyAFQ 1.3.5, AMICO 2.1.1 and R 4 on Linux.

The scripts from which these were generalized are in the SDN-IMPACT-DTI repository.