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

Add t-statistic images as valid targets in ImageTransformer #895

Merged
merged 1 commit into from
Aug 7, 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
6 changes: 6 additions & 0 deletions nimare/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def test_ImageTransformer(testdata_ibma):
new_p_files = new_dset.images["p"].tolist()
assert all([isinstance(pf, str) for pf in new_p_files])

t_files = dset.images["t"].tolist()
t_transformer = transforms.ImageTransformer(target="t")
new_dset = t_transformer.transform(dset)
new_t_files = new_dset.images["t"].tolist()
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Check for correct transformation.

Consider adding assertions to check that the transformation of 't' images is correct, not just that the lists match.

Suggested change
new_t_files = new_dset.images["t"].tolist()
new_t_files = new_dset.images["t"].tolist()
for old, new in zip(t_files, new_t_files):
assert old != new, "Transformation didn't change the image path"
assert new.endswith('.nii.gz'), "Transformed image should be in NIfTI format"
assert len(t_files) == len(new_t_files), "Number of images should remain the same"

assert t_files[:-1] == new_t_files[:-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Clarify the purpose of the assertion.

The assertion assert t_files[:-1] == new_t_files[:-1] is not immediately clear. Consider adding a comment to explain why the last element is excluded from the comparison.

Suggested change
assert t_files[:-1] == new_t_files[:-1]
assert t_files[:-1] == new_t_files[:-1], "Transformed t_files should match original, except for the last element"



def test_transform_images(testdata_ibma):
"""Smoke test on transforms.transform_images."""
Expand Down
2 changes: 1 addition & 1 deletion nimare/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def transform_images(images_df, target, masker, metadata_df=None, out_dir=None,
"""
new_images_df = images_df.copy() # Work on a copy of the images_df

valid_targets = {"z", "p", "beta", "varcope"}
valid_targets = {"t", "z", "p", "beta", "varcope"}
if target not in valid_targets:
raise ValueError(
f"Target type {target} not supported. Must be one of: {', '.join(valid_targets)}"
Expand Down
Loading