62
DTU Compute Introduction to Medical Image Analysis Rasmus R. Paulsen DTU Compute [email protected] http://www.compute.dtu.dk/courses/02511 http://www.compute.dtu.dk/courses/02512

Introduction to Medical Image Analysiscourses.compute.dtu.dk/02511/Presentations/02511 - week6.pdf · DTU Compute 3 DTU Compute, Technical University of Denmark Introduction to Medical

Embed Size (px)

Citation preview

  • DTU Compute

    Introduction to Medical Image AnalysisRasmus R. PaulsenDTU Compute

    [email protected]

    http://www.compute.dtu.dk/courses/02511http://www.compute.dtu.dk/courses/02512

    mailto:[email protected]://www.compute.dtu.dk/courses/02511

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis2 DTU Compute, Technical University of Denmark

    Lecture 6 BLOB analysis

    9.00 Lecture

    Exercises

    12.00 13.00 Lunch break

    13.00- Exercises

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis3 DTU Compute, Technical University of Denmark

    What can you do after today?

    Calculate the connected components of a binary image. Both using 4-connected and 8-connected neighbours

    Compute BLOB features including area, bounding box ratio, perimeter, center of mass, circularity, and compactness

    Describe a feature space Compute blob feature distances in feature space Classify binary objects based on their blob features Estimate feature value ranges using annotated training data Compute a confusion matrix Compute rates from a confusion matrix including sensitivity,

    specificity and accuracy

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis4 DTU Compute, Technical University of Denmark

    Object recognition Recognise objects in images Put them into different classes

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis6 DTU Compute, Technical University of Denmark

    BLOB what is it? BLOB = Binary Large

    Object Group of connected

    pixels BLOB Analysis

    Connected component analysis

    Object labelling

    .

    .

    .

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis7 DTU Compute, Technical University of Denmark

    Isolating a BLOB What we want:

    For each object in the image, a list with its pixels

    How do we get that? Connected component analysis

    Connectivity Who are my neighbors? 4-connected 8-connected

    4-connected

    8-connected Image

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis8 DTU Compute, Technical University of Denmark

    Connected component analysis Binary image Seed point: where do we

    start? Grassfire concept

    Delete (burn) the pixels we visit

    Visit all connected (4 or 8) neighbors

    34

    12

    4-connected

    (1,1) x

    Y

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis9 DTU Compute, Technical University of Denmark

    BLOBs 4- and 8-neighbours

    A) 3 og 7B) 9 og 5C) 8 og 6D) 7 og 5E) 4 og 5

    0 0

    21

    1 0

    A B C D E

    Chart1

    0

    0

    21

    1

    0

    Sheet1

    A0

    B0

    C21

    D1

    E0

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis11 DTU Compute, Technical University of Denmark

    The result of connected component analysis An image where each BLOB

    (component) is labelled Each blob now has a unique ID =

    number What do we do with these blobs?

    1

    2

    3

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis12 DTU Compute, Technical University of Denmark

    Features Feature

    A prominent or distinctive aspect, quality, or characteristic

    This radio has many good features

    Car (Ford-T) features 4 wheels 2 doors 540 kg 20 hp

    http://upload.wikimedia.org/wikipedia/commons/1/15/Late_model_Ford_Model_T.jpg

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis13 DTU Compute, Technical University of Denmark

    Feature vector Feature vector

    Vector with all the features for one object Ford-T features

    4 wheels 2 doors 540 kg 20 hp

    Ford Fiesta features 4 wheels 3 doors 1100 kg 90 hp

    f=[4, 2, 540, 20]

    f=[4, 3, 1100, 90]

    http://upload.wikimedia.org/wikipedia/commons/1/15/Late_model_Ford_Model_T.jpghttp://en.wikipedia.org/wiki/File:Ford_Fiesta_2003_RF_14dec2006.jpg

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis14 DTU Compute, Technical University of Denmark

    Feature extractions Compute features for each BLOB that can be used to

    identify it Size Shape Position

    From image operations to mathematical operations Input: a list of pixel positions Output: Feature vector

    First step: remove invalid BLOBS too small too big border BLOBs

    Feature vector = [2,1,,3]

    Feature vector = [4,7,,0]

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis15 DTU Compute, Technical University of Denmark

    BLOB Features Area

    number of pixels in the BLOB Can be used to remove noise (small

    BLOBS)

    One BLOB

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis16 DTU Compute, Technical University of Denmark

    BLOB Features Bounding box

    Minimum rectangle that contains the BLOB

    Height: max min Width: max min

    Bounding box ratio:

    tells if the BLOB is elongatedOne BLOB

    max minmax min(max,max)

    (min,min)

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis17 DTU Compute, Technical University of Denmark

    BLOB Features Bounding box

    Bounding box area:

    Compactness of BLOB

    One BLOB

    (max,max)

    (min,min) (max min) (max min)

    Compactness = BLOB Area(maxmin)(maxmin)

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis18 DTU Compute, Technical University of Denmark

    Compactness which shape is most compact?

    A) Shape 1:

    B) Shape 2:

    2

    19

    A B

    Compactness = BLOB Area(maxmin)(maxmin)

    Chart1

    2

    19

    Sheet1

    A2

    B19

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis19 DTU Compute, Technical University of Denmark

    BLOB Features Bounding box ratio

    Bounding box height divided by the width

    One BLOB

    (max,max)

    (min,min)

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis21 DTU Compute, Technical University of Denmark

    BLOB Features Center of mass

    ( ,)

    ( ,)

    ( ,)

    =1=1

    =1=1

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis22 DTU Compute, Technical University of Denmark

    Center of massA) (12, 1.5)B) (5, 8.5)C) (6.5, 3.5)D) (4.5, 0.5)E) (7, 4.5)

    0 1 1 0

    19

    A B C D E

    Chart1

    0

    1

    1

    0

    19

    Sheet1

    A0

    B1

    C1

    D0

    E19

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis24 DTU Compute, Technical University of Denmark

    BLOB Features Perimeter

    Length of perimeter How can we compute that?

    One BLOB

    ( , SE , )

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis27 DTU Compute, Technical University of Denmark

    BLOB Features - circularity

    How much does it look like a circle?

    Circle Area = 2 Perimeter = 2

    New object assumed to be a circle Measured perimeter Measured area

    Estimate perimeter from (measured) area Estimated perimeter = 2

    Circle like

    Not circle like

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis28 DTU Compute, Technical University of Denmark

    BLOB Features - circularity

    Compare the perimeters Measured perimeter Estimated perimeter = 2

    Circularity 1:

    Circularity =

    =

    2

    Circle like

    Not circle like

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis29 DTU Compute, Technical University of Denmark

    Circularity

    A) < B) = C) >

    1

    19

    1

    A B C

    Circularity =

    =

    2

    Chart1

    1

    19

    1

    Sheet1

    A1

    B19

    C1

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis30 DTU Compute, Technical University of Denmark

    Click to add question

    A) < B) = C) >

    7

    0

    16

    A B C

    Circularity =

    =

    2

    Chart1

    7

    0

    16

    Sheet1

    A7

    B0

    C16

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis31 DTU Compute, Technical University of Denmark

    BLOB Features - circularity

    Compare the perimeters Measured perimeter Estimated perimeter = 2

    Circularity:

    Circularity =

    =

    2

    This measure will normally be 1

    Circle like

    Not circle like

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis32 DTU Compute, Technical University of Denmark

    BLOB Features circularity inverse

    Compare the perimeters Measured perimeter Estimated perimeter = 2

    Circularity (inverse):

    Circularity inverse =

    =2 A

    This measure will normally be 1

    Circle like

    Not circle like

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis33 DTU Compute, Technical University of Denmark

    After feature extraction

    Feature vector = [2,1,,3]

    Feature vector = [4,7,,0]

    Area, compactness, circularity etc calculated for all BLOB

    One feature vector per blob

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis34 DTU Compute, Technical University of Denmark

    BLOB Classification Classification

    Put a BLOB into a class

    Classes are normally pre-defined Car Bus Motorcycle Scooter

    Object recognition

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis35 DTU Compute, Technical University of Denmark

    Object recognition: Circle example

    Which objects are circles?

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis36 DTU Compute, Technical University of Denmark

    Circle classification

    Two classes: Circle Not-circle

    Lets make a model of a proto-type circle

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis37 DTU Compute, Technical University of Denmark

    Model? What is a model?

    Something you build before the real thing?

    Something that looks really nice?

    A mathematical description of something?

    Mathematical model of an electromagnetic field

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis38 DTU Compute, Technical University of Denmark

    Circle classification

    Proto-type circle Circularity : 1 Area: 6700

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis39 DTU Compute, Technical University of Denmark

    Feature SpaceProto-type circle

    Objects in here are classified as circles

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis40 DTU Compute, Technical University of Denmark

    Feature space

    Proto-type circle Circularity : 1 Area: 6700

    Some slack is added to allow non-perfect circles Circularity: 1 +/- 0.15

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis41 DTU Compute, Technical University of Denmark

    Feature space - distances

    How do we decide if an object is inside the circle?

    Feature space distance Euclidean distance in

    features space

    D = (0.31 1)2+(6561 6700)2

    Blob 1: circularity: 0.31, Area : 6561

    Dominates all! normalisation needed

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis42 DTU Compute, Technical University of Denmark

    Cell classification

    UV Microscopy Fluorescence Microscopy (DAPI)

    Single Nuclei Multiple Nuclei

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis43 DTU Compute, Technical University of Denmark

    Nuclei classificationDAPI image Two classes

    Single nuclei Noise

    Multiple nuclei together Debris Other noise

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis44 DTU Compute, Technical University of Denmark

    Training and annotation Selection of true

    single nuclei marked

    Thresholding BLOB Analysis

    Circularity Area

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis45 DTU Compute, Technical University of Denmark

    Training data - analysis

    Probably outliers

    Acceptance area

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis46 DTU Compute, Technical University of Denmark

    Feature ranges

    Feature Min MaxArea 50 110Circularity 0.87 1.05

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis47 DTU Compute, Technical University of Denmark

    Using the classifier

    DAPI input image

    Threshold input image Morphological opening (SE 5x5) Morphological closing (SE 5x5) BLOBs found using 8-neighbours Border BLOBS removed Border features computed

    Area + circularity BLOBs with features inside the

    acceptance range are single-nuclei

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis48 DTU Compute, Technical University of Denmark

    Using the classifier

    DAPI input image Found single nuclei

    Feature Min Max

    Area 50 110

    Circularity 0.87 1.05

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis49 DTU Compute, Technical University of Denmark

    How well does it work?We say we have a great

    algorithm! Strangely the

    doctor/biochemist do not trust this statement! They need numbers!

    How do we report the performance?

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis50 DTU Compute, Technical University of Denmark

    Creating ground truth expert annotations

    Found single nuclei Expert opinion on true single nucleiRed markings: Single nuclei

    Not marked: Noise

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis51 DTU Compute, Technical University of Denmark

    Four cases True Positive (TP): A nuclei is classified as a nuclei True Negative (TN): A noise object is classified as noise object False Positive (FP): A noise object is classified as a nuclei False Negative (FN): A nuclei is classified as a noise object

    Found single nuclei

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis52 DTU Compute, Technical University of Denmark

    Confusion matrix

    Predicted as noise Predicted as single-nuclei

    Actual noiseActual single-nuclei

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis53 DTU Compute, Technical University of Denmark

    Confusion matrix

    Predicted as noise Predicted as single-nuclei

    Actual noise TN=19Actual single-nuclei

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis54 DTU Compute, Technical University of Denmark

    Confusion matrix

    Predicted as noise Predicted as single-nuclei

    Actual noise TN=19Actual single-nuclei TP=51

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis55 DTU Compute, Technical University of Denmark

    Confusion matrix

    Predicted as noise Predicted as single-nuclei

    Actual noise TN=19 FP=2Actual single-nuclei TP=51

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis56 DTU Compute, Technical University of Denmark

    Confusion matrix

    Predicted as noise Predicted as single-nuclei

    Actual noise TN=19 FP=2Actual single-nuclei FN=5 TP=51

    Something simpler?

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis57 DTU Compute, Technical University of Denmark

    Accuracy Tells how often the classifier is correct

    N is the total number of annotated objects

    Accuracy=+

    = + + +

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis58 DTU Compute, Technical University of Denmark

    AccuracyA) 42%B) 65%C) 77%D) 91%E) 97%

    0 0 0

    22

    0

    A B C D E

    Predicted as noise Predicted as single-nuclei

    Actual noise TN=19 FP=2Actual single-nuclei FN=5 TP=51

    Chart1

    0

    0

    0

    22

    0

    Sheet1

    A0

    B0

    C0

    D22

    E0

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis59 DTU Compute, Technical University of Denmark

    True positive rate (sensivity) How often is a positive predicted when it actually is

    positive

    Sensivity= + All the experts true single-nuclei

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis60 DTU Compute, Technical University of Denmark

    SensitivityA) 62%B) 65%C) 71%D) 91%E) 93%

    0 0 0

    19

    2

    A B C D E

    Predicted as noise Predicted as single-nuclei

    Actual noise TN=19 FP=2Actual single-nuclei FN=5 TP=51

    Chart1

    0

    0

    0

    19

    2

    Sheet1

    A0

    B0

    C0

    D19

    E2

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis61 DTU Compute, Technical University of Denmark

    Specificity How often is a negative predicted when it actually is

    negative

    Specificity= + All the experts true noise objects

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis62 DTU Compute, Technical University of Denmark

    SpecificityA) 77%B) 81%C) 90%D) 92%E) 97%

    0 0

    21

    0 0

    A B C D E

    Predicted as noise Predicted as single-nuclei

    Actual noise TN=19 FP=2Actual single-nuclei FN=5 TP=51

    Chart1

    0

    0

    21

    0

    0

    Sheet1

    A0

    B0

    C21

    D0

    E0

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis63 DTU Compute, Technical University of Denmark

    Optimising the classification Changing the

    classification limits The rates will be

    changed: Accuracy Sensitivity Specificity

    Very dependent on the task what is optimal

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis64 DTU Compute, Technical University of Denmark

    Dependencies Increasing true positive rate

    Increased false positive rate Decreased precision

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis65 DTU Compute, Technical University of Denmark

    Example cell analysis We want only single-nuclei cells

    For further analysis

    We do not want to do an analysis of a noise object

    We are not interested in the true number of single nuclei

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis66 DTU Compute, Technical University of Denmark

    What measure is the most important?A) Low false positivesB) High true positivesC) High true negativesD) Low false negatives

    10

    5

    0

    8

    A B C D We want only single-nuclei cells For further analysis

    We do not want to do an analysis of noise objects We are not interested in the true number of single

    nuclei

    Chart1

    10

    5

    0

    8

    Sheet1

    A10

    B5

    C0

    D8

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis67 DTU Compute, Technical University of Denmark

    Next week Pixel Classification

  • DTU Compute

    7/3/2018Introduction to Medical Image Analysis68 DTU Compute, Technical University of Denmark

    Exercises

    ?

    Introduction to Medical Image AnalysisLecture 6 BLOB analysisWhat can you do after today?Object recognitionBLOB what is it?Isolating a BLOBConnected component analysisBLOBs 4- and 8-neighboursThe result of connected component analysisFeaturesFeature vectorFeature extractionsBLOB FeaturesBLOB FeaturesBLOB FeaturesCompactness which shape is most compact?BLOB FeaturesBLOB FeaturesCenter of massBLOB FeaturesBLOB Features - circularityBLOB Features - circularityCircularityClick to add questionBLOB Features - circularityBLOB Features circularity inverseAfter feature extractionBLOB ClassificationObject recognition: Circle exampleCircle classificationModel?Circle classificationFeature SpaceFeature spaceFeature space - distancesCell classificationNuclei classificationTraining and annotationTraining data - analysisFeature rangesUsing the classifierUsing the classifierHow well does it work?Creating ground truth expert annotationsFour casesConfusion matrixConfusion matrixConfusion matrixConfusion matrixConfusion matrixAccuracyAccuracyTrue positive rate (sensivity)SensitivitySpecificitySpecificityOptimising the classificationDependenciesExample cell analysisWhat measure is the most important?Next weekExercises