From ba80d07049730ce189a3f31ce9d52145ae761edd Mon Sep 17 00:00:00 2001 From: VincentBeaud Date: Tue, 17 Dec 2024 13:41:03 -0500 Subject: [PATCH] doc and test fix --- scilpy/tractanalysis/fibertube_scoring.py | 10 ++++++---- scripts/scil_fibertube_compute_density.py | 10 ++++++---- scripts/tests/test_fibertube_compute_density.py | 11 ++++++++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/scilpy/tractanalysis/fibertube_scoring.py b/scilpy/tractanalysis/fibertube_scoring.py index 53bc1b23b..3aade91c1 100644 --- a/scilpy/tractanalysis/fibertube_scoring.py +++ b/scilpy/tractanalysis/fibertube_scoring.py @@ -20,10 +20,12 @@ def fibertube_density(sft, samples_per_voxel_axis, verbose=False): Estimates the per-voxel volumetric density of a set of fibertubes. In other words, how much space is occupied by fibertubes and how much is emptiness. - Works by building a binary mask segmenting voxels that contain at least - a single fibertube. Then, valid voxels are finely sampled and we count the - number of samples that landed within a fibertube. For each voxel, this - number is then divided by its total amount of samples. + 1. Segments voxels that contain at least a single fibertube. + 2. Valid voxels are finely sampled and we count the number of samples that + landed within a fibertube. For each voxel, this number is then divided by + its total amount of samples. + 3. By doing the same steps for samples that landed within 2 or more + fibertubes, we can create a density map of the fibertube collisions. Parameters ---------- diff --git a/scripts/scil_fibertube_compute_density.py b/scripts/scil_fibertube_compute_density.py index 0ee95d3fa..5672ad8aa 100755 --- a/scripts/scil_fibertube_compute_density.py +++ b/scripts/scil_fibertube_compute_density.py @@ -5,10 +5,12 @@ Estimates the per-voxel volumetric density of a set of fibertubes. In other words, how much space is occupied by fibertubes and how much is emptiness. -Works by building a binary mask segmenting voxels that contain at least -a single fibertube. Then, valid voxels are finely sampled and we count the -number of samples that landed within a fibertube. For each voxel, this -number is then divided by its total amount of samples. +1. Segments voxels that contain at least a single fibertube. +2. Valid voxels are finely sampled and we count the number of samples that +landed within a fibertube. For each voxel, this number is then divided by +its total amount of samples. +3. By doing the same steps for samples that landed within 2 or more +fibertubes, we can create a density map of the fibertube collisions. See also: - docs/source/documentation/fibertube_tracking.rst diff --git a/scripts/tests/test_fibertube_compute_density.py b/scripts/tests/test_fibertube_compute_density.py index 60f822951..677b7daca 100644 --- a/scripts/tests/test_fibertube_compute_density.py +++ b/scripts/tests/test_fibertube_compute_density.py @@ -42,7 +42,7 @@ def test_help_option(script_runner): assert ret.success -def test_execution(script_runner, monkeypatch): +def test_execution_density(script_runner, monkeypatch): monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) init_data() ret = script_runner.run('scil_fibertube_compute_density.py', @@ -50,6 +50,15 @@ def test_execution(script_runner, monkeypatch): '--out_density_map', 'density_map.nii.gz', '--out_density_measures', 'density_measures.json', + '-f') + assert ret.success + + +def test_execution_collisions(script_runner, monkeypatch): + monkeypatch.chdir(os.path.expanduser(tmp_dir.name)) + init_data() + ret = script_runner.run('scil_fibertube_compute_density.py', + 'fibertubes.trk', '--out_collision_map', 'collision_map.nii.gz', '--out_collision_measures', 'collision_measures.json',