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

[FIX] Fix bug in filtering by bval, where b0 calculation used mismatched dwi and gtab #1158

Merged
merged 1 commit into from
Aug 29, 2024
Merged
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
10 changes: 4 additions & 6 deletions AFQ/tasks/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,13 @@ def get_data_gtab(dwi_data_file, bval_file, bvec_file, min_bval=None,

@pimms.calc("b0")
@as_file('_desc-b0_dwi.nii.gz')
def b0(dwi_data_file, gtab):
def b0(dwi, gtab):
"""
full path to a nifti file containing the mean b0
"""
data = nib.load(dwi_data_file)
mean_b0 = np.mean(data.get_fdata()[..., gtab.b0s_mask], -1)
mean_b0_img = nib.Nifti1Image(mean_b0, data.affine)
meta = dict(b0_threshold=gtab.b0_threshold,
source=dwi_data_file)
mean_b0 = np.mean(dwi.get_fdata()[..., gtab.b0s_mask], -1)
mean_b0_img = nib.Nifti1Image(mean_b0, dwi.affine)
meta = dict(b0_threshold=gtab.b0_threshold)
return mean_b0_img, meta


Expand Down
9 changes: 9 additions & 0 deletions AFQ/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,15 @@ def test_AFQ_pydra():
pga.export("dti_fa")


def test_AFQ_filterb():
_, bids_path, _ = get_temp_hardi()
myafq = GroupAFQ(
bids_path=bids_path,
preproc_pipeline='vistasoft',
max_bval=1000)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this actually test this functionality? This data doesn't have b-vals above 1000 does it? I'll merge for now but just wondering whether there's a better test.

myafq.export("b0")


@pytest.mark.nightly_pft
def test_AFQ_pft():
"""
Expand Down
Loading