class NIFTIReader(BaseReader): _class_reader = vtkNIFTIImageReader #convert nifti to vtk reader = NIFTIReader(filename) #plot design plotter.set_background("white") plotter.show_axes() #read vtk file mesh = reader.read() #return (xmin, xmax, ymin, ymax, zmin, zmax) of the dataset Bounds = mesh.bounds maxX = int(Bounds[1]) #194 maxY = int(Bounds[3]) #239 maxZ = int(Bounds[5]) #175 #start timer just before slicing start_time = time() #create many slices of the input dataset along a all axes slicesx = mesh.slice_along_axis(n= maxX-1, axis='x') slicesy = mesh.slice_along_axis(n= maxY-1, axis='y') slicesz = mesh.slice_along_axis(n= maxZ-1, axis='z') #check how much time it took to slice data print("--- %s seconds ---" % (time() - start_time)) # result: --- 839.4215893745422 seconds --- #display the middle slice along the x axis plotter.add_mesh(slicesx[maxX//2], cmap = "gray", show_scalar_bar=False, lighting = True)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)