Skip to main content
. 2022 Dec 22;12(1):17. doi: 10.3390/pathogens12010017
Algorithm 1: BNCNN model
INPUT
IMG: Dataset of X-ray images [224 × 224 × 15,153]
LAB: Set of labels {‘COVID-19’, ‘Normal’, ‘Viral Pneumonia’} corresponding to X-ray images [1 × 15,153]
Nclass: number of classes used for training
OUTPUT
Ypred: a matrix of prediction probability of class labels [Nclass × 683]
ALGORITHM:
If 3-way
Nclass  = 3
If 2-way
Nclass = 2
For I = 1 to length (LAB)
If LAB (1, i) == ‘COVID-19’ or LAB(1, i) == ‘Normal’
X(:, :, i), Y(1, i) = IMG(:, :, i), LAB(1, i)
End if
End_for
Else
Nclass = 2
X, Y = IMG, LAB
End_if
X = image_resize(X)/255
Yenc = one-hot_encoder (Y, Nclass)
If model_name == ‘VGG-16’ or model_name == ‘VGG-16’
model = load_pre-trained_weigts(model_name)
model = freeze_feature_extration_layers(model)
Else_if model_name == ‘BNCNN’
model = construct_model()
End_if
Xtrain, Xval, Xtest, Ytrain, Yval, Ytest = cross-validation (X, Yenc, train = 0.8, val = 0.1, test = 0.1)
Xtrain_aug, Ytrain_aug = data_augmentation(Xtrain, Ytrain, rotation = [−20, 20], zoom = [0, 0.2],
shear = [0, 0.2], horizontal_flip = True, vertical_flip = False)
Xval_aug, Yval_aug = data_augmentation(Xtrain, Ytrain, rotation = [−20, 20], zoom = [0, 0.2],
Shear = [0, 0.2], horizontal_flip = True, vertical_flip = False)
model = train (Xtrain_aug, Ytrain_aug, Xval_aug, Yval_aug, custom_callbacks)
Ypred = predict (model, Xtest)
cm = calculate_confusion_matrix(Ypred, Ytest, Nclass)
acc, recall, precision, F1-score = calculate_evaluation_metrics(cm, Nclass)