【AI Applications in Medical Imaging】Classification

MeDA
2粉絲
ChiChi Chang | Department of Bioengineering, UC Berkeley
#AIApplication #MedicalImaging #Classification #MeDA #MeDASchool
今天我們將談論針對MRI檢測的分析
首先,我希望你們都看了分析視頻
今天我們將談論分析是什麼
流程就像分析視頻一樣
首先,我們將談論分析是什麼
接下來,我們將談論分析的意義和重要性
首先,分析是什麼
簡單來說,分析是現在您所看到的圖案
我們可以分析這些點
分成三個不同的標語
所以在這種情況下,它會是蘋果,圓形和星
分析有很多不同的用途
我們通常會看到一個例子
例如分析我們的郵箱
我們通常會看到我們重要的東西
或者我們通常會看到的非垃圾
我們通常會看到的非垃圾
或者我們通常會看到的非垃圾
這就是我們所看到的第一個例子
所以對於多層次定義來說
它是比簡單的
是比簡單的
我們有很多不同的詞彙
或者很多不同的標語
這些點可能是屬於的
所以在這個圖片裏
它會是一個開心的笑容
一箇中性的表情
或者一個非常不開心的
或者非常生氣的表情
所以我通常會看作
or segmented parts meanings to it
So we will see
in an example later
what exactly I mean by this
but this is an idea
that I would really like you guys
to kind of just remember
and keep recalling to yourself
just keep saying it to yourself
Classification is giving
segmented areas meanings and labels
So in more complicated words
specifically for scans
classification is a means to organize
all of the pixels
in a digital image
into different classes or themes
So what this means is that
as we're looking over a MRI scan
a lot of the times they're pixels
So what we're doing is that
we're assigning each of these pixels
to a certain label or a certain class
for us to be able to classify
what exactly we're looking at
or what exactly we're looking at
in terms of our segmented areas
if it's not a simple
yes or no classification situation
And so applying to medical imaging
as I was speaking before
Remember that phrase or that line
that I asked you guys to remember
This is a photo
or this is an image that was taken
from the segmentation lecture
if you guys remember
And what I meant by giving
segmented areas labels or meaning
is in this case
So originally this is the original image
And so after segmentation
what we would see is
these three different colors
We would see the white
the dark gray and then the light gray
And this is only the segmentation part to it
So you see the labels
with the WMGM and CSF
These labels are not actually there
when we only go through
the segmentation process
But through classification
we're able to identify
each of these three parts
So the whole point of classification
is giving meaning to these segmented areas
that we originally had
or giving meaning to the entire image itself
So another example of this would be
a multi-class classification
So in this case
we can classify
these different brain images
or these different tumors
into multiple kinds of tumors
So as we know
tumors has different types
So for example
we can actually classify this
into a glioma or a pituitary
depending on how
we would like to classify these things
And this is what the entire
classification algorithm is doing for us
They're able to read these images
and classify
these different kinds of tumors for us
potentially
to even assist physicians
So going on to the significance
or the importance of classification
So one thing that I would like to reiterate
or to emphasize to you guys
before we actually go into classification
is the difference
between classification and object detection
So a lot of times
we mix these two things up
because it's very, very easy
to kind of mix up
So for classification
one thing that we need to remember
is that we are categorizing
the segmented areas
So we're not actually telling you
where this image is
or where this object is
So in this case
as you can see
there's just a tick with the dog there
which is stating the fact that
in this image there's a dog
So you can remember that Google image
or that Google validation part
that we saw in segmentation
What it asks us to do
is to click the images
for example
where cars exist in the images
So in these kind of cases
it's classification
where it's only asking us
to identify whether or not
an object exists within the entire image
Object detection on the other hand
is classification plus localization
So the way that I would like to think about it
is the fact that they would tell you
exactly specifically
where these dogs are
or where these objects are
in the entire image
And so it will tell you by pixels
And so going on
we can see that
classification can be applied
to multiple areas
And they're very very similar
to segmentation
So it can be classified
Or it can be
Sorry
It can be applied
to diagnosis
detection
and structure categorization
And we're going to see how
in a second
So the applications and challenges
to classification
in each of these areas are
for diagnosis
as we said before
it's very very time consuming
And a lot of times
one thing that we didn't know
is the fact that it is also invasive
So when we're trying to classify
or when we're trying to figure out
whether or not a tumor is benign
or malignant
A lot of the times
we would have to use
some kind of invasive method
in order to identify
these types of tumors
However in the case of classification
this may potentially be
something that we can get rid of completely
Another thing to note is that
it is undetectable with the naked eye
So a lot of the times
algorithms can help us pick up
on things that we were not able to see
in the moment
or doctors were not able to see
in the moment
potentially due to even just time constraints
or just the fact that sometimes
it's just way too small for us to actually see
And so these are the same things
for detection as well
And going on to structure categorization
the challenges that exist in here
is the fact that sometimes
there are unnecessary tissues for diagnosis
that we would just need to get rid of
However we're unable to get rid of the tissues
before actually identifying
what they stand for
And so this is where
classification may come in
Another part would be
visualization difficulties
So if doctors or physicians
are trying to look at MRI scans
to identify places
where they would like to enter
or how they would like to perform their surgery
A lot of the times
these tissues may get in the way
of their visualization of the entire brain
And this is where
classification may also come in
And so going on
the whole point of using classification
and diagnosis and detection
is the fact that it can potentially
identify a lot of these diseases
during the early stages
which can actually prevent a lot of deaths
For example for brain cancer
for brain tumors
a lot of the times during early detection
we could actually take many steps
such as taking the entire tumor out surgically
in order to prevent any kind of spread
So any sort of early detection
may even prevent death
And that's where classification can come in
Another impact would be the fact
that we would be able to further assess
the kinds of treatments or surgeries
that would be required
through our classified parts
or through our classified tumors
Another thing which is the most important
is the fact that this can assist doctors
by saving time on analyzing
a lot of these images
You can think of a doctor
looking through hundreds of MRI scans
and like potentially even
8 MRI scans per patient
just in order to diagnose
some kind of tumor
So this is a very big thing
about classification
the very very big impact
And so another thing about it
as I reiterated before
is the fact that
there are different kinds of tumor types
such as benign malignant
and precarcinoma
And one of the things
that we would like to know
is the fact that
there are three primary tumor
categories for brain tumors
These are gliomas, the meningomas
and the pituitary tumors
And so one thing that
I would like to know is that
through a doctor's experience
a lot of times they're able to predict
For example for gliomas
we know that they're commonly malignant
So combining this knowledge
with the different kinds of tumor types
the fact that malignant spreads
So it's very dangerous to the patient
Using these and categorizing
or classifying the tumors
with the MRI images
with the algorithm
What we're able to do
is to assist doctors
in deciding what kinds of treatments
or what kind of surgeries
that would be required
for the specific tumors
that we have classified
And so this can help
the entire workflow
or the entire process
by speeding it up
or making it more efficient
for physicians
And so for tissue categorization
one thing that I'd like to know
in terms of the impact
is the fact that
we can figure out a means
or a method for non-invasive
pathological studies
So we're able to study
for example the brain
brain development
or brain diseases
just purely through looking
at the MRI images
Potentially we can even
figure out information
on brain development
or the biomarkers
that are related to brain development
or even just brain diseases
So a lot of the times
this provides us a non-invasive method
for us to be able to
further study
details about the brain
Another thing to note
is the fact that
classification
or brain tissue classification
provides seeds and masks
for tractography
and functional MRI studies
which is a different kind of MRI study
But tractography basically
allows us to identify
the nerves within our brains
And so it provides that mask
And so for tissue categorization
as I explained before
this is exactly what would happen
if we're classifying a brain
What it does is that
it gives meaning to
each of these parts
that we're talking about
So without the labels
that we see on the side
potentially this would just be
a blue, a green and a white area
And looking at this
for a person like me
I would not be able to understand
what exactly I'm looking at
What exactly is the green thing
Because it's going to be different
from each angle
And what classification
can help us do
is to be able to identify
or relate each of these
segmented areas
to a label that gives meaning
for us to actually look at
and interpret
So going on to talking about
the current classification limitations
Two things that I would like to note
which is very very
which are both very very similar
to segmentation is
the very first part is
image variation
So the variation
within the MRI images
which can be a potential result
of the sensors themselves
or anything about the image quality
can potentially affect
our classification algorithm
So that's a very very big part
Another part to it
is feature recognition
And so a lot of times
there are variations in data set
So the lack of generalizability
in these algorithms
can make it very very hard
for us to be able to
classify very efficiently
Another fact is the fact that
tumor shape variation
Let's say that the algorithm learned
we thought that tumors
are usually round
when we see them in MRI images
But a lot of times
tumors can grow very differently
especially when the tumors
become larger
And at that point
it makes it very hard
for the algorithm
to be able to be like
Hey this is definitely a tumor
I know that
It is different from the way
that our brains work
as human beings
Another thing to note
is the fact that
there are different methods
of prediction and diagnosis
for each of these
different types of tumors
as we stated before
So it would be different
for a glioma or a pituitary
And we will see that
in an example later
as to how different kinds
of diagnosis and predictions
can make it very hard
for us to classify
or for us to be able to
get a better understanding
of what kind of treatments
or surgeries to further use
And so as I stated before
in the segmentation video
One thing to note is that
there is no method
that is suitable for all images
And there is no image
that is also suitable
for all methods
So it's always going to be
targeted towards our data set
which is a very big limitation
in AI or in classification
right now
And so as I stated before
for feature recognition
this is exactly what I mean
So for each of these
as you can see
is a different diagnosis
So from A to H
these are all different diagnosis
And what I'd like to note
is the fact that
a lot of the times
doctors look at these images
they interpret the images
And then they go through
the signs and the symptoms
for each of these patients
before actually making
a good diagnosis
or a good prediction
And that is something that
the computer is not able to do
for us currently
So the computer works
completely differently
from the way that
human beings think
which makes it
a very big limitation right now
especially when it come
to feature recognition
So why is
classification important
And I think this is a question
that I would like to ask you guys
after everything
that we have talked about
So I'm going to give you
10 seconds approximately
So yeah
The colors on a digital image
or the segmented areas
are basically meaningless
without labels
So with the help of classification
as I have reiterated
and emphasized again and again
Classification allows us
to have some sort of meaning
to the image that we're looking
And that is very, very important
especially for someone
who is looking at an image
with zero background knowledge
So going on to
the fundamental concepts
of classification
So as a brief
or a very overview
of what classification
workflow looks like
we have an input image
an MRI image in our case
that goes in
and it goes through
the entire pre-processing parts
or the pre-processing steps
that we explain
in the segmentation video
So if anything
I would recommend you guys
to look over that video first
before going into
this classification lecture video
And then after pre-processing
the output of that
pre-processed image
will become the input
in the classification model training
So within this model training
what ends up happening
is that we have this prediction
that we're going to be talking about
this probability
to a certain label
that we're going to get
And using that trained model
what we're going to end up having
is a very
is a trained model
where we would be inputting
a different testing set
into that for evaluation
And so what we're going to
end up happening
is that we're going to
compare it to the ground truth
in order to be able to find out
the accuracy of our model
as well as whether or not
or as well as the classified image
that we output
So going on to
talking about pre-processing
I'm not going to go into
too much depth
as I explained before
So I'd recommend you guys
look over the segmentation
lecture video
before looking at this
if you want more information
on pre-processing on MRI images
So I'm going to
reiterate very quickly
The pre-processing steps
that we usually see in MRI images
include bias field correction
brain extraction and registration
which is an optional step
And it only exists if
for example we have
two different kinds of image modalities
such as MRI scans and CT scans
So I would recommend you guys
to look more into this
in the other video
So as a quick reminder
of what we talked about
in that segmentation video
Bias field correction
is basically this variation
in the exact same tissue that we see
And then for brain extraction
what it basically means
that we're taking that brain out
of all the other structures
that we see in the MRI images
And it can be different
depending on the angle
that we took the MRI
or the scan that we're
specifically looking at
And as for registration
as you can see on the very left side
It is basically just having two images
or two different kind of modalities
And putting them
or registering them
on top of each other
for us to be able to identify
what we're looking at
when we're comparing
two different kinds of patients
or the same patient
with different modalities
So going on to model training
One thing that we need to know
is that model training
is the model learning
to classify these images
And so the entire workflow
for model training is
as we have that input
as our pre-processed image
which is going to go into our CNN
which is our
convolutional neural network
which we're going to talk about
later in the next slide
What ends up happening
is that it learns to break up
these images into different features
It recognizes these features
And then it keeps reiterating back
into that model until it is trained
Comes out fully connected layer
which is basically going to help us
be able to identify the label
to each of these pixels
through a probability
a factor that we'll see later
And what we end up happening
is a layer probability
or a label probability
that we'll see later on
And so this is a process
that keeps reiterating
until all the pixels are identified
or all the pixels are analyzed
So convolutional neural network, CNN
This is a type of neural network
that specializes in image recognition
and computer vision tasks
So this is one of the most common methods
used to classify images
Another one would be
deep neural network
which I'm not going to be talking about
in this video today
And so convolutional networks
I'm pretty sure you guys have seen
look something related to this
And so this would be
a shallow neural network
And this would be a deep one
where as you can see
there are multiple hidden layers
And so we're going to talk about
what each of these layers would represent
or what the structure
of this CNN would represent
And so two things
that we would need to know about CNN
is the fact that
the convolutional mechanism
It breaks up the image
into features for analysis
So you can think of
the entire image
going through this input layer
and then into the hidden layers
So within these hidden layers
what you would see is a mechanism
that breaks up the different features
into smaller features
for us to be able to analyze
And then the fully connected layer
which we'll see at the outside
which we mentioned
very briefly in the workflow
is that it takes
the convolutional mechanism outputs
as we see here in this output layer
And what it does is that
it predicts the best label for the image
So this is based on the model
that we have trained
And so one thing that we can
kind of summarize CNN is
is the fact that it creates a mechanism
for analyzing each feature individually
which gives meaning to the image as a whole
So the way that I would like to think about this
is that the CNN is able to
break things down into pixels for us
that we would usually not be able to
do as human beings
as we see the image in its entirety
and we analyze it all together
Whereas a computer has to break it into pixels
in order to analyze
each of these pixels themselves
And that is exactly what CNN does for us
And so this is an example
that I would like to talk about
in terms of how we view CNNs
So these, according to a human being
as we look at these two images
we know that we see two in each of them
So we see the number two on the left side
And we see a number two on the right side
But one thing that we need to know
is that how do we see it
As human beings we look at it
And we're smart enough to be like
Hey, we're analyzing this entire image
It's all together
And they both look like twos to us
Because of experience
Or because of what we've learned
So that training process of experience
Is basically what the CNN is doing
It is training itself to recognize
what a two means
It's basically like a kid learning
And so the way that I would like to see about
Is that this image on the left side
Is a very simple image of a two
So as a kid the first thing that you would do
Is to show them this two
To be able to learn what number two looks like
However as we get older
We're able to add these different details
Or these arts to make it pretty
And what we end up seeing
Is this right image of a two
However in order to recognize
This image or this two
We need to be able to look at it
In terms of how do we see it
We require a lot more experience
Or we require a lot more analysis
Of the actual image
And that's where CNN instructors come in
So one question that I would like to ask you guys
Depending on everything that we just talked about
Is what image would have a more complicated CNN
Based on the age reference
That I just talked about
So yeah the right image
This image that is more decorated
Would require a lot more hidden layers
For it to learn
All these different features
For it to be like hey
This is a two that I see on the side
Despite the fact that it has eyes and mouths on it
And so this is where the CNN structure comes in
And that's where the shallow
And the deep CNN structure
That we saw in that very
In the earlier slides
And that's what it represents
When we're talking about a more complicated CNN
So going on to talking about
The fully connected layer
As we explained before
What it does is that it takes
The end result of the convolution process
And reaches a classification decision for us
And what that means is
We have that set of training
That input training set
And what it does is that
Goes through this entire CNN
That we talked about before
And each of these are just going to be layers
Of just learning the features
And extracting features
Learning features
And what we end up having
Is this very last part
Which is the fully connected layer of
However many nodes that we would
That would be dependent on
The complexity of our image
And what ends up happening in this stage
Is that a prediction comes out
In order for our final output layer
To be able to tell us
What exactly this image is classified as
Or what object in this image is classified as
And so the entire process
With the brain MRI images
As I explained before
I just wanted to go through very briefly
Or very quickly
As a summary of what I just talked about
So what we end up having in our situation
When we're talking about
brain MRI scans
Is that we would have a scan like this
Where you would not have that orange part
But it would just be a black and white
Or a grayscale image of that MRI scan
And what would end up happening
A lot of the times
Is that we would
The algorithm would just
Identify where that tumor is
Specifically
And it would enlarge on that
In order to spit it in
To this CNN
For us to be able to train and study
And so what ends up happening
After going through all this
Is that we end up having
That fully connected layer
As we talked about
Through flattening
And all these processes
That we'll explain later
It would end up having this last prediction
Or this last probability score
That would allow us to be able to have
Our classification prediction
For us to be able to analyze
So going on to talking about the evaluation
Which is very, very similar
To the inference in segmentation
So what it does
Is that we use our trained features
In that trained model
In order to classify images of data sets
That have not seen that trained model
Or that model at all
And so the entire process of it is
We start off by having our testing data set
So as I explained before
This data set has not seen this model
At all whatsoever
So it doesn't know what is going on
And so going in
We'd have our trained network as well
As well as our ground truth that goes in
And going through
That entire trained network
We would evaluate the accuracy
So we'd calculate the model's accuracy
How well was it actually able
To classify this entire image
And we're going to label the areas
With that classifier
So what we end up having an output as
Is the loss value
So how accurate our actual
Classification model was
As well as our classified image
Is this benign?
Is this malignant?
All that is where the classifier
Comes in
So accuracy metrics
Actually consist of a lot of different kinds
So there's two kinds
That I would like to talk about
As the basis
Which is accuracy by percentage
And confusion matrix
So we're going to go into deeper parts
In the mathematical concept
So for percentage accuracy
This is a very simple math
That we see a lot of the times
Which is basically
The number of correct predictions
Over the total number of predictions
That are actually made
So one of the perks about this
Or one of the disadvantages about this
Is the fact that
It gives us a false sense of high accuracy
And what I mean by this is
Think of a data set
And using this algorithm
We could potentially have
For example 100 predictions
That were being made
And we split it up into 60, 40
And what we ended up getting
Was a correct
In our testing data set
And our validation
In our testing and training data set
We had 60 and 40
And let's just say that
We had or let's say 90 and 10
So for that 90
The accuracy would potentially be 90%
However overall
The actual accuracy
May not be that high
And so it gives us that
False sense of high accuracy
The other part to it
Is the fact that this method
Only works well
If there are equal numbers of sample
Belonging to each class
So what I was talking about in that case
Was the fact that
If we had 50, 50
So 50 in class A
And 50 in class B
We're able to use this
To be able to get a better idea
Or a better sense of what
Kind of accuracy
We're actually getting
So the confusion matrix
Is something that we use a lot
When we're calculating the accuracy
Of our classification model
So things to know
About the confusion matrix
Is as we can see
This is what it looks like
We have the predicted
No, the predicted yes
And then the actual ground truth
So that's where the actual is horizontally
And so what we usually see
Is that we call these things
True negatives, false positive
False negative, true negatives
So these are very simple to predict
Or simple to interpret
If you think about it
So true negative means
That it is actually negative
And it was predicted negative as well
So we would see that
In the no, no section
And so false positive would mean
That it was predicted as positive
But it wasn't actually
So the prediction would be yes
But in reality it would be no
And the same idea for false negative
So it was not actually negative
So it's falsely
Interpreted as negative
Because in reality it was true
And so and then
There is also true positive
So one thing to know about this
Is the fact that
We take the average values
Of the across the diagonal
Which is going to be our accuracy
As we see here
So it is a true positive
Plus a true negative
Over the total number of samples
That we have
So in this case it would be 165
Would be our true total sample
And we would have our true positive
And our true negative
Which is 50 plus 100
So our overall accuracy
Would be 150 divided by 165
And so one thing to remember about this
Is the fact that
This is the basis
For all other metrics
That we're going to see later
In the mathematical concept section
So in terms of classifying labels
I wanted to go over this very quickly
Which is basically
The flattening process
That I talked about
So what ends up happening is
This is the probability
That I was talking about
With each of these features
You can think of each of these nodes
As a neuron
So what we end up having
Is that each of these neurons
Or each of these features
Are given a probability
And so if it's 0.1
We know that it's going to be dog
So if it's in the lower section
We know that's going to be a dog
Because it means it's not as similar to a cat
Or it's not similar to a cat at all
So that means that it has to be similar to a dog
In a case where an image includes a dog and a cat
Or for example
If this feature had a very high probability
Then we would know that it is very close
Or very similar to what a cat would look like
For example whiskers
That's something that a cat tends to have
That a dog doesn't
Going on to the mathematical concepts of classification
So first of all
We're going to learn how to analyze this image
Which is actually very very similar to the segmentation
So I would actually recommend you guys
As I said before
To look over that segmentation video
Before looking at this classification video
If you want to get a better sense
Of how the computer analyzes the image
Before classification
So one thing that I really like to know
Or like summarize as I explained before
Is the fact that
When we look at a photo of an elephant
For example
What we see is this
So as human beings
What we tend to do is that we see this
And through training and experience
We're able to identify
What exactly an elephant looks like
Irregardless of what kind of angle
Or what kind of lighting
So all of these is because of the features
That we have learned
That we relate to an elephant all the time
For example a long nose
We tend to view that feature
And say hey this is an elephant
So that's something that we've learned over time
Which is a method of how
A computer kind of classifies
Or learns the features of these images as well
So as we're looking at this image of the elephant
The computer looks at it very very differently
What it tends to do is that
For each of these pixels
For the digital images
For each of these pixels
What it tends to do
Is to assign a value to it
And erase that value
In order to understand this entire image
And so one thing to note
When it comes to MRI images
As I explained before
Look over a segmentation video
If you don't understand this
But two things that we
One thing that I'd really like to note
Is that for 2D and 3D images
Or 3D MRI images
It is very similar
Very very similar
What the difference lies in the vocabulary
So for example for a 2D image
We refer to each of these boxes
As pixels
Whereas for 3D images
We refer to them as voxels
And as you can tell
This is just a XYZ
And an XY kind of situation
And that's the difference
Between analyzing a 2D and 3D MRI image
So talking about classification methods
So for these methods
It's actually a lot simpler
I'm just going to talk about
Very briefly about the two methods
That we tend to use
And so for the two kinds
That we usually see a lot
Are supervised and unsupervised classification
So I'm not going to go too in depth
In terms of the mathematical concepts
Between these two
As I would interpret
These two kinds of methods
As more or less
A conceptual understanding
That you just need to understand
Behind this
The math behind this entire classification
Actually lies in the CNN
Or the convolutional neural network
That we talked about before
So a lot of times in classification
We see these two kinds of methods
So for supervised
What it actually means
Is that classification
Is based on prior image
Or prior information
So what that means
Is that for example
When we are learning a
When we are learning a image of a cat
For example
What it would do
Is that it would extract the features
Or learn all these different things
From a different model
Or a different image
And be like okay
Well these are all the features of a cat
I'm going to use this image
And put it into my model
And then train that model
In order for us
To be able to make a prediction
With our own model
Unsupervised
Is basically classification decisions
That are entirely based
On the data itself
So what that means
Is that if I have a cat
Let's just say the model
Has never seen it before
What it would do
Is that it would analyze
The entire image of that cat
And be like okay
This looks like a feature
That looks like a feature
This looks like eyes
Through all this entire process
It would output a prediction
That is not based
On any sort of comparison
With the ground truth
It is entirely based on
The model and the data
That is fed into that model itself
So no external kinds of validation
No validation from anywhere else
So going on to talk about
The fully connected layer
So something that I would like
To go in deeper
In deeper
To give you guys
A deeper understanding
Of what it actually is
Is the probability assignment
Aspect to this
So as we have seen
This image from previous slides
One thing that I'd like to note
Is that the output
Of the convolution
Is flattened into
A single vector of values
So what I mean by that
Is everything before
This flattening word
Is the CNN that we saw
Like the entire thing
That you'd see in that depth
So with all the hidden layers
That is everything
Before this flattening
So the output of that entire thing
Would be a single vector
Along this
Is what you're going to be seeing
And each of these vectors
The vector would have
Multiple values within it
And each of these values
Would represent a probability
That a certain feature
Belongs to a label
So that was what we were
Talking about before here
So after all this stuff
You have that single vector
And that flattening process
Allows us to obtain
The single vector
With different values
And so that 0.1 would mean
How closely related
Is this feature
To for example
The dog or the cat
That we're looking at
And adding up all this
Or through an analysis
Or interpretation
Of all these probabilities
We're able to output
What this image is
So if there are more 0.9
Along this one
Along this single vector
Then we would know
That this image
Is more similar to a cat than a dog
And vice versa
If there are more 0.1
In this single vector
Then we would know
That this image
Is closer to a dog
Than it is to a cat
So that is the mathematical
Kind of concept
Or analysis behind
How the entire CNN
Is able to identify
Or classify
What the object is
And so one thing
That I'd like to introduce
To you guys
Is the idea of
Back propagation algorithm
So if you guys have
Read a lot about CNNs
Then I'm pretty sure
You guys would be
A little bit more familiar
With this term
And so what it basically means
Is that a lot of the times
It is used to train neural networks
Which is why I'd like to talk about
A little bit with you guys
And what it does is that
It goes through a set of these steps
Which I'm going to explain
Basically for
The weights are set
For each of the neurons
So for as you can see
This is the CNN
That we're talking about
For each of these
It would be potentially a layer
With these different circles
As each neuron
And so in this layer
What ends up happening
Is that for each of these
We would assign a weight
So in this case
It would be weight one
Is assigned to neuron one
And inputs are passed through
The entire network of neurons
So we see this entire process
Going through
So at each of these layers
A calculation is made
And through the entire thing
We would reach the very end
And what ends up happening
With back propagation algorithm
Is that the network provides
An output for each neuron
And it goes
It works its way backwards
By adjusting the weights of the neurons
So that the results
Come closer to the ground truth
So what you can see as
Is whatever goes in
Was like the ground truth
What the original image was, right
And then through each of these layers
What ends up happening
Is that we have the values
Continuously being altered
Until the very end
And so back propagation
Basically works its way backwards
So that we're able to adjust
The weights of each of these
So that it is closer and closer
And closer to what
The original images were
And so how do we define
This closeness
Or how does that
Back propagation algorithm
Determine what close means
And it is through gradient descent
As I'm pretty sure you guys
Are also familiar with
Or if you're not
Look over segmentation video again
So by applying gradient descent
To the error function
We're able to find the weights
That achieve the lower error values
So what that means by
Is that at each of these weights
The errors would be minimized
Every single time
And so what ends up happening
After using this gradient descent
Or this iteration process of
Decreasing or finding that minimum
The model gradually becomes
More accurate
So that's something to keep in mind
The entire CNN
Through back propagation
And the embedded gradient descent
Method is able to minimize
That weight
So that we're able to achieve
A more accurate model
Or a more accurate prediction
And so to summarize
The fully connected layer
Basically it has its own
Back propagation algorithm
To determine the most suitable
Or the most accurate weight
So this is applying
The entire back propagation
And the gradient descent concepts
To the fully connected layer
How do those things tie in
With our prediction
Or our classification predictions
And so after having each of these
After the fully connected layer
Having its own
Back propagation algorithm
What ends up happening
Is that each neuron
Received the weights
That would prioritize
The most appropriate label
So for each of these neurons
What it ends up going through
Is that it would go through
Each of these weights
And it would choose
Or it would label it
So that the most accurate one
Would be at the very top
And then the neurons
Would then vote
On each of these labels
And the label with the most vote
Is going to end up
Being that classification decision
That we saw at the very beginning
So we're talking about that line
Of values that I said before
So if there are more 0.9s
Then we know that
It would be classified as a cap
Because it has higher votes
There are more 0.9s
Which means higher votes
So that's the entire concept
Behind fully connected layer
Or the mathematical concept
Behind how these predictions are made
And so going on to talk about
The accuracy
Which is basically
The confusion matrix
As I talked about before
So going in deeper depth
What we end up seeing
Is that for the accuracy metric
Just reiterating
What we talked about
For the confusion matrix
Is that we see this
As you guys remember
And what ends up happening
Is that this is the basis
For all these metrics
That we see on the right side
And I've only included two
Because these are the two things
That we usually commonly see
In a lot of papers
In a lot of analysis
Which is the area under curve
Which is AUC
As you guys would probably see
A lot of times
And the F1 score
So two things to note
About the F1 score
Or two terms that are very very important
To calculate the F1 score
Are precision and recall
And so the two equations are stated
On the left side as you can see
And so what F1 score basically does
Is that it finds a balance
Between these two things
So we can see it as
The higher the precision
And the lower the recall
We have something that
Is very accurate
But it's not robust at all
So for example
What that means is that
If we have abnormalities in it
It wouldn't be able to adjust
Or it won't be able to recognize
Those abnormalities
So it wouldn't be robust in that case
And so this is the equation
For the F1 score
Which is basically
Two multiplied by
One divided by
One divided by precision
Plus one divided by recall
Um and so one thing
That I wanted to ask you guys
Is based on this is
What based on this equation
Do we want a higher
Or lower F1 score
Higher
So same thing as AUC
We want something higher
Always a higher score
In order to have
Achieve a better
Classification accuracy
So higher means more accurate always
And so summarizing
This entire workflow
That we talked about
What we end up having
Is the MRI image that we see
And then it's gonna go through
That pre-processing method
And then it's gonna go through
That model training process
Finding or learning the features
And then we're gonna have
That evaluation process
Where we're able to have
A testing data that comes in
Where we're able to identify
The accuracy of our model
And whether or not or how
Or what images or what objects
Are classified in this entire image
Thank you
