Skip to content

FIX: NiBabel 5, and NetworkX 3 and DIPY 1.6 compatibility #3538

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

Merged
merged 9 commits into from
Jan 29, 2023

Conversation

effigies
Copy link
Member

@effigies effigies commented Jan 28, 2023

Summary

This PR makes minimal changes to handle deprecations in nibabel 5 and networkx 3.

As seen in #3535, simply switching to sparse arrays breaks the dependency graph matrix representation. However, scipy sparse arrays are just sparse matrices with wrappers on top, so we can just get back to the matrix for now. While they claim they are deprecating the API, much of the API still works with and produces matrices, so I think we have time where we can continue doing what works.

In the long run, it would be nice to understand what is treating these representations differently, but that's beyond the time I have to devote to this. I would rather get things working before embarking on a refactor, especially if it's just a cheap type coercion.

Fixes #3537.
Fixes #3530.
Fixes #3539.

List of changes proposed in this PR (pull-request)

  • Convert nx.to_scipy_sparse_matrix() to ssp.lil_matrix(nx.to_scipy_sparse_array())
  • Add non-int64 dtypes to arrays to be promoted to test Nifti1Images
  • Fix dipy type conversion to accept "str" instead of "string"
  • In passing update the requirements.txt file from current build info

NiBabel 4 began warning that int64 images would error, and NiBabel 5
began erroring if not passed an explicit dtype or header.

We don't need int64 images, just set some sensible dtypes.
@effigies effigies requested a review from TheChymera January 28, 2023 13:47
@codecov
Copy link

codecov bot commented Jan 28, 2023

Codecov Report

Base: 63.63% // Head: 63.62% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (f6bf0af) compared to base (7382b3d).
Patch coverage: 26.31% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3538      +/-   ##
==========================================
- Coverage   63.63%   63.62%   -0.02%     
==========================================
  Files         309      309              
  Lines       40873    40900      +27     
  Branches     5381     5381              
==========================================
+ Hits        26011    26021      +10     
- Misses      13838    13855      +17     
  Partials     1024     1024              
Impacted Files Coverage Δ
nipype/interfaces/cmtk/cmtk.py 17.75% <0.00%> (-0.15%) ⬇️
nipype/interfaces/nilearn.py 96.61% <ø> (ø)
nipype/interfaces/cmtk/nx.py 17.73% <7.14%> (-0.07%) ⬇️
nipype/interfaces/cmtk/nbs.py 32.98% <14.28%> (+0.02%) ⬆️
nipype/interfaces/cmtk/convert.py 27.01% <20.00%> (-0.05%) ⬇️
nipype/interfaces/dipy/base.py 75.86% <100.00%> (ø)
nipype/pipeline/plugins/base.py 58.88% <100.00%> (+0.66%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@effigies
Copy link
Member Author

Looks like dipy compatibility as well. @skoudoro anything we should know before digging in? I might have a chance this afternoon.

@skoudoro
Copy link
Member

Nothing particular change. Looking at the error, it seems that a new workflow has a unknown argument type which surprise me.

I can look at this only tonight, quite busy today.

Thank you for pinging @effigies

@effigies
Copy link
Member Author

Thanks. I'll let you know if I find anything. If it's just a bug, the easy fix here will be to blacklist the latest release of dipy. Then there shouldn't be a huge rush for you to release.

@skoudoro
Copy link
Member

Ok, I just looked deeper and you just need to add the type "str" in the function "convert_to_traits_type". This function is handling the keyword "string" but not "str". 😅

It should be an easy and fast fix of this function in nipype. Now, I see why I didn't catch it in DIPY.

@@ -110,7 +110,7 @@ def convert_to_traits_type(dipy_type, is_file=False):
"""Convert DIPY type to Traits type."""
dipy_type = dipy_type.lower()
is_mandatory = bool("optional" not in dipy_type)
if "variable" in dipy_type and "string" in dipy_type:
if "variable" in dipy_type and "str" in dipy_type:
Copy link
Member Author

Choose a reason for hiding this comment

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

I tested this on 1.5.0 (which was not failing) and 1.6.0 (which was). Both pass.

@effigies effigies changed the title FIX: NiBabel 5 and NetworkX 3 compatibility FIX: NiBabel 5, and NetworkX 3 and DIPY 1.6 compatibility Jan 28, 2023
Copy link
Collaborator

@TheChymera TheChymera left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the amazing work. Solves the issue I just opened and supersedes my networkx PR.

(I still have one error, but that is fully unrelated to dependency compatibility fixes)

@effigies effigies merged commit 28d424f into nipy:master Jan 29, 2023
@effigies effigies deleted the fix/nibabel5 branch January 29, 2023 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants