Skip to content

Commit

Permalink
Fix: RGB quiver plot failing if plotting transforms independent of on…
Browse files Browse the repository at this point in the history
…e or more spatial dimensions (see someones_displacement_field.nii.gz). Fixed.
  • Loading branch information
Julien Marabotto authored and Julien Marabotto committed Jul 16, 2024
1 parent b66fee3 commit 94bab2a
Show file tree
Hide file tree
Showing 2 changed files with 301 additions and 1 deletion.
292 changes: 292 additions & 0 deletions docs/notebooks/Visualizing transforms.ipynb

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion nitransforms/vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,15 @@ def plot_quiverdsm(
else:
zeros.append(0)

assert len(np.concatenate((c_reds, c_greens, c_blues))) == len(x) - len(zeros)
'''Check if shape of c_arrays is (0,) ie transform is independent of some dims'''
if np.shape(c_reds) == (0,):
c_reds = np.zeros((1, 7))
if np.shape(c_greens) == (0,):
c_greens = np.zeros((1, 7))
if np.shape(c_blues) == (0,):
c_blues = np.zeros((1, 7))
elif np.shape(c_reds) != (0,) and np.shape(c_greens) != (0,) and np.shape(c_blues) != (0,):
assert len(np.concatenate((c_reds, c_greens, c_blues))) == len(x) - len(zeros)

c_reds = np.asanyarray(c_reds)
c_greens = np.asanyarray(c_greens)
Expand Down

0 comments on commit 94bab2a

Please sign in to comment.