diff --git a/README.md b/README.md index d60cb80..067aac8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ =================== Run the Bundle Specific Tractography pipeline. +To access the template in the original publication: +https://zenodo.org/record/4104309#.X4xduZ1KhdU If you use this pipeline, please cite: diff --git a/USAGE b/USAGE index ec68be2..7ba2c9a 100755 --- a/USAGE +++ b/USAGE @@ -3,11 +3,11 @@ Pipeline for bundle-specific tractography USAGE -nextflow run main.nf --root ... [OPTIONAL_ARGUMENTS] +nextflow run main.nf --input ... [OPTIONAL_ARGUMENTS] DESCRIPTION ---root=/path/to/[root] Root folder containing multiple subjects +--input=/path/to/[root] Root folder containing multiple subjects [root] ├── S1 @@ -40,7 +40,7 @@ OPTIONAL ARGUMENTS (current value) --seeding Seeding strategy, either npv or nts ($seeding) --nbr_seeds Number of seeds to initialize, per voxel or total ($nbr_seeds) --algo Choice between "prob", "det" or "prob,det" ($algo) ---basis SH basis of the input FOD ($basis) +--sh_basis SH basis of the input FOD, descoteaux07 or tournier07 ($sh_basis) --min_length Minimal length in mm of streamline ($min_length) --max_length Maximal length in mm of streamline ($max_length) --compress_error_tolerance Error tolerance for streamline compression in mm ($compress_error_tolerance) diff --git a/main.nf b/main.nf index 5ebffd2..7f56101 100644 --- a/main.nf +++ b/main.nf @@ -16,7 +16,7 @@ if(params.help) { "seeding":"$params.seeding", "nbr_seeds":"$params.nbr_seeds", "algo":"$params.algo", - "basis":"$params.basis", + "sh_basis":"$params.sh_basis", "min_length":"$params.min_length", "max_length":"$params.max_length", "compress_error_tolerance":"$params.compress_error_tolerance", @@ -81,8 +81,8 @@ log.info "Outlier Removal Alpha: $params.outlier_alpha" log.info "" log.info "" -log.info "Input: $params.root" -root = file(params.root) +log.info "Input: $params.input" +root = file(params.input) /* Watch out, files are ordered alphabetically in channel */ in_data = Channel .fromFilePairs("$root/**/{*fa.nii.gz,*fodf.nii.gz,*tracking_mask.nii.gz}", @@ -96,6 +96,11 @@ root = file(params.root) maxDepth:2, flat: true) {it.parent.name} +if (!(params.atlas_anat) || !(params.atlas_directory)) { + error "You must specify all 2 atlas related input. --atlas_anat " + + "and --atlas_directory all are mandatory." +} + atlas_anat = Channel.fromPath("$params.atlas_anat") atlas_bundles = Channel.fromPath("$params.atlas_directory/*.trk") algo_list = params.algo?.tokenize(',') @@ -130,6 +135,7 @@ process Register_Anat { output: set sid, "${sid}__output1InverseWarp.nii.gz", "${sid}__output0GenericAffine.mat" into deformation_for_warping file "${sid}__outputWarped.nii.gz" + file "${sid}__output1Warp.nii.gz" script: """ antsRegistrationSyNQuick.sh -d 3 -f ${native_anat} -m ${atlas} -n ${params.register_processes} -o ${sid}__output @@ -150,9 +156,7 @@ process Warp_Bundle { set sid, val(bundle_name.baseName), "${sid}__${bundle_name.baseName}_warp.trk" into bundles_for_priors, models_for_recobundles script: """ - ConvertTransformFile 3 ${affine} ${affine}.txt --hm --ras - scil_apply_transform_to_tractogram.py ${bundle_name} ${warp} ${affine}.txt ${bundle_name.baseName}_linear.trk --inverse --remove_invalid -f - scil_apply_warp_to_tractogram.py ${bundle_name.baseName}_linear.trk ${anat} ${warp} ${sid}__${bundle_name.baseName}_warp.trk --remove_invalid -f + scil_apply_transform_to_tractogram.py ${bundle_name} ${anat} ${affine} ${sid}__${bundle_name.baseName}_warp.trk --inverse --cut_invalid --in_deformation ${warp} """ } @@ -179,8 +183,9 @@ process Generate_Priors { set sid, val(bundle_name), "${sid}__${bundle_name}_endpoints_mask_dilate.nii.gz" into masks_for_map_in script: """ - scil_generate_priors_from_bundle.py ${bundle} ${fod} ${mask} \ - --sh_basis $params.basis --output_prefix ${sid}__${bundle_name}_ + scil_image_math.py convert ${mask} mask.nii.gz --data_type uint8 + scil_generate_priors_from_bundle.py ${bundle} ${fod} mask.nii.gz \ + --sh_basis $params.sh_basis --out_prefix ${sid}__${bundle_name}_ scil_image_math.py dilation ${sid}__${bundle_name}_todi_mask.nii.gz \ $params.bs_tracking_mask_dilation dilate_todi.nii.gz --data_type uint8 scil_image_math.py multiplication ${mask} dilate_todi.nii.gz \ @@ -226,11 +231,11 @@ process Tracking_Mask { script: if (params.use_bs_tracking_mask) """ - mv ${bs_mask} ${sid}__${bundle_name}_tracking_mask.nii.gz + scil_image_math.py convert ${bs_mask} ${sid}__${bundle_name}_tracking_mask.nii.gz --data_type uint8 """ else """ - mv ${tracking_mask} ${sid}__${bundle_name}_tracking_mask.nii.gz + scil_image_math.py convert ${tracking_mask} ${sid}__${bundle_name}_tracking_mask.nii.gz --data_type uint8 """ } @@ -260,10 +265,12 @@ process Local_Tracking { script: """ scil_compute_local_tracking.py ${efod} ${seeding_mask} ${tracking_mask} \ - ${sid}__${bundle_name}_${algo}_${params.seeding}_${params.nbr_seeds}.trk \ - --sh_basis $params.basis --min_len $params.min_length --max_len $params.max_length \ + tracking.trk --sh_basis $params.sh_basis --min_len $params.min_length --max_len $params.max_length \ --$params.seeding $params.nbr_seeds --compress $params.compress_error_tolerance \ --seed $params.tracking_seed --algo ${algo} + scil_remove_invalid_streamlines.py tracking.trk tracking_ic.trk + scil_filter_tractogram.py tracking_ic.trk ${sid}__${bundle_name}_${algo}_${params.seeding}_${params.nbr_seeds}.trk \ + --drawn_roi ${seeding_mask} either_end include """ } @@ -344,7 +351,7 @@ process PFT_Tracking { """ scil_compute_pft.py ${efod} ${seeding_mask} ${map_include} ${map_exclude} \ ${sid}__${bundle_name}_${algo}_${params.seeding}_${params.nbr_seeds}.trk \ - --algo $algo --sh_basis $params.basis --min_length $params.min_length \ + --algo $algo --sh_basis $params.sh_basis --min_length $params.min_length \ --max_length $params.max_length --$seeding $params.nbr_seeds \ --compress $params.compress_error_tolerance --seed $params.tracking_seed scil_remove_invalid_streamlines.py ${sid}__${bundle_name}_${algo}_${params.seeding}_${params.nbr_seeds}.trk ${sid}__${bundle_name}_${algo}_${params.seeding}_${params.nbr_seeds}.trk -f diff --git a/nextflow.config b/nextflow.config index 9eb1132..485e338 100644 --- a/nextflow.config +++ b/nextflow.config @@ -26,7 +26,7 @@ params { seeding="npv" nbr_seeds=1 algo="prob" - basis="descoteaux07" + sh_basis="descoteaux07" min_length=20 max_length=200 compress_error_tolerance=0.2