Conversation

effigies

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.
@codecov

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).
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 FilesCoverage Δ
nipype/interfaces/cmtk/cmtk.py17.75% <0.00%> (-0.15%)⬇️
nipype/interfaces/nilearn.py96.61% <ø> (ø)
nipype/interfaces/cmtk/nx.py17.73% <7.14%> (-0.07%)⬇️
nipype/interfaces/cmtk/nbs.py32.98% <14.28%> (+0.02%)⬆️
nipype/interfaces/cmtk/convert.py27.01% <20.00%> (-0.05%)⬇️
nipype/interfaces/dipy/base.py75.86% <100.00%> (ø)
nipype/pipeline/plugins/base.py58.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

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

@skoudoro

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

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

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.

@effigieseffigies changed the title FIX: NiBabel 5 and NetworkX 3 compatibility FIX: NiBabel 5, and NetworkX 3 and DIPY 1.6 compatibility Jan 28, 2023

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)

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

Successfully merging this pull request may close these issues.

18 test failures (IndexError and AssertionError) on 1.8.4 Build failure with nibabel 5.0 networkx >= 3.0 unsupported