Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon...

28
Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Scientific Computing and Imaging Institute, School of Computing, University of Utah

Transcript of Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon...

Page 1: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Representing and ProcessingScientific Data with Teem:

Applications to CT and DT-MRI

Gordon Kindlmann

Representing and ProcessingScientific Data with Teem:

Applications to CT and DT-MRI

Gordon Kindlmann Scientific Computing and Imaging Institute, School of Computing, University of Utah

Page 2: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

The software: teem includes nrrd and ten

Application 1: Inspecting CT data

Application 2: Estimating and inspecting diffusion tensors

Outline

Page 3: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Teem overview

• Software I write to do research• Data processing, scientific visualization

• Open-source: http://teem.sourceforge.net• Get pre-compiled binaries, reproduce results

• Collection of ANSI C libraries• Function calls do what you need• Pseudo-object-oriented: nrrdNew(), nrrdCopy(), nrrdSlice(), nrrdNuke()

• Uncommon library names• Multiple interfaces

• Command-line: Repeatability, reproducability• API BioTensor GUI

Page 4: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Teem libraries

Basic utility functions + macros

Command-line parsing

Nearly Raw Raster Data: representing (in memory, on disk) and manipulating N-dimensional arrays

Filtered point sampling: interpolating scalar, vector, tensor fields; used for fiber tracking in Bio-Tensor

All things diffusion tensor

Page 5: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Two libraries, two utilities

Underlying library

nrrd

ten

Command-line utility

unu

tendalso BioPSE module name prefix

Page 6: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

nrrd: what it is

• Nearly Raw Raster Data• No abstractions, no cleverness

• Representation and manipulation of N-dimensional raster data:• File format• Data structure• Large set of operations

• Used by SCIRun, ITK, others• Format and API are stable

Page 7: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

nrrd: why it is• Information in scientific computation and

visualization often N-dimensional array:• 1D: histograms, time-varying scalar• 2D: gray-scale images, scatterplots,

collection of signals• 3D: color images, CT/MRI volumes• 4D: vector/tensor volumes, time-

varying scalar fields• 5D: time-varying vector/tensor fields

• Common format and tools for all of these

Page 8: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

nrrd: capabilities• Subset, superset

• Cropping, slicing, padding, joining• Arithmetic

• Adding, multiplying• Converting

• Quantization, changing type• Rearranging

• Permute axes, flipping+shuffling slices, bricking (w/out overlap)

• Filtering• Up+downsampling, blurring, median

• Measuring: projection along an axis• Min, max, mean, L2, variance, etc.

• Histograms of all sorts

dimensiongenerality

Page 9: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Getting data in: NRRD file format

NRRD0001content: a dozen imagestype: floatdimension: 4sizes: 3 640 480 12encoding: raw endian: big

<raw data>• Detached headers possible:

• “data file”, “line skip”, “byte skip”• Different encodings possible:

• Raw, ASCII, gzip-compressed, hex• Can be generated by hand …

ASCII headerfor arraydescription

Blank line Data

Page 10: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Getting data in: “unu make”• unu make -i <data file> \

-s 3 640 480 12 -t float \ -e raw -en big -o images.nrrdNRRD0001type: floatdimension: 4sizes: 3 640 480 12encoding: raw endian: big…

• unu make -h -i <data file> \ -s 3 640 480 12 -t float \ -e raw -en big -o images.nhdr

• Pretty? No. Effective? Yes.

Page 11: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Concept: raster orderingN-D raster data has “raster ordering”(0, 0, 0)(1, 0, 0)(2, 0, 0)(0, 1, 0)(1, 1, 0)(2, 1, 0) …(0, 539, 0)(1, 539, 0)(2, 539, 0)(0, 0, 1)…(0, 0, 2)…(0, 539, 379)(1, 539, 379)(2, 539, 379)

linea

r or

derin

g in

mem

ory 2-D color image

3-D array color:X:Y

Each coordinate is an axisAxes ordered: fast to slow;contiguous to distant

Fast: colorMedium: XSlow: Y

color

color X

Y

Page 12: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

The software: teem includes nrrd and ten

Application 1: Inspecting CT data

Application 2: Estimating and inspecting diffusion tensors

Outline

Page 13: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

To inspect one slice:zcat c_vf1700.fre.Z \| unu make -t ushort -e raw \

-en big -s 512 512 -bs 3416 \| unu quantize -b 8 \| unu save -f pnm | xv -

(demo of this, and command list)

