ILD classifications
Interstitial lung diseases are a collection of diseases which cause scarring of the lung tissue. In order to diagnose these diseases radiologists must scour a series of CT scans for a patient. With the use of machine learning the time of radiologists could be saved by allowing them to validate results returned from a machine learning algorithm allowing it to do all the heavy lifting. In order to carry out this vision our team set out to design two distinct classification methods for CT scans in order to compare their efficacy and accuracy. Those two distinct classification methods were a Regional-CNN and a CNN which employed the use of sliding window classification. The results of the R-CNN leave much to be desired because obtains an average precision of 0% on most patients with some patients getting around 2% - 3% average precision. The highest ground glass average precision was 10% and fibrosis was 22%. This data was gathered with fifteen patients which equates to about 130 images in the training set. Increasing the amount of classes in the dataset also decreased the accuracy so the data was tested on only two classes.
The initial stages of designing the R-CNN consisted of structuring the data for proper format. The MATLAB documentation specified that the data be specified in table format with the first column being a vector of file names, and the other subsequent column names being the location of the ROI. Each subsequent column would represent the class being identified. The sizes of columns must be equal to each other so many columns would have empty observations because they only contain one class.
Another specification for training the R-CNN classifier required the images to be in a format recognized by imread(). Since the CT slices were dicom images their pixel coordinates were described in Hounsfield Units or (HU). HU pixel values typically range from -1000 to 1000. So in order to create valid data for the R-CNN the images needed to be converted from HU to valid RGB pictures. Luckily there was functionality for this already in place in the project. The structuring of this data initially proved to be challenging single class identification was simple because each image corresponded to the single class. However, when converting the classifier to multiclass there had to be empty observations for the other classes. This problem was solved with the use of cell arrays which are very flexible. After the data was structured for training it next needed to be segmented for creating valid training sets. Each patient had a series of CT slices within each folder. In order to create a valid training and test set of this it had to recognize these folders. This meant restructuring my code in order to create folders for each patient to store each slice in. From here the data could be recognized by distinct patients rather than a collection of arbitrary CT slices. From here leave one out validation could be applied with relative ease. With valid training and test sets created the R-CNN could now make predictions on the data. The settings that were used for the R-CNN did not deviate far from the defaults specified within the documentation.
% CNN -> R-CNN
net = resnet18;
numClasses = numel(diseaseLabels) + 1;
lgraph = layerGraph(net);
% Remove the the last 3 layers.
layersToRemove = {
'fc1000'
'prob'
'ClassificationLayer_predictions'
};
lgraph = removeLayers(lgraph, layersToRemove);
% % Define new classfication layers
newLayers = [
fullyConnectedLayer(numClasses, 'Name', 'rcnnFC')
softmaxLayer('Name', 'rcnnSoftmax')
classificationLayer('Name', 'rcnnClassification')
];
% % Add new layers
lgraph = addLayers(lgraph, newLayers);
% % Connect the new layers to the network.
lgraph = connectLayers(lgraph, 'pool5', 'rcnnFC');
The basic workflow for creating an R-CNN was using one of the pretrained models and replacing the last three layers with a fullyConnectedLayer, softmaxLayer, and finally a classificationLayer.
As for the training the defaults did not stray too far away from the defaults mentioned in the MATLAB documentation either, some variables were tweaked but not too many.
options = trainingOptions('sgdm', ...
'MiniBatchSize', 128, ...
'InitialLearnRate', 1e-3, ...
'LearnRateDropFactor',0.2, ...
'LearnRateDropPeriod', 5, ...
'MaxEpochs', 15, ...
'ExecutionEnvironment', 'gpu');
rcnn = trainRCNNObjectDetector(trainDataTable, lgraph, options, ...
'NegativeOverlapRange', [0 0.3], 'PositiveOverlapRange',[0.4 1])
The results for the R-CNN were unimpressive, in most training the results of average precision for each patient was 0%. There were a small percentage of patients which had an average precision of around 2% - 3%. The highest precision for ground glass was 10% and 22% for the fibrosis class. These results were on 15 patients which unfortunately takes a very long time due to leave one out validation of the data.
Increasing the amount of patients gives a minor improvement on the data overall but the time that it takes to run dramatically increases. Overall the results leave much to be desired and it is currently unclear if it is faulty code which is leading to these results, lack of training data or a combination of both.The R-CNN quantitatively was a failure, as of right now it is uncertain whether this is a bug within the code or a lack of training data. Assuming it is not a bug which is causing these low recognition rates there are some areas of the project which could be affecting the accuracy of the classifier. The most likely of which would be the conversion from Hounsfield units to RGB. There is certainly some data loss when applying this conversion and if there was a better alternative to conversion then this could improve accuracy.
Healthy Lung Example:
Ground Glass Lung Example: