From a8bea2700641c8b3c13164fecfbebf91972e40c7 Mon Sep 17 00:00:00 2001 From: Julien Marabotto Date: Tue, 9 Jul 2024 11:47:30 +0200 Subject: [PATCH] enh: code structure --- nitransforms/vis.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/nitransforms/vis.py b/nitransforms/vis.py index a893425a..89e9bf03 100644 --- a/nitransforms/vis.py +++ b/nitransforms/vis.py @@ -333,21 +333,22 @@ def plot_jacobian(self, axes, xslice, yslice, zslice, show_titles=True): J = self.get_jacobian().reshape(self._xfm._field[..., -1].shape)[s[0], s[1], s[2]] jacobians[ind] = J.flatten() - for index, plane in enumerate(planes): - x, y, z, u, v, w = plane + for index, (ax, plane) in enumerate(zip(axes, planes)): + x, y, z, _, _, _ = plane if index == 0: - dim1, dim2, vec1, vec2 = y, z, v, w + dim1, dim2 = y, z elif index == 1: - dim1, dim2, vec1, vec2 = x, z, u, w + dim1, dim2 = x, z else: - dim1, dim2, vec1, vec2 = x, y, u, v + dim1, dim2 = x, y c = jacobians[index] - axes[index].scatter(dim1, dim2, c=c, norm=mpl.colors.CenteredNorm(), cmap='seismic') + plot = ax.scatter(dim1, dim2, c=c, norm=mpl.colors.CenteredNorm(), cmap='seismic') if show_titles==True: - axes[index].set_title(titles[index], fontsize=14, weight='bold') + ax.set_title(titles[index], fontsize=14, weight='bold') + plt.colorbar(plot, location='bottom', orientation='horizontal', label=str(r'$J$')) def get_coords(self): @@ -567,3 +568,18 @@ def format_axes(axis, **kwargs): except: pass return + +path = "tests/data/ds-005_sub-01_from-OASIS_to-T1_warp_fsl.nii.gz" + +fig, axes = plt.subplots(1, 3, figsize=(12,4)) +PlotDenseField( + path_to_file=path, + is_deltas=True, +).plot_quiverdsm( + axes=[axes[2], axes[1], axes[0]], + xslice=102, + yslice=90, + zslice=88, +) + +plt.show()