Skip to content

Commit

Permalink
Merge pull request #17 from frheault/hack_single_point
Browse files Browse the repository at this point in the history
Hack to avoid crashing on single point centroids
  • Loading branch information
arnaudbore authored Mar 30, 2023
2 parents 36e43ee + f2053c3 commit e5fc56b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if (params.use_provided_centroids){
number_centroids_for_compare
.concat(number_bundles_for_compare)
.toList()
.subscribe{a, b -> if (a < b)
.subscribe{a, b -> if (a == 0)
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."}
}

Expand Down Expand Up @@ -209,9 +209,9 @@ process Resample_Centroid {
bname=\${bname/_centroid/}
bname=\${bname/_ic/}
scil_resample_streamlines.py \$bundle \
echo \$(scil_resample_streamlines.py \$bundle \
"${sid}__\${bname}_centroid_${params.nb_points}.trk" \
--nb_pts_per_streamline $params.nb_points -f
--nb_pts_per_streamline $params.nb_points -f)
done
"""
}
Expand Down Expand Up @@ -256,15 +256,17 @@ process Bundle_Label_And_Distance_Maps {
bname=\${bname/_ic/}
centroid=${sid}__\${bname}_centroid_${params.nb_points}.trk
scil_compute_bundle_voxel_label_map.py \$bundle \${centroid} tmp_out\
--min_streamline_count ${params.min_streamline_count} \
--min_voxel_count ${params.min_voxel_count} -f
mv tmp_out/labels_map.nii.gz ${sid}__\${bname}_labels.nii.gz
mv tmp_out/distance_map.nii.gz ${sid}__\${bname}_distances.nii.gz
mv tmp_out/labels.trk ${sid}__\${bname}_labels.trk
mv tmp_out/distance.trk ${sid}__\${bname}_distances.trk
if [[ -f \${centroid} ]]; then
scil_compute_bundle_voxel_label_map.py \$bundle \${centroid} tmp_out\
--min_streamline_count ${params.min_streamline_count} \
--min_voxel_count ${params.min_voxel_count} -f
mv tmp_out/labels_map.nii.gz ${sid}__\${bname}_labels.nii.gz
mv tmp_out/distance_map.nii.gz ${sid}__\${bname}_distances.nii.gz
mv tmp_out/labels.trk ${sid}__\${bname}_labels.trk
mv tmp_out/distance.trk ${sid}__\${bname}_distances.trk
fi
done
"""
Expand Down

0 comments on commit e5fc56b

Please sign in to comment.