def add_fixed_plane(self, axis): "Add an offset plane for current channel on `axis` in {'x', 'y', 'z'}" if self.display._ipw_x(axis) is None: raise RuntimeError('No Axis to mirror!') if not self.aa.point_scalars_name: raise RuntimeError('No Colors to plot!') axis_idx = axis_to_index[axis] # set up the new fixed image plane widget at position w0 w0 = self.bbox[axis_idx][0] - self.offset r = tvtk.ImageReslice() self.set_translation(r, axis) resliced_img = mlab.pipeline.user_defined(self.aa, filter=r) m_ipw = image_plane_widget_rgba(resliced_img) m_ipw.ipw.interaction = 0 m_ipw.ipw.plane_orientation = '%s_axes'%axis m_ipw.ipw.restrict_plane_to_volume = False m_ipw.ipw.slice_position = w0 setattr(self, 'm_ipw_%s'%axis, m_ipw) setattr(self, 'resliced_img_%s'%axis, resliced_img)
def _plot_fired(self): if not self.aa.point_scalars_name: print 'no point scalars to plot' return mt.image_plane_widget_rgba(self.aa)
over_img._data = np.ma.masked_where(over_img._data > 1e10, over_img._data) main_img = xio.load_spatial_image(xipy.TEMPLATE_MRI_PATH) bi = rb.BlendedImages(vtk_order = True) m_src = mt.MasterSource(blender=bi) bi.main = main_img bi.over = over_img m_src = mlab.pipeline.add_dataset(m_src) aa1 = mlab.pipeline.set_active_attribute( m_src, point_scalars=m_src.main_channel ) ipw1 = mt.image_plane_widget_rgba(aa1) ipw1.ipw.plane_orientation = 'x_axes' aa2 = mlab.pipeline.set_active_attribute( m_src, point_scalars=m_src.main_channel ) bbox = bi.bbox x_extent = bbox[0][1] - bbox[0][0] # want to translate the image along x-axis for x_extent + 20 mm reslice = tvtk.ImageReslice() resliced_img = mlab.pipeline.user_defined(aa2, filter=reslice) x0 = 30 reslice.reslice_axes_origin = x0, 0, 0 ipw2 = mt.image_plane_widget_rgba(resliced_img)
) if __name__=='__main__': over_img = xio.load_spatial_image('tfbeam_img.nii') over_img._data = np.ma.masked_where(over_img._data > 1e10, over_img._data) over_img2 = xio.load_spatial_image('map_img.nii') main_img = xio.load_spatial_image(xipy.TEMPLATE_MRI_PATH) bi = rb.BlendedImages(vtk_order = True, over_alpha = .5) m_src = mt.MasterSource(blender=bi) bi.main = main_img ## bi.over = over_img m_src = mlab.pipeline.add_dataset(m_src) switcher = SimpleSwitching(source=m_src) ui = switcher.edit_traits() aa1 = mlab.pipeline.set_active_attribute( m_src, point_scalars=m_src.main_channel ) ipw1 = mt.image_plane_widget_rgba(aa1) ipw1.ipw.plane_orientation = 'x_axes' ## aa2 = mlab.pipeline.set_active_attribute( ## m_src, point_scalars=m_src.over_channel ## ) ## ipw2 = mt.image_plane_widget_rgba(aa2) mlab.show()