cp data/c_vf16{4,5,6,7,8,9}?.fre.Z .cp data/c_vf17??.fre.Z .cp data/c_vf18{0,1,2}?.fre.Z .uncompress *.Zunu make -i *.fre -t ushort -e raw -en big \

-s 512 512 190 -bs 3416 \ -sp 0.9375 0.9375 1.0 \| unu crop -min 324 84 0 -max 499 270 M \

-o vfrhand.nhdrrm -rf *.fre

Unu application: Visible human CT

(link)

Page 14: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Unu application: Visible human CT

Page 15: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

The software: teem includes nrrd and ten

Application 1: Inspecting CT data

Application 2: Estimating and inspecting diffusion tensors

Outline

Page 16: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Diffusion in Biological Tissue

Motion of water through tissue

Faster in some directions than others

Kleenex newspaper

• Anisotropy: diffusion rate depends on direction

isotropic anisotropic

Page 17: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Diffusion in 3D

isotropic

anisotropic

linear

planar

spherical• Diffusion Tensor: 3x3 semi-positive definite symmetric matrix

• Ellipsoids represent variety of possible diffusion patterns

• Ellipsoid is image of unit sphere under diffusion tensor matrix

Page 18: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Diffusion MRI of brain• Anisotropy high along white matter fiber tracts

2.1 -0.1 -0.2

-0.1 2.0 -0.0

-0.2 -0.0 2.1

3.7 0.3 -0.8

0.3 0.6 -0.1

-0.8 -0.1 0.8

1.7 0.1 -0.1

0.1 2.3 -0.3

-0.1 -0.3 0.3

Dxx

Dxy

Dxz

Dxy Dxz

DyzDyy

DzzDyz

Page 19: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Inspecting DWI slices

unu make -i 02728/003/I.050 -t ushort \

-e raw -en big -s 256 256 -bs -1 \

| unu quantize -b 8 -o slice.png

Page 20: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Inspecting multiple DWI slicesunu make -i 003/I.0{5,6,7}? -t ushort \ -e raw -en big -s 256 256 20 -bs -1 \ | unu axsplit -a 2 -s 5 4 \ | unu permute -p 0 2 1 3 \ | unu axmerge -a 0 | unu axmerge -a 1 \ | unu quantize -b 8 -o mosaic.png

Page 21: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Making DWI volumes

foreach IMG ( 003 004 005 006 007 \ 008 009 010 011 012 013 \ 014 015 016 017 018 019 \ 020 021 022 )

unu make -i 02728/$IMG/I.* -bs -1 \ -t ushort -e raw -en big \ -s 256 256 136 -sp 0.39 0.39 1.00 \ -o dwi/$IMG.nrrd

unu resample -I dwi/$IMG.nrrd \ -s 100 100 = -k hann:8 \ -o dwi/$IMG-small.nrrdend

Page 22: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Meddling with B-matrix list

Brr Brp Brs 0 3 5 0 1 2

. Bpp Bps 1 4 3 4

. . Bss 2 5

105.92862 0.00003 33746.47739 0.04822 -1.07717 -1484.482576868.88229 1.60591 31849.32096 -104.73389 226.02398 -14714.5424116140.57145 21695.45998 1893.56463 -18690.76297 -6346.26912 5492.96913...

unu shuffle -i B-orig.txt \ -a 0 -p 0 3 5 1 4 2 -o B.txt

Page 23: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Estimating diffusion tensors

tend estim -i dwi/0??.nrrd -knownB0 false \ -B B.txt -t 48 -o ten.nrrd

confidence

Dxx Dxy Dxz

Dyz

Dzz

Dyy

Page 24: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Inspecting diffusion tensors

R=| v1.x |G=| v1.y |B=| v1.z |

v1

xy

zforeach SLC ( 30 40 50 60 ) tend slice -i ten.nrrd -a 2 -p $SLC \ | tend evecrgb -c 0 -a fa \ | unu axdelete -a -1 \ | unu quantize -b 8 \ -min 0 -max 1 -o $SLC-rgb.pngend

Page 25: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

1 = 2 = 3

1 + 2 + 3 = T

Space of tensor shape

1

2

3

1

2

3

v1

v2

v3

linear planar

spherical1 >= 2 >= 3

Page 26: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

Glyph shapes

Page 27: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

1 glyph = 1 mm3

Backdrop: FA

Color: RGB(v1)

Page 28: Representing and Processing Scientific Data with Teem: Applications to CT and DT-MRI Gordon Kindlmann Representing and Processing Scientific Data with.

http://teem.sourceforge.net