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

[ENH] tracking module #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .devcontainer/updateContentCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ cat <<EOF > $XDG_CONFIG_HOME/nf-neuro/.env
# It is sourced by the shell on startup of every terminals.
export PROFILE=docker
export NFCORE_MODULES_GIT_REMOTE=$GIT_REMOTE
export NFCORE_MODULES_GIT_REMOTE="$GIT_REMOTE"
export NFCORE_MODULES_BRANCH=$CURRENT_BRANCH
export NFCORE_SUBWORKFLOWS_GIT_REMOTE=$GIT_REMOTE
export NFCORE_SUBWORKFLOWS_GIT_REMOTE="$GIT_REMOTE"
export NFCORE_SUBWORKFLOWS_BRANCH=$CURRENT_BRANCH
export DEVCONTAINER_RAM_LIMIT_GB=$((maxmem / 1024 / 1024))
Expand Down
28 changes: 16 additions & 12 deletions modules/nf-neuro/tracking/localtracking/main.nf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
process TRACKING_LOCALTRACKING {
tag "$meta.id"
label 'process_single'
label 'process_high_memory'

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(wm), path(fodf), path(fa)
Expand Down Expand Up @@ -39,42 +39,46 @@ process TRACKING_LOCALTRACKING {
def compress = task.ext.local_compress_streamlines ? "--compress " + task.ext.local_compress_value : ""
def basis = task.ext.basis ? "--sh_basis " + task.ext.basis : ""

def gpu_batch_size = task.ext.gpu_batch_size ? "--batch_size " + task.ext.gpu_batch_size : ""
def enable_gpu = task.ext.enable_gpu ? "--use_gpu $gpu_batch_size" : ""

"""
export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1
export OMP_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1

if [ "${local_tracking_mask}" == "wm" ]; then
scil_volume_math.py convert $wm ${prefix}__local_tracking_mask.nii.gz \
--data_type uint8
--data_type uint8 -f

elif [ "${local_tracking_mask}" == "fa" ]; then
scil_volume_math.py lower_threshold $fa \
$local_fa_tracking_mask_threshold \
${prefix}__local_tracking_mask.nii.gz \
--data_type uint8
--data_type uint8 -f
fi

if [ "${local_seeding_mask}" == "wm" ]; then
scil_volume_math.py convert $wm ${prefix}__local_seeding_mask.nii.gz \
--data_type uint8
--data_type uint8 -f

elif [ "${local_seeding_mask}" == "fa" ]; then
scil_volume_math.py lower_threshold $fa \
$local_fa_seeding_mask_threshold \
${prefix}__local_seeding_mask.nii.gz \
--data_type uint8
--data_type uint8 -f
fi

scil_tracking_local.py $fodf ${prefix}__local_seeding_mask.nii.gz ${prefix}__local_tracking_mask.nii.gz tmp.trk\
scil_tracking_local.py $fodf ${prefix}__local_seeding_mask.nii.gz \
${prefix}__local_tracking_mask.nii.gz tmp.trk $enable_gpu\
$local_algo $local_seeding $local_nbr_seeds\
$local_random_seed $local_step $local_theta\
$local_sfthres $local_min_len\
$local_max_len $compress $basis
$local_max_len $compress $basis -f

scil_tractogram_remove_invalid.py tmp.trk\
${prefix}__local_tracking.trk\
--remove_single_point
--remove_single_point -f

cat <<-TRACKING_INFO > ${prefix}__local_tracking_config.json
{"algorithm": "${task.ext.local_algo}",
Expand All @@ -97,7 +101,7 @@ process TRACKING_LOCALTRACKING {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.1
scilpy: 2.0.2
END_VERSIONS
"""

Expand All @@ -115,7 +119,7 @@ process TRACKING_LOCALTRACKING {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.1
scilpy: 2.0.2
END_VERSIONS
"""
}
16 changes: 8 additions & 8 deletions modules/nf-neuro/tracking/localtracking/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
]
],
[
"versions.yml:md5,097efc37ca86414ed8d4836991b634b7"
"versions.yml:md5,0088e7190e395324acbb8fce5c474750"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-05-08T23:46:42.749206"
"timestamp": "2024-10-24T19:38:16.835402429"
},
"tracking - localtracking - fa": {
"content": [
Expand Down Expand Up @@ -70,13 +70,13 @@
]
],
[
"versions.yml:md5,097efc37ca86414ed8d4836991b634b7"
"versions.yml:md5,0088e7190e395324acbb8fce5c474750"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-05-08T23:46:28.766414"
"timestamp": "2024-10-24T19:37:54.047881093"
}
}
20 changes: 10 additions & 10 deletions modules/nf-neuro/tracking/pfttracking/main.nf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

process TRACKING_PFTTRACKING {
tag "$meta.id"
label 'process_single'
label 'process_high_memory'

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(wm), path(gm), path(csf), path(fodf), path(fa)
Expand Down Expand Up @@ -56,28 +56,28 @@ process TRACKING_PFTTRACKING {

if [ "${pft_seeding_mask}" == "wm" ]; then
scil_volume_math.py convert $wm ${prefix}__mask_wm.nii.gz \
--data_type uint8
--data_type uint8 -f
scil_volume_math.py union ${prefix}__mask_wm.nii.gz \
${prefix}__interface.nii.gz ${prefix}__pft_seeding_mask.nii.gz\
--data_type uint8
--data_type uint8 -f

elif [ "${pft_seeding_mask}" == "interface" ]; then
cp ${prefix}__interface.nii.gz ${prefix}__pft_seeding_mask.nii.gz

elif [ "${pft_seeding_mask}" == "fa" ]; then
mrcalc $fa $pft_fa_threshold -ge ${prefix}__pft_seeding_mask.nii.gz\
-datatype uint8
-datatype uint8 -force
fi

scil_tracking_pft.py $fodf ${prefix}__pft_seeding_mask.nii.gz \
${prefix}__map_include.nii.gz ${prefix}__map_exclude.nii.gz tmp.trk\
$pft_algo $pft_seeding_type $pft_nbr_seeds \
$pft_random_seed $pft_step $pft_theta\
$pft_sfthres $pft_sfthres_init $pft_min_len $pft_max_len\
$pft_particles $pft_back $pft_front $compress $basis
$pft_particles $pft_back $pft_front $compress $basis -f

scil_tractogram_remove_invalid.py tmp.trk ${prefix}__pft_tracking.trk\
--remove_single_point
--remove_single_point -f

cat <<-TRACKING_INFO > ${prefix}__pft_tracking_config.json
{"algorithm": "${task.ext.pft_algo}",
Expand All @@ -101,7 +101,7 @@ process TRACKING_PFTTRACKING {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.1
scilpy: 2.0.2
mrtrix: \$(mrcalc -version 2>&1 | sed -n 's/== mrcalc \\([0-9.]\\+\\).*/\\1/p')
END_VERSIONS
"""
Expand All @@ -124,7 +124,7 @@ process TRACKING_PFTTRACKING {

cat <<-END_VERSIONS > versions.yml
"${task.process}":
scilpy: 2.0.1
scilpy: 2.0.2
mrtrix: \$(mrcalc -version 2>&1 | sed -n 's/== mrcalc \\([0-9.]\\+\\).*/\\1/p')
END_VERSIONS
"""
Expand Down
24 changes: 12 additions & 12 deletions modules/nf-neuro/tracking/pfttracking/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
]
],
[
"versions.yml:md5,6fa5c5e21149198626b41120de3947c3"
"versions.yml:md5,2ae3399d07ef00610deae7988357dd55"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-05-08T23:44:48.372791"
"timestamp": "2024-10-24T19:53:53.332859167"
},
"tracking - pfttracking - interface": {
"content": [
Expand Down Expand Up @@ -79,7 +79,7 @@
]
],
[
"versions.yml:md5,6fa5c5e21149198626b41120de3947c3"
"versions.yml:md5,2ae3399d07ef00610deae7988357dd55"
],
[
[
Expand All @@ -92,10 +92,10 @@
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-05-08T23:45:02.333851"
"timestamp": "2024-10-24T19:54:04.257171663"
},
"tracking - pfttracking - wm": {
"content": [
Expand Down Expand Up @@ -137,13 +137,13 @@
]
],
[
"versions.yml:md5,6fa5c5e21149198626b41120de3947c3"
"versions.yml:md5,2ae3399d07ef00610deae7988357dd55"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-05-08T23:44:33.456248"
"timestamp": "2024-10-24T19:53:38.784232647"
}
}