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 support for IBMA estimators with t-statistic images in Reports #896

Merged
merged 4 commits into from
Aug 15, 2024

Conversation

JulioAPeraza
Copy link
Collaborator

@JulioAPeraza JulioAPeraza commented Aug 10, 2024

Closes None.

Changes proposed in this pull request:

  • Add support for IBMA estimators with t-statistic images in Reports

Summary by Sourcery

Add support for IBMA estimators with t-statistic images in report generation and update the report generation logic to handle different types of input maps. Extend smoke tests to cover the new functionality.

New Features:

  • Add support for IBMA estimators with t-statistic images in report generation.

Enhancements:

  • Update report generation logic to handle different types of input maps (z_maps, t_maps, beta_maps) for IBMA estimators.

Tests:

  • Extend smoke tests to include report generation with t-statistic images for IBMA estimators.

@JulioAPeraza JulioAPeraza added the bug Issues noting problems and PRs fixing those problems. label Aug 10, 2024
Copy link
Contributor

sourcery-ai bot commented Aug 10, 2024

Reviewer's Guide by Sourcery

This pull request adds support for IBMA estimators with t-statistic images in the report generation process. The changes include updating the test cases to handle t maps and modifying the report generation logic to accommodate t maps in addition to z maps and beta maps.

File-Level Changes

Files Changes
nimare/tests/test_reports.py
nimare/reports/base.py
Enhanced the IBMA report generation to support t-statistic images by updating the test cases and the report generation logic.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @JulioAPeraza - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

nimare/reports/base.py Outdated Show resolved Hide resolved
Comment on lines 535 to 539
if self.results.estimator.aggressive_mask:
voxel_mask = self.results.estimator.inputs_["aggressive_mask"]
corr = np.corrcoef(
self.results.estimator.inputs_["z_maps"][:, voxel_mask],
self.results.estimator.inputs_[key_maps][:, voxel_mask],
rowvar=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Add a comment explaining the different approaches for aggressive and non-aggressive masking

The reasoning behind using different methods for correlation calculation based on the masking approach is not immediately clear. A brief comment would improve code understanding.

Suggested change
if self.results.estimator.aggressive_mask:
voxel_mask = self.results.estimator.inputs_["aggressive_mask"]
corr = np.corrcoef(
self.results.estimator.inputs_["z_maps"][:, voxel_mask],
self.results.estimator.inputs_[key_maps][:, voxel_mask],
rowvar=True,
# Calculate correlation based on masking approach
if self.results.estimator.aggressive_mask:
voxel_mask = self.results.estimator.inputs_["aggressive_mask"]
corr = np.corrcoef(
self.results.estimator.inputs_[key_maps][:, voxel_mask],
rowvar=True,
)
else:
corr = np.corrcoef(self.results.estimator.inputs_[key_maps], rowvar=True)


filename = "report.html"
outpath = op.join(tmpdir, filename)
outpath = op.join(stouffers_dir, filename)
assert op.isfile(outpath)
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): Consider adding edge case tests for invalid or missing t-statistic images

While the current tests cover the basic functionality, it would be beneficial to add tests for edge cases such as invalid t-statistic images or missing images. This will ensure the robustness of the new feature.

def test_invalid_tstat_images():
    with pytest.raises(ValueError):
        IBMAWorkflow(invalid_image_path)

def test_missing_tstat_images():
    with pytest.raises(FileNotFoundError):
        IBMAWorkflow(non_existent_image_path)

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
nimare/reports/base.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Aug 15, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.24%. Comparing base (5b6e337) to head (db8e0fe).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
nimare/reports/base.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #896   +/-   ##
=======================================
  Coverage   88.23%   88.24%           
=======================================
  Files          48       48           
  Lines        6386     6389    +3     
=======================================
+ Hits         5635     5638    +3     
  Misses        751      751           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jdkent jdkent left a comment

Choose a reason for hiding this comment

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

LGTM!

@jdkent jdkent merged commit c1cd2d7 into neurostuff:main Aug 15, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues noting problems and PRs fixing those problems.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants