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

ENH: Check CIFTI-2 data shape matches shape described by header #774

Merged
merged 9 commits into from
Jul 13, 2019
Merged

ENH: Check CIFTI-2 data shape matches shape described by header #774

merged 9 commits into from
Jul 13, 2019

Conversation

MichielCottaar
Copy link
Contributor

Checks whether the shape of the data matches the shape expected based on the CIFTI-2 header

  • raises an error when trying to write out a mismatched CIFTI image to disk
  • raises a warning when creating a mismatched CIFTI file
    I've added tests for both of these behaviors (and fixed many old tests that produced mismatched CIFTI images).

In the end I did not adopt the framework of _get_checks as this seemed to be only implemented for subclasses of WrapStruct, which are the header objects. However, this is a test that should be run on the Image class (as it requires knowing the shape of the dataobj).

@MichielCottaar
Copy link
Contributor Author

I do think a ConsistencyWarning rather than a UserWarning would work well here, if you decide to implement one.

@codecov-io
Copy link

codecov-io commented Jul 5, 2019

Codecov Report

Merging #774 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #774      +/-   ##
==========================================
+ Coverage   89.97%   89.99%   +0.01%     
==========================================
  Files          94       94              
  Lines       11992    12009      +17     
  Branches     2128     2134       +6     
==========================================
+ Hits        10790    10807      +17     
  Misses        859      859              
  Partials      343      343
Impacted Files Coverage Δ
nibabel/batteryrunners.py 95.74% <ø> (ø) ⬆️
nibabel/cifti2/cifti2.py 96.55% <100%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0282bb9...c531421. Read the comment docs.

@effigies effigies added this to the 2.5.0 milestone Jul 10, 2019
Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

This looks good to me. Just a couple comments.

nibabel/cifti2/cifti2.py Outdated Show resolved Hide resolved
nibabel/cifti2/cifti2.py Outdated Show resolved Hide resolved
nibabel/cifti2/cifti2.py Outdated Show resolved Hide resolved
@effigies effigies changed the title Check cifti shape ENH: Check CIFTI-2 data shape matches shape described by header Jul 12, 2019
@effigies
Copy link
Member

Also, I doubt I'm going to have time to think through and implement new warning classes before the 2.5 release. Perhaps we can revisit afterwards.

MichielCottaar and others added 2 commits July 12, 2019 09:26
Co-Authored-By: Chris Markiewicz <effigies@gmail.com>
@MichielCottaar
Copy link
Contributor Author

I'm happy to either have this pull request to remain open until you have time to decide on the new warning system. We could also just put it in with the default python warning and later replace that with a custom warning system. I have no strong preference either way.

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

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

Thanks. One quick typo...

nibabel/cifti2/cifti2.py Outdated Show resolved Hide resolved
Co-Authored-By: Chris Markiewicz <effigies@gmail.com>
@effigies
Copy link
Member

LGTM. Thanks.

@effigies effigies merged commit b356a64 into nipy:master Jul 13, 2019
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.

3 participants