Skip to content

Commit

Permalink
FIX Address the case of no volumes to scrub when given the scrubbing …
Browse files Browse the repository at this point in the history
…strategy
  • Loading branch information
htwangtw committed Jun 3, 2024
1 parent e44fca6 commit 6a71292
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 3 additions & 5 deletions giga_connectome/denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
3 changes: 0 additions & 3 deletions giga_connectome/tests/test_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]))

0 comments on commit 6a71292

Please sign in to comment.