Image-X-Institute / mri_distortion_toolkit

Characterisation and reporting of geometric distortion in MRI
https://image-x-institute.github.io/mri_distortion_toolkit/
GNU General Public License v3.0
9 stars 3 forks source link

add this plot to `MatchedMarkerVolumes` #245

Closed bwheelz36 closed 1 year ago

bwheelz36 commented 1 year ago
   def plot_3D_markers_with_color_scale(self, cmap=None, title=None, elevation=None, azimuth=None,
                                         vmin=None, vmax=None, return_axs = False):

        if cmap is None:
            cmap = plt.cm.viridis

        fig = plt.figure()
        axs = fig.add_subplot(111, projection='3d')

        x_dis = np.abs(self.MatchedCentroids.x_gt - self.MatchedCentroids.x_gnl)
        y_dis = np.abs(self.MatchedCentroids.y_gt - self.MatchedCentroids.y_gnl)
        z_dis = np.abs(self.MatchedCentroids.z_gt - self.MatchedCentroids.z_gnl)
        abs_dis = np.sqrt(x_dis**2 + y_dis**2 + z_dis**2)
        p = axs.scatter(self.MatchedCentroids.x_gt, self.MatchedCentroids.y_gt, self.MatchedCentroids.z_gt,
                        c=abs_dis, cmap=cmap, vmin=vmin, vmax=vmax)
        fig.colorbar(p, ax=axs)
        if elevation:
            axs.elev = elevation
        if azimuth:
            axs.azim = azimuth
        axs.set_xlabel('X [mm]')
        axs.set_ylabel('Y [mm]')
        axs.set_zlabel('Z [mm]')
        if title:
            axs.set_title(title)
        axs.set_box_aspect((np.ptp(self.MatchedCentroids.x_gt), np.ptp(self.MatchedCentroids.y_gt),
                            np.ptp(self.MatchedCentroids.z_gt)))

        if return_axs:
            return  axs
        else:
            plt.show()
bwheelz36 commented 1 year ago

can actually be combined with existing plot, just add optinal color scale