Code Monkey home page Code Monkey logo

ctu's Introduction

CTU

CT Scan Utilities. A set of useful methods for working with CT scan dicom files as simple as possible in python.

dependencies:

  • pydicom
  • numpy
  • scipy
  • matplotlib
  • plotly

Read a single slice from a CT Scan:

from ctu import reader
slice = reader.ReadSlice("path to CT slice")
print(slice)

slice is a dicom DataSet object that contains pixel data and other metadata. Dataset object is the primary object and is used in many methods.

Read a CT scan

from ctu import reader
ct_slices = reader.ReadCT("path to a CT Scan directory")
print(len(ct_slices))

Plot Slices of a CT Scan:

from ctu import reader, display
slices = reader.ReadCT("path to a CT Scan directory")
display.PlotSlices(slices,wtype='lung',nrows=5,ncols=5, step=2)

wtype can be a string from ['lung' , 'bone' , 'liver' , 'tissues'] or a tuple which specifies custom WindowCenter and WindowWidth.



Working with Image data
Get image in Hounsfield scale:

from ctu import reader, display
slice = reader.ReadSlice("path to a slice")
img = reader.getImageHU(slice)
display.Plot(img)

Get image in a certain Windowing condition:

from ctu import reader, display
slice = reader.ReadSlice("path to slice")
img = reader.getWindowedImage(slice, wtype='lung')
display.Plot(img) 

Plot a CT Scan in 3D

from ctu import reader, display
slices = reader.ReadCT("path to a CT Scan folder")
display.Plot3D(slices, threshold=400)


Mask body part in CT slices

from ctu import reader, transform
slice = reader.ReadSlice("path to a slice")
img = reader.getWindowedImage(slice, 'lung')
mask, masked_image = transform.BodyMask(img) 


Lung mask of a CT Slice

from ctu import reader, transform
slice = reader.ReadSlice("path to a slice")
img = reader.getImageHU(slice)
label, mask, masked_image = transform.LungMask(img) 

K-Means clustering is used to detect different parts in image. "lable" is the output of K-Means clustering and "mask" is the computed lung mask.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.