Skip to content

Commit

Permalink
[FIX] fix small issues with chaining + added assertions in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
gagnonanthony committed Nov 19, 2024
1 parent 67531b6 commit 8ea6bd5
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
- name: Clean up Disk space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
tool-cache: false

- name: "Run pipeline with test data ${{ matrix.NXF_VER }} | ${{ matrix.test_name }} | ${{ matrix.profile }}"
run: |
Expand Down
2 changes: 1 addition & 1 deletion modules/local/filtering/commit.nf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ process FILTERING_COMMIT {
elif [ -f "${prefix}__results_bzs/commit_1/decompose_commit.h5" ]; then
mv "${prefix}__results_bzs/commit_1/decompose_commit.h5" "./${prefix}__decompose_commit.h5"
else
mv "${prefix}__results_bzs/commit_1/essential.trk" "./${prefix}__commit.trk"
mv "${prefix}__results_bzs/commit_1/essential_tractogram.trk" "./${prefix}__commit.trk"
fi
cat <<-END_VERSIONS > versions.yml
Expand Down
2 changes: 1 addition & 1 deletion modules/local/image/convert.nf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ process IMAGE_CONVERT {
stub:
def prefix = task.ext.prefix ?: "${meta.id}"

def suffix = task.ext.first_suffix ? "${task.ext.first_suffix}_${task.ext.datatype}" : "${task.ext.datatype}"
def suffix = task.ext.first_suffix ? "${task.ext.first_suffix}_${task.ext.datatype}_converted" : "${task.ext.datatype}_converted"

"""
touch ${prefix}_${suffix}.nii.gz
Expand Down
1 change: 1 addition & 0 deletions modules/nf-neuro/betcrop/cropvolume/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ process BETCROP_CROPVOLUME {
scil_volume_crop.py -h
touch ${prefix}_${suffix}.nii.gz
touch bounding_box.pkl
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
8 changes: 4 additions & 4 deletions modules/nf-neuro/segmentation/freesurferseg/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ process SEGMENTATION_FREESURFERSEG {
label 'process_single'

container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://scil.usherbrooke.ca/containers/scilus_2.0.0.sif':
'scilus/scilus:2.0.0' }"
'https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif':
'scilus/scilus:2.0.2' }"

input:
tuple val(meta), path(aparc_aseg), path(wmparc), path(lesion)
Expand Down Expand Up @@ -87,7 +87,7 @@ process SEGMENTATION_FREESURFERSEG {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.0
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
mrtrix: \$(mrconvert -version 2>&1 | sed -n 's/== mrconvert \\([0-9.]\\+\\).*/\\1/p')
END_VERSIONS
"""
Expand All @@ -105,7 +105,7 @@ process SEGMENTATION_FREESURFERSEG {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.0
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
mrtrix: \$(mrconvert -version 2>&1 | sed -n 's/== mrconvert \\([0-9.]\\+\\).*/\\1/p')
END_VERSIONS
"""
Expand Down
8 changes: 4 additions & 4 deletions modules/nf-neuro/utils/extractb0/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ process UTILS_EXTRACTB0 {
label 'process_single'

container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://scil.usherbrooke.ca/containers/scilus_2.0.1.sif':
'scilus/scilus:2.0.1' }"
'https://scil.usherbrooke.ca/containers/scilus_2.0.2.sif':
'scilus/scilus:2.0.2' }"

input:
tuple val(meta), path(dwi), path(bval), path(bvec)
Expand All @@ -31,7 +31,7 @@ process UTILS_EXTRACTB0 {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.1
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
END_VERSIONS
"""

Expand All @@ -46,7 +46,7 @@ process UTILS_EXTRACTB0 {
cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.1
scilpy: \$(pip list | grep scilpy | tr -s ' ' | cut -d' ' -f2)
END_VERSIONS
"""
}
9 changes: 9 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ profiles {
params.run_pft_tracking = false
params.local_min_len = 15
params.local_fa_seeding_mask_threshold = 0.10

params.run_commit2 = false
params.commit_para_diff = "1.2E-3"
params.commit_iso_diff = "2.0E-3"
params.commit_ball_stick = true

params.decompose_min_len = 10
params.decompose_outlier_threshold = 0.4

}
tracking {
params.tracking = true
Expand Down
6 changes: 3 additions & 3 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -950,19 +950,19 @@
"hidden": true
},
"commit_para_diff": {
"type": "number",
"type": "string",
"description": "Para diff value used in the COMMIT filtering step.",
"fa_icon": "fas fa-code-branch",
"hidden": false
},
"commit_iso_diff": {
"type": "number",
"type": "string",
"description": "Iso diff value used in the COMMIT filtering step.",
"fa_icon": "fas fa-code-branch",
"hidden": false
},
"commit_perp_diff": {
"type": "number",
"type": "string",
"description": "Perp diff value used in the COMMIT filtering step.",
"fa_icon": "fas fa-code-branch",
"hidden": false
Expand Down
2 changes: 1 addition & 1 deletion nf-test.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config {
configFile "tests/nextflow.config"
libDir "tests/lib"
profile "docker"
withTrace false
withTrace true
autoSort false
ignore "modules/**", "subworkflows/**"
options "-dump-channels -stub-run"
Expand Down
2 changes: 1 addition & 1 deletion tests/data/samplesheet_testconn.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
subject,t1,t2,dwi,bval,bvec,rev_b0,labels,wmparc,trk,peaks,fodf,mat,warp,metrics
sub-test,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/t1.nii.gz,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/dwi.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/dwi.bval,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/dwi.bvec,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/labels.nii.gz,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/tracking.trk,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/peaks.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/fodf.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/0GenericAffine.mat,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/output1Warp.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/metrics/,
sub-test,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/t1.nii.gz,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/dwi.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/dwi.bval,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/dwi.bvec,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/labels.nii.gz,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/tracking.trk,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/peaks.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/fodf.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/0GenericAffine.mat,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/output1Warp.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/metrics/,
2 changes: 1 addition & 1 deletion tests/data/samplesheet_testconn_infant.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
subject,t1,t2,dwi,bval,bvec,rev_b0,labels,wmparc,trk,peaks,fodf,mat,warp,metrics
sub-test,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/t2.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/dwi.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/dwi.bval,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/dwi.bvec,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/labels.nii.gz,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/tracking.trk,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/peaks.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/fodf.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/0GenericAffine.mat,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/output1Warp.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/metrics/,
sub-test,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/t2.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/dwi.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/dwi.bval,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/dwi.bvec,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/labels.nii.gz,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/tracking.trk,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/peaks.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/fodf.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/0GenericAffine.mat,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/output1Warp.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/metrics/,
2 changes: 1 addition & 1 deletion tests/data/samplesheet_testconn_notrk.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
subject,t1,t2,dwi,bval,bvec,rev_b0,labels,wmparc,trk,peaks,fodf,mat,warp,metrics
sub-test,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/t1.nii.gz,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/dwi.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/dwi.bval,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/dwi.bvec,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/labels.nii.gz,,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/peaks.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/fodf.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/0GenericAffine.mat,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/output1Warp.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-testconn/metrics/,
sub-test,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/t1.nii.gz,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/dwi.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/dwi.bval,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/dwi.bvec,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/labels.nii.gz,,,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/peaks.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/fodf.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/0GenericAffine.mat,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/output1Warp.nii.gz,/Users/anthonygagnon/code/nf-pediatric/tests/data/sub-test/metrics/,
43 changes: 42 additions & 1 deletion tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ nextflow_pipeline {

then {
assert workflow.success
assert workflow.trace.tasks().size() == 26
}

}
Expand Down Expand Up @@ -84,12 +85,14 @@ nextflow_pipeline {
params.run_pft_tracking = false
params.local_min_len = 15
params.local_fa_seeding_mask_threshold = 0.10
params.run_local_tracking = true

}
}

then {
assert workflow.success
assert workflow.trace.tasks().size() == 29
}

}
Expand All @@ -105,6 +108,16 @@ nextflow_pipeline {
params.tracking = true
params.infant = true

// ** Infant specific parameters ** //
params.dwi_run_synthstrip = true
params.dwi_normalize_fa_mask_threshold = 0.10
params.fodf_max_fa_threshold = 0.01
params.fodf_min_md_threshold = 0.00185
params.frf_manual_frf = "12,5,5"
params.run_pft_tracking = false
params.local_min_len = 15
params.local_fa_seeding_mask_threshold = 0.10

}
}

Expand All @@ -126,6 +139,16 @@ nextflow_pipeline {
params.tracking = true
params.infant = true

// ** Infant specific parameters ** //
params.dwi_run_synthstrip = true
params.dwi_normalize_fa_mask_threshold = 0.10
params.fodf_max_fa_threshold = 0.01
params.fodf_min_md_threshold = 0.00185
params.frf_manual_frf = "12,5,5"
params.run_pft_tracking = false
params.local_min_len = 15
params.local_fa_seeding_mask_threshold = 0.10

}
}

Expand All @@ -147,6 +170,16 @@ nextflow_pipeline {
params.tracking = true
params.infant = true

// ** Infant specific parameters ** //
params.dwi_run_synthstrip = true
params.dwi_normalize_fa_mask_threshold = 0.10
params.fodf_max_fa_threshold = 0.01
params.fodf_min_md_threshold = 0.00185
params.frf_manual_frf = "12,5,5"
params.run_pft_tracking = false
params.local_min_len = 15
params.local_fa_seeding_mask_threshold = 0.10

}
}

Expand All @@ -172,6 +205,7 @@ nextflow_pipeline {

then {
assert workflow.success
assert workflow.trace.tasks().size() == 7
}

}
Expand All @@ -191,6 +225,7 @@ nextflow_pipeline {

then {
assert workflow.success
assert workflow.trace.tasks().size() == 7
}

}
Expand All @@ -209,7 +244,7 @@ nextflow_pipeline {
}

then {
assert workflow.success
assert workflow.failed
assert workflow.stdout.contains("Please provide a trk file for sample: sub-test")
}

Expand All @@ -231,6 +266,7 @@ nextflow_pipeline {

then {
assert workflow.success
assert workflow.trace.tasks().size() == 7
}

}
Expand All @@ -251,6 +287,7 @@ nextflow_pipeline {

then {
assert workflow.success
assert workflow.trace.tasks().size() == 3
}

}
Expand All @@ -272,6 +309,7 @@ nextflow_pipeline {

then {
assert workflow.success
assert workflow.trace.tasks().size() == 9
}

}
Expand All @@ -294,6 +332,7 @@ nextflow_pipeline {

then {
assert workflow.success
assert workflow.trace.tasks().size() == 34
}

}
Expand All @@ -316,6 +355,7 @@ nextflow_pipeline {

then {
assert workflow.success
assert workflow.trace.tasks().size() == 34
}

}
Expand Down Expand Up @@ -347,6 +387,7 @@ nextflow_pipeline {

then {
assert workflow.success
assert workflow.trace.tasks().size() == 35
}

}
Expand Down
52 changes: 52 additions & 0 deletions tests/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,56 @@ process {
memory = 3.GB
time = 2.h
}

withName: 'NF_PEDIATRIC:PEDIATRIC:PREPROC_T1:BETCROP_CROPVOLUME_T1' {
ext.output_bbox = true
}

withName: 'NF_PEDIATRIC:PEDIATRIC:PREPROC_DWI:CROPDWI' {
ext.output_bbox = true
ext.first_suffix = 'dwi'
}

withName: 'NF_PEDIATRIC:PEDIATRIC:PREPROC_DWI:CROPB0' {
ext.first_suffix = 'b0'
}

withName: 'NF_PEDIATRIC:PEDIATRIC:PREPROC_DWI:CROPMASK' {
ext.first_suffix = 'mask'
}

withName: 'NF_PEDIATRIC:PEDIATRIC:PREPROC_DWI:CONVERT' {
ext.first_suffix = 'mask'
ext.datatype = 'uint8'
}

withName: 'NF_PEDIATRIC:PEDIATRIC:PREPROC_DWI:BETCROP_FSLBETCROP' {
ext.crop = true
}

withName: 'NF_PEDIATRIC:PEDIATRIC:PREPROC_DWI:RESAMPLE_DWI' {
ext.first_suffix = 'dwi'
}

withName: 'NF_PEDIATRIC:PEDIATRIC:PREPROC_DWI:RESAMPLE_MASK' {
ext.first_suffix = 'mask'
}

withName: 'NF_PEDIATRIC:PEDIATRIC:RESAMPLE_WMMASK' {
ext.interp = "nn"
}

withName: 'NF_PEDIATRIC:PEDIATRIC:CROPT2' {
ext.output_bbox = true
ext.first_suffix = 't2'
}

withName: 'NF_PEDIATRIC:PEDIATRIC:CROPWMMASK' {
ext.first_suffix = 'wm_mask'
}

withName: 'NF_PEDIATRIC:PEDIATRIC:REGISTRATION_ANTSAPPLYTRANSFORMS' {
ext.first_suffix = "wm_mask"
}

}
Loading

0 comments on commit 8ea6bd5

Please sign in to comment.