scilus / scilpy

The Sherbrooke Connectivity Imaging Lab (SCIL) Python dMRI processing toolbox
Other
54 stars 59 forks source link

Verify mask fit with reference in get_data_as_mask #937

Closed EmmaRenauld closed 3 months ago

EmmaRenauld commented 4 months ago

Quick description

I was seeing many times the same line:

if args.mask is None:
    mask = None
else:
   mask = get_data_as_mask()
   verify_shape

Replaced by single-line with verification inside get_data_as_mask. Makes the verification more thorough (was not done in all scripts) and will help with coverage.

EDIT:

After discussion with Arnaud, instead, not verifying shape there, but using assert_headers_compatible at the beginning.

Type of change

Check the relevant options.

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

...

Checklist

pep8speaks commented 4 months ago

Hello @EmmaRenauld, Thank you for submitting the Pull Request !

Line 237:80: E501 line too long (80 > 79 characters)

codecov[bot] commented 3 months ago

Codecov Report

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

Project coverage is 66.95%. Comparing base (546189e) to head (8125862). Report is 36 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #937 +/- ## ========================================== - Coverage 69.53% 66.95% -2.58% ========================================== Files 392 392 Lines 20976 21037 +61 Branches 3207 3197 -10 ========================================== - Hits 14585 14086 -499 - Misses 5090 5656 +566 + Partials 1301 1295 -6 ``` | [Components](https://app.codecov.io/gh/scilus/scilpy/pull/937/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scilus) | Coverage Δ | | |---|---|---| | [Scripts](https://app.codecov.io/gh/scilus/scilpy/pull/937/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scilus) | `68.07% <90.17%> (-3.89%)` | :arrow_down: | | [Library](https://app.codecov.io/gh/scilus/scilpy/pull/937/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=scilus) | `65.15% <78.26%> (-0.38%)` | :arrow_down: |
EmmaRenauld commented 3 months ago

Really nice addition! I found a few scripts where I don't understand why we don't use your function assert_headers_compatible, especially when we have multiple tractograms (in scil_tractogram or scil_bundle). I also added a few esthetic comments. Moreover, I think some scripts might have been left out, like scil_dwi_concatenate.py, where a check is done with is_header_compatible but could be replaced by your function.

Good job!

Yeah, at first I was managing only script calling the function get_data_as_mask. Then I also managed all scripts using add_reference_arg. But I didn't go through all scripts exhaustively. Should I? In a new PR?