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

Volumes test #942

Merged
merged 14 commits into from
May 6, 2024
Merged

Volumes test #942

merged 14 commits into from
May 6, 2024

Conversation

EmmaRenauld
Copy link
Contributor

@EmmaRenauld EmmaRenauld commented Mar 7, 2024

Quick description

New tests for more code coverage, ye!!

Changes:

  • volume_math:
    - Tests: added a test for the correlation method, was missing. Fixes issue Image correlation correct? #940 .
    - Methods: Moved sub-method (def correlate) out of the loop.
  • volume operations:
    • Tests: Added 3 tests
    • Methods:
      - register_image: My initials tests failed because my fake images were too small. Took me a long time to figure out. Added a verification.
      - compute_snr: verified if both noise_mask and noise_map were given. Added more explanation.
  • script scil_header_print_info: I wanted a faster way to print the affine. Added an option. You can tell me if there was an other way.

Type of change

Check the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Provide data, screenshots, command line to test (if relevant)

...

Checklist

  • My code follows the style guidelines of this project (run autopep8)
  • I added relevant citations to scripts, modules and functions docstrings and descriptions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I moved all functions from the script file (except the argparser and main) to scilpy modules
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@pep8speaks
Copy link

pep8speaks commented Mar 7, 2024

Hello @EmmaRenauld, Thank you for updating !

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-05-06 18:07:34 UTC

@EmmaRenauld EmmaRenauld marked this pull request as draft March 12, 2024 14:49
@EmmaRenauld EmmaRenauld changed the title Volumes test [WIP] Volumes test Mar 26, 2024
# Test 2: No background
# In both cases, compares a bunch of 0 with a bunch of 1, should be a
# perfect correlation.
img_data_1 = np.zeros((3, 3, 3)).astype(float)
Copy link
Member

Choose a reason for hiding this comment

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

Here it wont work with an image full of zeros, because 0 is assume to be background (i.e. no information), to ensure there is no division by zero in np.corrcoef and no resulting NaN we add noise to background.

Therefore the correlation between an image full of zeros and full of ones is very poor (because one is 100% background), an image full of ones and twos would work (no background)

Copy link
Contributor Author

@EmmaRenauld EmmaRenauld Apr 15, 2024

Choose a reason for hiding this comment

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

@frheault After doing many tests...

Actually, result of corr is NaN whenever one patch has only the same value everywhere. So instead of adding random values, I managed possible NaN values:

  • 0 if at least one neighborhood was entirely containing background
  • 1 if the voxel's neighborhoods are uniform in both images
  • 0 if the voxel's neighborhoods is uniform in one image, but not the other.

Tell me if that's ok with you.

@EmmaRenauld EmmaRenauld changed the title [WIP] Volumes test Volumes test Apr 15, 2024
@EmmaRenauld EmmaRenauld marked this pull request as ready for review April 15, 2024 20:05
@EmmaRenauld
Copy link
Contributor Author

There were failing tests in test_reproducibility_measures. The error is fixed. But while searching for the error, I modified that other test quite a lot, and discovered that origin of SFT had an impact on results. Placed sft.to_corner() higher in tractogram_pairwise_comparison.

@EmmaRenauld EmmaRenauld force-pushed the volumes_test branch 2 times, most recently from 46bcae0 to 1f23f87 Compare April 16, 2024 20:38
Copy link

codecov bot commented Apr 16, 2024

Codecov Report

Attention: Patch coverage is 81.53846% with 24 lines in your changes are missing coverage. Please review.

Project coverage is 67.85%. Comparing base (deb254a) to head (480449d).
Report is 16 commits behind head on master.

❗ Current head 480449d differs from pull request most recent head 8d3f34d. Consider uploading reports for the commit 8d3f34d to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #942      +/-   ##
==========================================
- Coverage   68.00%   67.85%   -0.15%     
==========================================
  Files         419      419              
  Lines       21569    21604      +35     
  Branches     3242     3248       +6     
==========================================
- Hits        14668    14660       -8     
- Misses       5609     5653      +44     
+ Partials     1292     1291       -1     
Components Coverage Δ
Scripts 68.96% <59.37%> (-0.01%) ⬇️
Library 66.19% <88.77%> (-0.36%) ⬇️

Copy link
Contributor

@arnaudbore arnaudbore left a comment

Choose a reason for hiding this comment

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

A couple of question but will need another reviewer.

scripts/scil_dwi_compute_snr.py Outdated Show resolved Hide resolved
scilpy/image/volume_math.py Show resolved Hide resolved
Copy link
Contributor

@karanphil karanphil left a comment

Choose a reason for hiding this comment

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

Looks good from what I understand...

scilpy/image/volume_operations.py Outdated Show resolved Hide resolved
scilpy/image/volume_operations.py Outdated Show resolved Hide resolved
scilpy/image/volume_operations.py Outdated Show resolved Hide resolved
scilpy/image/volume_operations.py Outdated Show resolved Hide resolved
scripts/scil_dwi_compute_snr.py Outdated Show resolved Hide resolved
@arnaudbore arnaudbore merged commit ffb449f into scilus:master May 6, 2024
2 checks passed
@EmmaRenauld EmmaRenauld deleted the volumes_test branch May 6, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants