From c9c78bb356441f4a72b501f3cc23eb350cace2b9 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Wed, 31 Jul 2024 21:01:09 +0000 Subject: [PATCH 1/3] add option lesions to bundle stats --- modules/nf-scil/bundle/stats/main.nf | 62 ++++- modules/nf-scil/bundle/stats/meta.yml | 30 +++ .../nf-scil/bundle/stats/tests/main.nf.test | 34 ++- .../bundle/stats/tests/main.nf.test.snap | 219 +++++++++++++++--- .../stats/tests/nextflow_lesions.config | 15 ++ 5 files changed, 315 insertions(+), 45 deletions(-) create mode 100644 modules/nf-scil/bundle/stats/tests/nextflow_lesions.config diff --git a/modules/nf-scil/bundle/stats/main.nf b/modules/nf-scil/bundle/stats/main.nf index 7d92f0d9..2ff2daba 100644 --- a/modules/nf-scil/bundle/stats/main.nf +++ b/modules/nf-scil/bundle/stats/main.nf @@ -7,20 +7,25 @@ process BUNDLE_STATS { 'scilus/scilus:2.0.2' }" input: - tuple val(meta), path(bundles), path(labels_map), path(metrics) + tuple val(meta), path(bundles), path(labels_map), path(metrics), path(lesions) output: - tuple val(meta), path("*_length_stats.json") , emit: length, optional: true - tuple val(meta), path("*_endpoints_map_raw.json") , emit: endpoints_raw, optional: true - tuple val(meta), path("*_endpoints_metric_stats.json") , emit: endpoints_metric_stats, optional: true - tuple val(meta), path("*_mean_std.json") , emit: mean_std, optional: true - tuple val(meta), path("*_volume.json") , emit: volume, optional: true - tuple val(meta), path("*_streamline_count.json") , emit: streamline_count, optional: true - tuple val(meta), path("*_volume_per_label.json") , emit: volume_per_labels, optional: true - tuple val(meta), path("*_mean_std_per_point.json") , emit: mean_std_per_point, optional: true - tuple val(meta), path("*_endpoints_map_head.nii.gz") , emit: endpoints_head, optional: true - tuple val(meta), path("*_endpoints_map_tail.nii.gz") , emit: endpoints_tail, optional: true - path "versions.yml" , emit: versions + tuple val(meta), path("*_length_stats.json") , emit: length, optional: true + tuple val(meta), path("*_endpoints_map_raw.json") , emit: endpoints_raw, optional: true + tuple val(meta), path("*_endpoints_metric_stats.json") , emit: endpoints_metric_stats, optional: true + tuple val(meta), path("*_mean_std.json") , emit: mean_std, optional: true + tuple val(meta), path("*_volume.json") , emit: volume, optional: true + tuple val(meta), path("*_volume_lesions.json") , emit: volume_lesions, optional: true + tuple val(meta), path("*_streamline_count.json") , emit: streamline_count, optional: true + tuple val(meta), path("*_streamline_count_lesions.json") , emit: streamline_count_lesions, optional: true + tuple val(meta), path("*_volume_per_label.json") , emit: volume_per_labels, optional: true + tuple val(meta), path("*_volume_per_label_lesions.json") , emit: volume_per_labels_lesions, optional: true + tuple val(meta), path("*_mean_std_per_point.json") , emit: mean_std_per_point, optional: true + tuple val(meta), path("*__lesion_stats.json") , emit: lesion_stats, optional: true + tuple val(meta), path("*_endpoints_map_head.nii.gz") , emit: endpoints_head, optional: true + tuple val(meta), path("*_endpoints_map_tail.nii.gz") , emit: endpoints_tail, optional: true + tuple val(meta), path("*_lesion_map.nii.gz") , emit: lesion_map, optional: true + path "versions.yml" , emit: versions when: task.ext.when == null || task.ext.when @@ -34,6 +39,8 @@ process BUNDLE_STATS { def endpoints = task.ext.endpoints ?: "" def mean_std = task.ext.mean_std ?: "" def volume = task.ext.volume ?: "" + def lesions_stats = task.ext.lesions_stats ?: "" + def min_lesion_vol = task.ext.min_lesion_vol ?: "" def streamline_count = task.ext.streamline_count ?: "" def volume_per_labels = task.ext.volume_per_labels ?: "" def mean_std_per_point = task.ext.mean_std_per_point ?: "" @@ -76,6 +83,14 @@ process BUNDLE_STATS { then scil_bundle_shape_measures.py \${bundles[index]} > \${bname}_volume_stat.json + if [[ "$lesions_stats" ]]; + then + scil_lesions_info.py $lesions \${bname}_volume_lesions_stat.json \ + --bundle \${bundles[index]} --out_lesion_stats ${prefix}__lesion_stats.json \ + --out_streamlines_stats \${bname}_streamline_count_lesions_stat.json \ + --min_lesion_vol $min_lesion_vol -f + fi + elif [[ "$streamline_count" ]]; then scil_tractogram_count_streamlines.py \${bundles[index]} > \${bname}_streamlines.json @@ -85,6 +100,14 @@ process BUNDLE_STATS { then scil_bundle_volume_per_label.py \${label_map[index]} \$bname --sort_keys >\ \${bname}_volume_label.json + + if [[ "$lesions_stats" ]]; + then + scil_analyse_lesions_load.py $lesions \$bname_volume_per_label_lesions_stat.json \ + --bundle_labels_map \${label_map[index]} \ + --out_lesion_atlas "${prefix}__\${bundles[index]}_lesion_map.nii.gz" \ + --min_lesion_vol $min_lesion_vol + fi fi if [[ "$mean_std_per_point" ]]; @@ -125,6 +148,15 @@ process BUNDLE_STATS { then scil_json_merge_entries.py *_volume_stat.json ${prefix}_volume.json --no_list --add_parent_key ${prefix} + if [[ "$lesions_stats" ]]; + then + scil_json_merge_entries.py *_volume_lesions_stat.json ${prefix}_volume_lesions.json --no_list --add_parent_key ${prefix} + scil_json_merge_entries.py *_streamline_count_lesions_stat.json ${prefix}_streamline_count_lesions.json \ + --no_list --add_parent_key ${prefix} + scil_merge_json.py ${prefix}__lesion_stats.json ${prefix}__lesion_stats.json \ + --remove_parent_key --add_parent_key ${prefix} -f + fi + #Bundle_Streamline_Count elif [[ "$streamline_count" ]]; then @@ -137,6 +169,12 @@ process BUNDLE_STATS { then scil_json_merge_entries.py *_volume_label.json ${prefix}_volume_per_label.json --no_list \ --add_parent_key ${prefix} + + if [[ "$lesions_stats" ]]; + then + scil_json_merge_entries.py *_volume_per_label_lesions_stat.json ${prefix}_volume_per_label_lesions.json \ + --no_list --add_parent_key ${prefix} + fi fi #Bundle_Mean_Std_Per_Point diff --git a/modules/nf-scil/bundle/stats/meta.yml b/modules/nf-scil/bundle/stats/meta.yml index 3df58f8b..25761372 100644 --- a/modules/nf-scil/bundle/stats/meta.yml +++ b/modules/nf-scil/bundle/stats/meta.yml @@ -76,6 +76,11 @@ input: The metrics has to follow a specific naming convention. pattern: "*_{bundle_name}_{metric_name}.nii.gz" + - lesions: + type: file + description: Nifti lesion volume to compute statistics on. The lesion mask must be a binary mask. + pattern: "*.nii.gz" + output: - meta: type: map @@ -108,21 +113,41 @@ output: description: Evaluate basic measurements of bundle(s). pattern: "*__volume.json" + - volume_lesions: + type: file + description: Compute bundle volume in each lesions in mm3. + pattern: "*__volume_lesion.json" + - streamline_count: type: file description: Return the number of streamlines in a tractogram. pattern: "*__streamline_count.json" + - streamline_count_lesions: + type: file + description: Return the number of streamlines in each lesions. + pattern: "*__streamline_count_lesions.json" + - volume_per_labels: type: file description: Compute bundle volume per label in mm3. This script supports anisotropic voxels resolution. Volume is estimated by counting the number of voxel occupied by each label and multiplying it by the volume of a single voxel. pattern: "*__volume_per_label.json" + - volume_per_labels_lesions: + type: file + description: Compute bundle volume per label in each lesions in mm3. + pattern: "*__volume_per_label_lesions.json" + - mean_std_per_point: type: file description: Average the metric values of all voxels occupied by the bundle per label. pattern: "*__mean_std_per_point.json" + - lesion_stats: + type: file + description: File of the lesion-wise volume measure. + pattern: "*_lesion_stats.json" + - endpoints_head: type: file description: Endpoint head map of bundle. The endpoint head map is simply a count of the number of streamlines that start in each voxel. @@ -133,6 +158,11 @@ output: description: Endpoint tail map of bundle. The endpoint tail map is simply a count of the number of streamlines that end in each voxel. pattern: "*.nii.gz" + - lesion_map: + type: file + description: Nifti files of labelized lesion(s) map for each bundles. + pattern: "*.nii.gz" + - versions: type: file description: File containing software versions diff --git a/modules/nf-scil/bundle/stats/tests/main.nf.test b/modules/nf-scil/bundle/stats/tests/main.nf.test index 9f8677cb..e7662ff8 100644 --- a/modules/nf-scil/bundle/stats/tests/main.nf.test +++ b/modules/nf-scil/bundle/stats/tests/main.nf.test @@ -25,9 +25,7 @@ nextflow_process { } test("bundle - stats") { - config "./nextflow.config" - when { process { """ @@ -36,12 +34,12 @@ nextflow_process { [ id:'test', single_end:false ], // meta map file("\${test_data_directory}/IFGWM.trk"), file("\${test_data_directory}/IFGWM_labels_map.nii.gz"), - file("\${test_data_directory}/mni_masked.nii.gz") + file("\${test_data_directory}/mni_masked.nii.gz"), + [] ]} """ } } - then { assertAll( { assert process.success }, @@ -51,9 +49,7 @@ nextflow_process { } test("bundle - stats - light") { - config "./nextflow_light.config" - when { process { """ @@ -62,12 +58,36 @@ nextflow_process { [ id:'test', single_end:false ], // meta map file("\${test_data_directory}/IFGWM{,_color}.trk"), file("\${test_data_directory}/IFGWM{_labels_map,}.nii.gz"), - file("\${test_data_directory}/mni_masked.nii.gz") + file("\${test_data_directory}/mni_masked.nii.gz"), + [] ]} """ } } + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + test("bundle - stats - lesions") { + config "./nextflow_lesions.config" + when { + process { + """ + input[0] = LOAD_DATA.out.test_data_directory.map{ + test_data_directory -> [ + [ id:'test', single_end:false ], // meta map + file("\${test_data_directory}/IFGWM{,_color}.trk",), + file("\${test_data_directory}/IFGWM{_labels_map,}.nii.gz"), + file("\${test_data_directory}/mni_masked.nii.gz"), + file("\${test_data_directory}/IFGWM{}.nii.gz") + ]} + """ + } + } then { assertAll( { assert process.success }, diff --git a/modules/nf-scil/bundle/stats/tests/main.nf.test.snap b/modules/nf-scil/bundle/stats/tests/main.nf.test.snap index b171d2ff..4cd73edb 100644 --- a/modules/nf-scil/bundle/stats/tests/main.nf.test.snap +++ b/modules/nf-scil/bundle/stats/tests/main.nf.test.snap @@ -1,4 +1,111 @@ { + "bundle - stats - lesions": { + "content": [ + { + "0": [ + + ], + "1": [ + + ], + "10": [ + + ], + "11": [ + + ], + "12": [ + + ], + "13": [ + + ], + "14": [ + + ], + "15": [ + + ], + "2": [ + + ], + "3": [ + + ], + "4": [ + + ], + "5": [ + + ], + "6": [ + + ], + "7": [ + + ], + "8": [ + + ], + "9": [ + + ], + "endpoints_head": [ + + ], + "endpoints_metric_stats": [ + + ], + "endpoints_raw": [ + + ], + "endpoints_tail": [ + + ], + "length": [ + + ], + "lesion_map": [ + + ], + "lesion_stats": [ + + ], + "mean_std": [ + + ], + "mean_std_per_point": [ + + ], + "streamline_count": [ + + ], + "streamline_count_lesions": [ + + ], + "versions": [ + + ], + "volume": [ + + ], + "volume_lesions": [ + + ], + "volume_per_labels": [ + + ], + "volume_per_labels_lesions": [ + + ] + } + ], + "meta": { + "nf-test": "0.9.0-rc1", + "nextflow": "24.04.3" + }, + "timestamp": "2024-07-31T20:54:54.296906" + }, "bundle - stats": { "content": [ { @@ -21,73 +128,88 @@ ] ], "10": [ - "versions.yml:md5,c22283763660c5778cdd9c34c64200bd" - ], - "2": [ [ { "id": "test", "single_end": false }, - "test_endpoints_metric_stats.json:md5,d13e29a5d9dd09e8b5a2d40b3b61b3a9" + "test_mean_std_per_point.json:md5,efcac000fb6c0f607b7377154e68854c" ] ], - "3": [ + "11": [ + + ], + "12": [ [ { "id": "test", "single_end": false }, - "test_mean_std.json:md5,f7463e5519063f7e0f32709d0dfdc1a2" + "IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" ] ], - "4": [ + "13": [ [ { "id": "test", "single_end": false }, - "test_volume.json:md5,f2cf5bbf678b0d364f26120ad10900ae" + "IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" ] ], - "5": [ + "14": [ ], - "6": [ + "15": [ + "versions.yml:md5,c22283763660c5778cdd9c34c64200bd" + ], + "2": [ [ { "id": "test", "single_end": false }, - "test_volume_per_label.json:md5,1ba8e9d51cc2dec86fdaa4498488424b" + "test_endpoints_metric_stats.json:md5,d13e29a5d9dd09e8b5a2d40b3b61b3a9" ] ], - "7": [ + "3": [ [ { "id": "test", "single_end": false }, - "test_mean_std_per_point.json:md5,efcac000fb6c0f607b7377154e68854c" + "test_mean_std.json:md5,f7463e5519063f7e0f32709d0dfdc1a2" ] ], - "8": [ + "4": [ [ { "id": "test", "single_end": false }, - "IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" + "test_volume.json:md5,f2cf5bbf678b0d364f26120ad10900ae" ] ], - "9": [ + "5": [ + + ], + "6": [ + + ], + "7": [ + + ], + "8": [ [ { "id": "test", "single_end": false }, - "IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" + "test_volume_per_label.json:md5,1ba8e9d51cc2dec86fdaa4498488424b" ] + ], + "9": [ + ], "endpoints_head": [ [ @@ -133,6 +255,12 @@ }, "test_length_stats.json:md5,72873da12072e254f369ec316911df28" ] + ], + "lesion_map": [ + + ], + "lesion_stats": [ + ], "mean_std": [ [ @@ -154,6 +282,9 @@ ], "streamline_count": [ + ], + "streamline_count_lesions": [ + ], "versions": [ "versions.yml:md5,c22283763660c5778cdd9c34c64200bd" @@ -166,6 +297,9 @@ }, "test_volume.json:md5,f2cf5bbf678b0d364f26120ad10900ae" ] + ], + "volume_lesions": [ + ], "volume_per_labels": [ [ @@ -175,14 +309,17 @@ }, "test_volume_per_label.json:md5,1ba8e9d51cc2dec86fdaa4498488424b" ] + ], + "volume_per_labels_lesions": [ + ] } ], "meta": { - "nf-test": "0.8.4", - "nextflow": "23.10.1" + "nf-test": "0.9.0-rc1", + "nextflow": "24.04.3" }, - "timestamp": "2024-06-12T14:39:41.886782" + "timestamp": "2024-07-31T20:52:19.29951" }, "bundle - stats - light": { "content": [ @@ -194,6 +331,21 @@ ], "10": [ + + ], + "11": [ + + ], + "12": [ + + ], + "13": [ + + ], + "14": [ + + ], + "15": [ "versions.yml:md5,c22283763660c5778cdd9c34c64200bd" ], "2": [ @@ -206,6 +358,9 @@ ], "5": [ + + ], + "6": [ [ { "id": "test", @@ -213,9 +368,6 @@ }, "test_streamline_count.json:md5,bedf1fbd223dd47d9a8970dc779f296f" ] - ], - "6": [ - ], "7": [ @@ -240,6 +392,12 @@ ], "length": [ + ], + "lesion_map": [ + + ], + "lesion_stats": [ + ], "mean_std": [ @@ -255,22 +413,31 @@ }, "test_streamline_count.json:md5,bedf1fbd223dd47d9a8970dc779f296f" ] + ], + "streamline_count_lesions": [ + ], "versions": [ "versions.yml:md5,c22283763660c5778cdd9c34c64200bd" ], "volume": [ + ], + "volume_lesions": [ + ], "volume_per_labels": [ + ], + "volume_per_labels_lesions": [ + ] } ], "meta": { - "nf-test": "0.8.4", - "nextflow": "23.10.1" + "nf-test": "0.9.0-rc1", + "nextflow": "24.04.3" }, - "timestamp": "2024-06-12T14:39:53.476493" + "timestamp": "2024-07-31T20:52:29.344762" } } \ No newline at end of file diff --git a/modules/nf-scil/bundle/stats/tests/nextflow_lesions.config b/modules/nf-scil/bundle/stats/tests/nextflow_lesions.config new file mode 100644 index 00000000..69bad23a --- /dev/null +++ b/modules/nf-scil/bundle/stats/tests/nextflow_lesions.config @@ -0,0 +1,15 @@ +process { + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + withName: "BUNDLE_STATS" { + ext.density_weighting = true + ext.normalize_weights = true + ext.length_stats = true + ext.endpoints = true + ext.mean_std = true + ext.volume = true + ext.volume_per_labels = true + ext.mean_std_per_point = true + ext.lesions_stats = true + ext.min_lesion_vol = 7 + } +} From 02338f8024ad178c3a1041b5e6ca4656b182a61e Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Thu, 1 Aug 2024 13:49:04 +0000 Subject: [PATCH 2/3] correction lesions test snap --- modules/nf-scil/bundle/stats/main.nf | 2 +- .../nf-scil/bundle/stats/tests/main.nf.test | 6 +- .../bundle/stats/tests/main.nf.test.snap | 234 +++++++++++++++--- 3 files changed, 205 insertions(+), 37 deletions(-) diff --git a/modules/nf-scil/bundle/stats/main.nf b/modules/nf-scil/bundle/stats/main.nf index 2ff2daba..25918308 100644 --- a/modules/nf-scil/bundle/stats/main.nf +++ b/modules/nf-scil/bundle/stats/main.nf @@ -103,7 +103,7 @@ process BUNDLE_STATS { if [[ "$lesions_stats" ]]; then - scil_analyse_lesions_load.py $lesions \$bname_volume_per_label_lesions_stat.json \ + scil_analyse_lesions_load.py $lesions \${bname}_volume_per_label_lesions_stat.json \ --bundle_labels_map \${label_map[index]} \ --out_lesion_atlas "${prefix}__\${bundles[index]}_lesion_map.nii.gz" \ --min_lesion_vol $min_lesion_vol diff --git a/modules/nf-scil/bundle/stats/tests/main.nf.test b/modules/nf-scil/bundle/stats/tests/main.nf.test index e7662ff8..d402ce68 100644 --- a/modules/nf-scil/bundle/stats/tests/main.nf.test +++ b/modules/nf-scil/bundle/stats/tests/main.nf.test @@ -80,10 +80,10 @@ nextflow_process { input[0] = LOAD_DATA.out.test_data_directory.map{ test_data_directory -> [ [ id:'test', single_end:false ], // meta map - file("\${test_data_directory}/IFGWM{,_color}.trk",), - file("\${test_data_directory}/IFGWM{_labels_map,}.nii.gz"), + file("\${test_data_directory}/IFGWM.trk",), + file("\${test_data_directory}/IFGWM_labels_map.nii.gz"), file("\${test_data_directory}/mni_masked.nii.gz"), - file("\${test_data_directory}/IFGWM{}.nii.gz") + file("\${test_data_directory}/IFGWM.nii.gz") ]} """ } diff --git a/modules/nf-scil/bundle/stats/tests/main.nf.test.snap b/modules/nf-scil/bundle/stats/tests/main.nf.test.snap index 4cd73edb..511b2c67 100644 --- a/modules/nf-scil/bundle/stats/tests/main.nf.test.snap +++ b/modules/nf-scil/bundle/stats/tests/main.nf.test.snap @@ -3,100 +3,268 @@ "content": [ { "0": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_length_stats.json:md5,72873da12072e254f369ec316911df28" + ] ], "1": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_endpoints_map_raw.json:md5,2a86a4d10878c942c09723c3122940b4" + ] ], "10": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_mean_std_per_point.json:md5,efcac000fb6c0f607b7377154e68854c" + ] ], "11": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__lesion_stats.json:md5,cefff165378a416816c1c7a644c4969c" + ] ], "12": [ - + [ + { + "id": "test", + "single_end": false + }, + "IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" + ] ], "13": [ - + [ + { + "id": "test", + "single_end": false + }, + "IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" + ] ], "14": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__IFGWM.trk_lesion_map.nii.gz:md5,390c8abfcfa2533367099c9fac26ee21" + ] ], "15": [ - + "versions.yml:md5,c22283763660c5778cdd9c34c64200bd" ], "2": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_endpoints_metric_stats.json:md5,d13e29a5d9dd09e8b5a2d40b3b61b3a9" + ] ], "3": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_mean_std.json:md5,f7463e5519063f7e0f32709d0dfdc1a2" + ] ], "4": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_volume.json:md5,f2cf5bbf678b0d364f26120ad10900ae" + ] ], "5": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_volume_lesions.json:md5,6221f9954d93904de992d5b7af99bcce" + ] ], "6": [ ], "7": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_streamline_count_lesions.json:md5,08433569dd80f6b1dd53193e7cf446d6" + ] ], "8": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_volume_per_label.json:md5,1ba8e9d51cc2dec86fdaa4498488424b" + ] ], "9": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_volume_per_label_lesions.json:md5,b9138245af55e3becd3c9e2bec2c9821" + ] ], "endpoints_head": [ - + [ + { + "id": "test", + "single_end": false + }, + "IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" + ] ], "endpoints_metric_stats": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_endpoints_metric_stats.json:md5,d13e29a5d9dd09e8b5a2d40b3b61b3a9" + ] ], "endpoints_raw": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_endpoints_map_raw.json:md5,2a86a4d10878c942c09723c3122940b4" + ] ], "endpoints_tail": [ - + [ + { + "id": "test", + "single_end": false + }, + "IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" + ] ], "length": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_length_stats.json:md5,72873da12072e254f369ec316911df28" + ] ], "lesion_map": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__IFGWM.trk_lesion_map.nii.gz:md5,390c8abfcfa2533367099c9fac26ee21" + ] ], "lesion_stats": [ - + [ + { + "id": "test", + "single_end": false + }, + "test__lesion_stats.json:md5,cefff165378a416816c1c7a644c4969c" + ] ], "mean_std": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_mean_std.json:md5,f7463e5519063f7e0f32709d0dfdc1a2" + ] ], "mean_std_per_point": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_mean_std_per_point.json:md5,efcac000fb6c0f607b7377154e68854c" + ] ], "streamline_count": [ ], "streamline_count_lesions": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_streamline_count_lesions.json:md5,08433569dd80f6b1dd53193e7cf446d6" + ] ], "versions": [ - + "versions.yml:md5,c22283763660c5778cdd9c34c64200bd" ], "volume": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_volume.json:md5,f2cf5bbf678b0d364f26120ad10900ae" + ] ], "volume_lesions": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_volume_lesions.json:md5,6221f9954d93904de992d5b7af99bcce" + ] ], "volume_per_labels": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_volume_per_label.json:md5,1ba8e9d51cc2dec86fdaa4498488424b" + ] ], "volume_per_labels_lesions": [ - + [ + { + "id": "test", + "single_end": false + }, + "test_volume_per_label_lesions.json:md5,b9138245af55e3becd3c9e2bec2c9821" + ] ] } ], @@ -104,7 +272,7 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.3" }, - "timestamp": "2024-07-31T20:54:54.296906" + "timestamp": "2024-08-01T13:47:29.33467" }, "bundle - stats": { "content": [ @@ -319,7 +487,7 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.3" }, - "timestamp": "2024-07-31T20:52:19.29951" + "timestamp": "2024-08-01T13:42:36.266056" }, "bundle - stats - light": { "content": [ @@ -438,6 +606,6 @@ "nf-test": "0.9.0-rc1", "nextflow": "24.04.3" }, - "timestamp": "2024-07-31T20:52:29.344762" + "timestamp": "2024-08-01T13:42:46.785058" } } \ No newline at end of file From 89714a0f8b241fb67c10c2def1e00ae5598c4703 Mon Sep 17 00:00:00 2001 From: Thoumyre Stanislas Date: Tue, 3 Sep 2024 15:26:49 +0000 Subject: [PATCH 3/3] fix Alex's changes --- modules/nf-scil/bundle/stats/main.nf | 18 +++++----- .../bundle/stats/tests/main.nf.test.snap | 36 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/modules/nf-scil/bundle/stats/main.nf b/modules/nf-scil/bundle/stats/main.nf index 25918308..ed5799f7 100644 --- a/modules/nf-scil/bundle/stats/main.nf +++ b/modules/nf-scil/bundle/stats/main.nf @@ -62,13 +62,13 @@ process BUNDLE_STATS { if [[ "$endpoints" ]]; then scil_bundle_compute_endpoints_map.py \${bundles[index]} \ - \${bname}_endpoints_map_head.nii.gz \ - \${bname}_endpoints_map_tail.nii.gz >\ + ${prefix}__\${bname}_endpoints_map_head.nii.gz \ + ${prefix}__\${bname}_endpoints_map_tail.nii.gz >\ ${prefix}__\${bname}_endpoints_raw.json; - scil_volume_stats_in_ROI.py \${bname}_endpoints_map_head.nii.gz $normalize_weights\ + scil_volume_stats_in_ROI.py ${prefix}__\${bname}_endpoints_map_head.nii.gz $normalize_weights\ --metrics \${b_metrics} > \${bname}_head.json - scil_volume_stats_in_ROI.py \${bname}_endpoints_map_tail.nii.gz $normalize_weights\ + scil_volume_stats_in_ROI.py ${prefix}__\${bname}_endpoints_map_tail.nii.gz $normalize_weights\ --metrics \${b_metrics} > \${bname}_tail.json; fi @@ -89,7 +89,7 @@ process BUNDLE_STATS { --bundle \${bundles[index]} --out_lesion_stats ${prefix}__lesion_stats.json \ --out_streamlines_stats \${bname}_streamline_count_lesions_stat.json \ --min_lesion_vol $min_lesion_vol -f - fi + fi elif [[ "$streamline_count" ]]; then @@ -105,9 +105,9 @@ process BUNDLE_STATS { then scil_analyse_lesions_load.py $lesions \${bname}_volume_per_label_lesions_stat.json \ --bundle_labels_map \${label_map[index]} \ - --out_lesion_atlas "${prefix}__\${bundles[index]}_lesion_map.nii.gz" \ + --out_lesion_atlas "${prefix}__\${bname}_lesion_map.nii.gz" \ --min_lesion_vol $min_lesion_vol - fi + fi fi if [[ "$mean_std_per_point" ]]; @@ -172,8 +172,8 @@ process BUNDLE_STATS { if [[ "$lesions_stats" ]]; then - scil_json_merge_entries.py *_volume_per_label_lesions_stat.json ${prefix}_volume_per_label_lesions.json \ - --no_list --add_parent_key ${prefix} + scil_json_merge_entries.py *_volume_per_label_lesions_stat.json ${prefix}_volume_per_label_lesions.json \ + --no_list --add_parent_key ${prefix} fi fi diff --git a/modules/nf-scil/bundle/stats/tests/main.nf.test.snap b/modules/nf-scil/bundle/stats/tests/main.nf.test.snap index 511b2c67..94aa4fbc 100644 --- a/modules/nf-scil/bundle/stats/tests/main.nf.test.snap +++ b/modules/nf-scil/bundle/stats/tests/main.nf.test.snap @@ -44,7 +44,7 @@ "id": "test", "single_end": false }, - "IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" + "test__IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" ] ], "13": [ @@ -53,7 +53,7 @@ "id": "test", "single_end": false }, - "IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" + "test__IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" ] ], "14": [ @@ -62,7 +62,7 @@ "id": "test", "single_end": false }, - "test__IFGWM.trk_lesion_map.nii.gz:md5,390c8abfcfa2533367099c9fac26ee21" + "test__IFGWM_lesion_map.nii.gz:md5,390c8abfcfa2533367099c9fac26ee21" ] ], "15": [ @@ -74,7 +74,7 @@ "id": "test", "single_end": false }, - "test_endpoints_metric_stats.json:md5,d13e29a5d9dd09e8b5a2d40b3b61b3a9" + "test_endpoints_metric_stats.json:md5,3a0fef22a945c74ae4792a5de818acff" ] ], "3": [ @@ -140,7 +140,7 @@ "id": "test", "single_end": false }, - "IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" + "test__IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" ] ], "endpoints_metric_stats": [ @@ -149,7 +149,7 @@ "id": "test", "single_end": false }, - "test_endpoints_metric_stats.json:md5,d13e29a5d9dd09e8b5a2d40b3b61b3a9" + "test_endpoints_metric_stats.json:md5,3a0fef22a945c74ae4792a5de818acff" ] ], "endpoints_raw": [ @@ -167,7 +167,7 @@ "id": "test", "single_end": false }, - "IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" + "test__IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" ] ], "length": [ @@ -185,7 +185,7 @@ "id": "test", "single_end": false }, - "test__IFGWM.trk_lesion_map.nii.gz:md5,390c8abfcfa2533367099c9fac26ee21" + "test__IFGWM_lesion_map.nii.gz:md5,390c8abfcfa2533367099c9fac26ee21" ] ], "lesion_stats": [ @@ -270,9 +270,9 @@ ], "meta": { "nf-test": "0.9.0-rc1", - "nextflow": "24.04.3" + "nextflow": "24.04.4" }, - "timestamp": "2024-08-01T13:47:29.33467" + "timestamp": "2024-09-03T15:23:58.700174" }, "bundle - stats": { "content": [ @@ -313,7 +313,7 @@ "id": "test", "single_end": false }, - "IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" + "test__IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" ] ], "13": [ @@ -322,7 +322,7 @@ "id": "test", "single_end": false }, - "IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" + "test__IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" ] ], "14": [ @@ -337,7 +337,7 @@ "id": "test", "single_end": false }, - "test_endpoints_metric_stats.json:md5,d13e29a5d9dd09e8b5a2d40b3b61b3a9" + "test_endpoints_metric_stats.json:md5,3a0fef22a945c74ae4792a5de818acff" ] ], "3": [ @@ -385,7 +385,7 @@ "id": "test", "single_end": false }, - "IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" + "test__IFGWM_endpoints_map_head.nii.gz:md5,444b8e3e40f4694b84a1fb5a2be8a52f" ] ], "endpoints_metric_stats": [ @@ -394,7 +394,7 @@ "id": "test", "single_end": false }, - "test_endpoints_metric_stats.json:md5,d13e29a5d9dd09e8b5a2d40b3b61b3a9" + "test_endpoints_metric_stats.json:md5,3a0fef22a945c74ae4792a5de818acff" ] ], "endpoints_raw": [ @@ -412,7 +412,7 @@ "id": "test", "single_end": false }, - "IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" + "test__IFGWM_endpoints_map_tail.nii.gz:md5,a4cb0339f71c17a8703e920e0eb4916a" ] ], "length": [ @@ -485,9 +485,9 @@ ], "meta": { "nf-test": "0.9.0-rc1", - "nextflow": "24.04.3" + "nextflow": "24.04.4" }, - "timestamp": "2024-08-01T13:42:36.266056" + "timestamp": "2024-09-03T15:23:19.265407" }, "bundle - stats - light": { "content": [