def __init__(self, name, vol=None, hdr=None, method='mip', threshold=0., cmap='OpaqueGrays', select=None, transform=None, parent=None, preload=True, verbose=None, **kw): """Init.""" _Volume.__init__(self, name, parent, transform, verbose, **kw) # _______________________ CHECKING _______________________ # Create 3-D volume : vol_d = np.zeros((1, 1, 1), dtype=np.float32) self._vol3d = visuals.Volume(vol_d, parent=self._node, threshold=threshold, name='3-D Volume', cmap=VOLUME_CMAPS[cmap]) if preload: self(name, vol, hdr, threshold, cmap, method, select)
def __init__(self, parent=None, cmap='OpaqueGrays'): """Init.""" # Create the node for the 3-D volume : self._node_vol = scene.Node(name='Volume3D') self._node_vol.parent = parent # Colormaps : self._cmap_vol = cmap self._cmaps = {} self._cmaps['TransFire'] = TransFire() self._cmaps['OpaqueFire'] = OpaqueFire() self._cmaps['TransGrays'] = TransGrays() self._cmaps['OpaqueGrays'] = OpaqueGrays() # Create 3-D volume : vol = np.zeros((1, 1, 1), dtype=np.float32) self.vol3d = visu.Volume(vol, parent=self._node_vol, threshold=0., cmap=self._cmaps[cmap])
def show(self,clim=None,cmap = None): # add a volume into the scene # vol_data = np.load(io.load_data_file('brain/mri.npz'))['data'] # print type(vol_data) # print vol_data.shape # vol_data = np.flipud(np.rollaxis(vol_data, 1)) # print type(vol_data) # print vol_data.shape vol_data = self._pixel_array.copy() # vol_data = np.gradient(self._pixel_array) # vol_data = np.sqrt(vol_data[0] ** 2 + vol_data[1] ** 2 + vol_data[2] ** 2) # print vol_data.shape clim = clim or [-3024, 3071] cmap = cmap or 'grays' volume = visuals.Volume(vol_data, clim=clim,cmap = cmap,method = 'mip',relative_step_size=0.8,emulate_texture=False) view.add(volume) view.camera.set_range() # similar to viewAll in Coin3D