The formula is:
hu = pixel_value * slope + intercept
Normally, these values are stored in the DICOM file itself. The tags are
generally called the Rescale Slope and Rescale Intercept, and typically have
values of 1 and -1024, respectively.
| import shutil | |
| def copyDirectory(src, dest): | |
| try: | |
| shutil.copytree(src, dest) | |
| # Directories are the same | |
| except shutil.Error as e: | |
| print('Directory not copied. Error: %s' % e) | |
| # Any error saying that the directory doesn't exist | |
| except OSError as e: |
| # mesh created with | |
| # verts, faces = skimage.measure.marching_cubes(volume, level, spacing=(1.0, 1.0, 1.0)) | |
| from mayavi import mlab | |
| verts, faces = marching_cubes(myvolume, 0.0, (1., 1., 2.)) | |
| mlab.triangular_mesh([vert[0] for vert in verts], | |
| [vert[1] for vert in verts], | |
| [vert[2] for vert in verts], | |
| faces) | |
| mlab.show() |
This option allows you to disable or enable internal commands. To disable a command, precede the command name with a minus [-]. To re-enable a command, precede it with a plus [+]. For example, to disable the internal LIST command to force TCC to use an external command:
setdos /i-list
To re-enable all disabled commands use /I*.
source:
This function takes a renderer and displays the output directly into IPython
def vtk_show(renderer, w=100, h=100):
"""
Takes vtkRenderer instance and returns an IPython Image with the rendering.
"""
renderWindow = vtkRenderWindow()
renderWindow.SetOffScreenRendering(1)
renderWindow.AddRenderer(renderer)
Here's how to use the os module to get the directory of the file the command
is executed in
os.path.dirname(os.path.realpath(__file__))
From http://stackoverflow.com/questions/5137497/find-current-directory-and-files-directory
| import requests | |
| def download_file(url): | |
| local_filename = url.split('/')[-1] | |
| # NOTE the stream=True parameter | |
| r = requests.get(url, stream=True) | |
| with open(local_filename, 'wb') as f: | |
| for chunk in r.iter_content(chunk_size=1024): | |
| if chunk: # filter out keep-alive new chunks | |
| f.write(chunk) | |
| f.flush() |
| # This example shows how to manually construct triangle cell using unstructured grids | |
| # and display its surface normal. | |
| # | |
| package require vtk | |
| package require vtkinteraction | |
| # Create an unstructured grids containing a triangle cell. | |
| vtkPoints trianglePoints | |
| trianglePoints SetNumberOfPoints 3 |