Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error when not enough centroids #11

Merged
merged 3 commits into from
Nov 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ workflow.onComplete {
Channel
.fromFilePairs("$params.input/**/bundles/*.trk",
size: -1) { it.parent.parent.name }
.set{bundles_for_rm_invalid}
.into{bundles_for_rm_invalid; in_bundles_check}

Channel
.fromFilePairs("$params.input/**/metrics/*.nii.gz",
Expand All @@ -69,6 +69,18 @@ Channel
in_metrics
.set{metrics_for_rename}


in_bundles_check.map{it[1]}.flatten().count().set{number_bundles_for_compare}
in_centroids_check.map{it[1]}.flatten().count().set{number_centroids_for_compare}

if (params.use_provided_centroids){
number_centroids_for_compare
.concat(number_bundles_for_compare)
.toList()
.subscribe{a, b -> if (a < b)
error "Error ~ You ask the pipeline to use provided centroids but there are less centroids than bundles.\nPlease provide at least a centroid per bundle."}
}

process Rename_Metrics {
input:
set sid, file(metrics) from metrics_for_rename
Expand Down Expand Up @@ -208,7 +220,7 @@ process Bundle_Label_And_Distance_Maps {
bname=\$(basename \$bundle .trk)
fi
bname=\${bname/_ic/}

centroid=${sid}__\${bname}_centroid_${params.nb_points}.trk
scil_compute_bundle_voxel_label_map.py \$bundle \${centroid} \
${sid}__\${bname}_labels.nii.gz \
Expand Down Expand Up @@ -305,11 +317,11 @@ process Lesion_Load {
cd streamlines_stats
scil_merge_json.py *.json ../${sid}__lesion_streamlines_stats.json \
--add_parent_key ${sid}

cd ../lesion_load
scil_merge_json.py *.json ../${sid}__lesion_load.json \
--add_parent_key ${sid}

cd ../lesion_load_per_point
scil_merge_json.py *.json ../${sid}__lesion_load_per_point.json \
--add_parent_key ${sid}
Expand Down