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

Update to scilpy 1.6.0 #22

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Tractometry pipeline

[![GitHub release (latest by date)](https://img.shields.io/github/v/release/scilus/tractometry_flow)](https://github.com/scilus/tractometry_flow/releases)

[![Nextflow](https://img.shields.io/badge/nextflow-21.10.6-brightgreen.svg)](https://www.nextflow.io/)
[![Docker container badge](https://img.shields.io/docker/v/scilus/scilus?label=docker&logo=docker&logoColor=white)](https://hub.docker.com/r/scilus/scilus)

This pipeline allows you to extract tractometry information by combining
subjects's fiber bundles and diffusion MRI metrics.

Expand Down Expand Up @@ -30,15 +33,14 @@ Requirements
Singularity/Docker
-----------
If you are on Linux, we recommend using the Singularity to run tractometry_flow pipeline.
If you have Singularity == 3.*, launch your Nextflow command with:
`-with-singularity scilus/scilus:1.2.0_tractometryflow-1.0.0`
If you have Apptainer (Singularity), launch your Nextflow command with:
`-with-singularity ABSOLUTE_PATH/scilus-1.6.0.sif`

If you have rebuild singularity Singularity == 2.* image is available [here](http://scil.dinf.usherbrooke.ca/en/containers_list/scilus-1.2.0_tractometryflow-1.0.0.img)
Launch your Nextflow command with: `-with-singularity ABSOLUTE_PATH/scilus-1.2.0_tractometryflow-1.0.0.img`
Image is available [here](http://scil.dinf.usherbrooke.ca/en/containers_list/scilus-1.6.0.sif)

If you are on MacOS or Windows, we recommend using the Docker container to run tractometry_flow pipeline.
Launch your Nextflow command with:
`-with-docker scilus/scilus:1.2.0_tractometryflow-1.0.0`
`-with-docker scilus/scilus:1.6.0`

Usage
-----
Expand Down
21 changes: 15 additions & 6 deletions USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ DESCRIPTION

All subjects in the [root] folder must contain
pre-computed centroids if pre-computed centroids
are provided. In other words, you can't mix
are provided. In other words, you can not mix
subjects with and without pre-computed centroids


Expand All @@ -78,13 +78,22 @@ OPTIONAL ARGUMENTS (current value)
--output_dir Directory where to write the final results.
By default, will be in "./results_tractometry"


AVAILABLE PROFILES (using -profile option (e.g. -profile macos, cbrain))
macos When this profile is used, rbx_flow will modify a parameter (scratch) for MacOS users.

cbrain When this profile is used, Nextflow will copy all the output files in publishDir and not use symlinks.


NOTES

The `scilpy/scripts` folder should be in your PATH environment variable
The 'scilpy/scripts' folder should be in your PATH environment variable. Not necessary if the
Singularity container is used.

The intermediate working directory is, by default, set to "./work".
The intermediate working directory is, by default, set to './work'.
To change it, use the '-w WORK_DIR' argument.

Use `-C config_file.config` to specify a non-default configuration file.

If running this on OSX, use `-profile osx` to get the correct shell.
The default config file is tractoflow/nextflow.config.
Use '-C config_file.config' to specify a non-default configuration file.
The '-C config_file.config' must be inserted after the nextflow call
like 'nextflow -C config_file.config run ...'.
61 changes: 31 additions & 30 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 }
.into{bundles_for_rm_invalid; in_bundles_check; bundles_for_fixel_afd}
.into{bundles_for_rm_invalid; in_bundles_check}

Channel
.fromFilePairs("$params.input/**/metrics/*.nii.gz",
Expand Down Expand Up @@ -102,6 +102,32 @@ process Rename_Metrics {
done
"""
}

process Remove_Invalid_Streamlines {
input:
set sid, file(bundles) from bundles_for_rm_invalid

output:
set sid, "${sid}__*_ic.trk" into bundles_for_label_and_distance_map, bundles_for_centroids, bundles_for_fixel_afd

script:
String bundles_list = bundles.join(", ").replace(',', '')
"""
for bundle in $bundles_list;
do if [[ \$bundle == *"__"* ]]; then
pos=\$((\$(echo \$bundle | grep -b -o __ | cut -d: -f1)+2))
bname=\${bundle:\$pos}
bname=\$(basename \$bname .trk)
else
bname=\$(basename \$bundle .trk)
fi
bname=\${bname/$params.bundle_suffix_to_remove/}

scil_remove_invalid_streamlines.py \$bundle ${sid}__\${bname}_ic.trk --remove_single_point --remove_overlapping_points --cut_invalid --no_empty
done
"""
}

bundles_for_fixel_afd
.join(fodf_for_fixel_afd)
.set{bundle_fodf_for_fixel_afd}
Expand Down Expand Up @@ -132,31 +158,6 @@ process Fixel_AFD {
"""
}

process Remove_Invalid_Streamlines {
input:
set sid, file(bundles) from bundles_for_rm_invalid

output:
set sid, "${sid}__*_ic.trk" into bundles_for_label_and_distance_map, bundles_for_centroids optional true

script:
String bundles_list = bundles.join(", ").replace(',', '')
"""
for bundle in $bundles_list;
do if [[ \$bundle == *"__"* ]]; then
pos=\$((\$(echo \$bundle | grep -b -o __ | cut -d: -f1)+2))
bname=\${bundle:\$pos}
bname=\$(basename \$bname .trk)
else
bname=\$(basename \$bundle .trk)
fi
bname=\${bname/$params.bundle_suffix_to_remove/}

scil_remove_invalid_streamlines.py \$bundle ${sid}__\${bname}_ic.trk --remove_single_point --remove_overlapping_points --cut_invalid --no_empty
done
"""
}

process Bundle_Centroid {
input:
set sid, file(bundles) from bundles_for_centroids
Expand Down Expand Up @@ -477,7 +478,7 @@ process Bundle_Metrics_Stats_In_Endpoints {
mv \$map \${bname}_head.nii.gz
mv \${map/_head/_tail} \${bname}_tail.nii.gz

b_metrics=($metrics)
b_metrics="$metrics"
if [[ -f \${bname}_afd_metric.nii.gz ]];
then
mv \${bname}_afd_metric.nii.gz afd_metric.nii.gz
Expand Down Expand Up @@ -531,7 +532,7 @@ process Bundle_Endpoints_Metrics {
bname=\${bname/_uniformized/}
mkdir \${bname}

b_metrics=($metrics)
b_metrics="$metrics"
if [[ -f \${bname}_afd_metric.nii.gz ]];
then
mv \${bname}_afd_metric.nii.gz afd_metric.nii.gz
Expand Down Expand Up @@ -582,7 +583,7 @@ process Bundle_Mean_Std {
bname=\${bname/_uniformized/}
mv \$bundle \$bname.trk

b_metrics=($metrics)
b_metrics="$metrics"
if [[ -f \${bname}_afd_metric.nii.gz ]];
then
mv \${bname}_afd_metric.nii.gz afd_metric.nii.gz
Expand Down Expand Up @@ -720,7 +721,7 @@ process Bundle_Mean_Std_Per_Point {
label_map=${sid}__\${bname}_labels.nii.gz
distance_map=${sid}__\${bname}_distances.nii.gz

b_metrics=($metrics)
b_metrics="$metrics"
if [[ -f \${bname}_afd_metric.nii.gz ]];
then
mv \${bname}_afd_metric.nii.gz afd_metric.nii.gz
Expand Down
6 changes: 6 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,10 @@ profiles {
macos {
process.scratch="/tmp"
}

cbrain {
process{
publishDir = [path: {"./results_rbx/$sid/$task.process"}, mode: 'copy']
}
}
}