Skip to content

Commit 948adc6

Browse files
committed
RF: Use lil_array only
Scipy is phasing out *_matrix, so switch to lil_array. And there is no penalty for not converting to csr (nor gain) before calling kron, so simplify. The result is still a coo_matrix. It seems better to let scipy change the type rather than coerce.
1 parent a92bc6f commit 948adc6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sdcflows/transform.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from warnings import warn
2929
from scipy import ndimage as ndi
3030
from scipy.signal import cubic
31-
from scipy.sparse import vstack as sparse_vstack, kron, csr_matrix, lil_matrix
31+
from scipy.sparse import vstack as sparse_vstack, kron, lil_array
3232

3333
import nibabel as nb
3434
import nitransforms as nt
@@ -413,10 +413,10 @@ def grid_bspline_weights(target_nii, ctrl_nii, dtype="float32"):
413413
d_vals, d_idxs = np.unique(distance[within_support], return_inverse=True)
414414
bs_w = cubic(d_vals)
415415

416-
colloc_ax = lil_matrix((knots_shape[axis], sample_shape[axis]), dtype=dtype)
416+
colloc_ax = lil_array((knots_shape[axis], sample_shape[axis]), dtype=dtype)
417417
colloc_ax[within_support] = bs_w[d_idxs]
418418

419-
wd.append(csr_matrix(colloc_ax))
419+
wd.append(colloc_ax)
420420

421421
# Calculate the tensor product of the three design matrices
422422
return kron(kron(wd[0], wd[1]), wd[2]).astype(dtype)

0 commit comments

Comments
 (0)