From 7adf7d2a7d75715d350116fee56c0ba79d4b4eaf Mon Sep 17 00:00:00 2001 From: frheault Date: Wed, 1 Jul 2020 16:07:37 -0400 Subject: [PATCH 1/6] Change warp, uint mask --- USAGE | 2 +- main.nf | 19 ++++++++++--------- nextflow.config | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/USAGE b/USAGE index ec68be2..e1af53a 100755 --- a/USAGE +++ b/USAGE @@ -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 ($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..70e8dcd 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", @@ -130,6 +130,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 +151,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 +178,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 \ @@ -260,10 +260,11 @@ 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_filter_tractogram.py tracking.trk ${sid}__${bundle_name}_${algo}_${params.seeding}_${params.nbr_seeds}.trk \ + --drawn_roi ${seeding_mask} either_end include """ } @@ -344,7 +345,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 From 1bbe00da914ebcce33feaed06e96ce43486f8825 Mon Sep 17 00:00:00 2001 From: frheault Date: Wed, 19 Aug 2020 09:29:22 -0400 Subject: [PATCH 2/6] Remove ic --- main.nf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.nf b/main.nf index 70e8dcd..81e8d56 100644 --- a/main.nf +++ b/main.nf @@ -263,7 +263,8 @@ process Local_Tracking { 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_filter_tractogram.py tracking.trk ${sid}__${bundle_name}_${algo}_${params.seeding}_${params.nbr_seeds}.trk \ + 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 """ } From 6775eb3a3289b8667ebd7fb6f97c7486eaa34518 Mon Sep 17 00:00:00 2001 From: frheault Date: Fri, 11 Sep 2020 13:26:59 -0400 Subject: [PATCH 3/6] Fix indent --- USAGE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/USAGE b/USAGE index e1af53a..999c3ed 100755 --- a/USAGE +++ b/USAGE @@ -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) ---sh_basis SH basis of the input FOD ($sh_basis) +--sh_basis SH basis of the input FOD ($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) From 5555a1b2037c11493f4c19ea73721a3975da41a5 Mon Sep 17 00:00:00 2001 From: frheault Date: Fri, 2 Oct 2020 10:27:47 -0400 Subject: [PATCH 4/6] Robust mask --- main.nf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.nf b/main.nf index 81e8d56..7a0164b 100644 --- a/main.nf +++ b/main.nf @@ -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 3 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(',') @@ -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 """ } From ee2b80e8d4eed42669b21c6912e70ae77c15d2b2 Mon Sep 17 00:00:00 2001 From: frheault Date: Sun, 18 Oct 2020 11:52:42 -0400 Subject: [PATCH 5/6] Resolve Max comments --- README.md | 2 ++ USAGE | 2 +- main.nf | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) 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 999c3ed..e966fc3 100755 --- a/USAGE +++ b/USAGE @@ -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) ---sh_basis SH basis of the input FOD ($sh_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 7a0164b..8a24a92 100644 --- a/main.nf +++ b/main.nf @@ -97,7 +97,7 @@ root = file(params.root) flat: true) {it.parent.name} if (!(params.atlas_anat) || !(params.atlas_directory)) { - error "You must specify all 3 atlas related input. --atlas_anat " + + error "You must specify all 2 atlas related input. --atlas_anat " + "and --atlas_directory all are mandatory." } From 2171c6fb3b27b0adebd61916e420248261a6dc33 Mon Sep 17 00:00:00 2001 From: frheault Date: Sun, 18 Oct 2020 11:53:56 -0400 Subject: [PATCH 6/6] switch root to input --- USAGE | 4 ++-- main.nf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/USAGE b/USAGE index e966fc3..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 diff --git a/main.nf b/main.nf index 8a24a92..7f56101 100644 --- a/main.nf +++ b/main.nf @@ -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}",