From 6a71292967fde89a2afde9f3b9998637ff1b7927 Mon Sep 17 00:00:00 2001 From: Hao-Ting Wang Date: Mon, 3 Jun 2024 11:32:40 -0400 Subject: [PATCH] FIX Address the case of no volumes to scrub when given the scrubbing strategy --- giga_connectome/denoise.py | 8 +++----- giga_connectome/tests/test_denoise.py | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/giga_connectome/denoise.py b/giga_connectome/denoise.py index da7a481..1ae3bc7 100644 --- a/giga_connectome/denoise.py +++ b/giga_connectome/denoise.py @@ -153,11 +153,9 @@ def denoise_meta_data(strategy: STRATEGY_TYPE, img: str) -> METADATA_TYPE: if sample_mask_non_steady is not None else 0 ) - n_scrub = 0 - if "scrubbing" in strategy["parameters"].get( - "denoise_strategy", "" - ) or "srub" in strategy["parameters"].get("strategy", []): - n_scrub = cf.shape[0] - sm.shape[0] - n_non_steady + # sample mask = \ + # number of scan - scrubbed volumes - non steady states + n_scrub = 0 if sm is None else cf.shape[0] - sm.shape[0] - n_non_steady meta_data: METADATA_TYPE = { "ConfoundRegressors": cf.columns.tolist(), diff --git a/giga_connectome/tests/test_denoise.py b/giga_connectome/tests/test_denoise.py index a089456..9e43653 100644 --- a/giga_connectome/tests/test_denoise.py +++ b/giga_connectome/tests/test_denoise.py @@ -13,7 +13,6 @@ def test_denoise_nifti_voxel(): strategy=strategy, img=img_file, ) - assert len(meta_data["ConfoundRegressors"]) == 36 assert meta_data["NumberOfVolumesDiscardedByMotionScrubbing"] == 12 assert meta_data["NumberOfVolumesDiscardedByNonsteadyStatesDetector"] == 2 @@ -26,11 +25,9 @@ def test_denoise_nifti_voxel(): strategy=strategy, img=img_file, ) - assert len(meta_data["ConfoundRegressors"]) == 30 assert meta_data["NumberOfVolumesDiscardedByMotionScrubbing"] == 0 assert meta_data["NumberOfVolumesDiscardedByNonsteadyStatesDetector"] == 2 testing.assert_almost_equal( meta_data["MeanFramewiseDisplacement"], 0.107, decimal=3 ) - print(type(meta_data["NumberOfVolumesDiscardedByMotionScrubbing"]))