# Automatic Approach for Brain Aneurysm Detection Using Convolutional Neural Networks
## 4 Proposed Method
### Proposed 2 DCNN Architecture  
The proposed 2D convolutional neural network (2 DCNN) architecture (see Figure 7) is designed to classify grayscale images with 235 zero-mean-normalized slices into two classes. The mesh consists of two hidden convolution 2D layers followed by MaxPooling 2D layers. Subsequently, the data are transforming by a Flatten layer and input to Dense layers. The input to the convolution model is a grayscale image with zero-mean-normalized slices. The input shape dimension is 64 \(\times\) 64. The model begins with two hidden convolution 2D layers that extract features from the input images. Each convolution layer applies a set of filters to the input image, resulting in a set of feature maps. The filters are learned during training to identify relevant patterns in the data. The size of the filters is typically smaller than the input image, and the filters slide over the input image to produce the feature maps.  
After the convolution layers, MaxPooling 2D layers are applied to reduce the spatial dimension of the feature maps while preserving the most important features. MaxPooling 2D layers take the maximum value in each small region of the feature maps and output a new set of reduced feature maps. This reduces the number of parameters in the model, allowing for faster computation and reducing the risk of overfitting. The output of the MaxPooling 2D layers is then transformed by a Flatten layer, which converts the 2D feature maps into a 1D feature vector.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Set** & **Aneurysm** & **Non-Aneurysm** \\ \hline Training & 779 & 9850 \\ Validating & 195 & 1970 \\ Testing & 256 & 2450 \\ Total & 1230 & 12,300 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Data partitioning into training, validating, and testing.  
Figure 7: The proposed 2 DCNN architecture.  
This pseudo-code provides a high-level overview of the proposed 2 DCNN architecture (Algorithm 1):  
```
1:\(tensorflow\_keras.models\)
2:\(tensorflow\_keras.layers\)
3:\(X\_train,X\_test,Y\_train,Y\_test=train\_test\_split(X,Y)\)
4:\(X\_val,X\_test,Y\_val,Y\_test=train\_test\_split(X\_test,Y\_test)\)
5:\(model\_add(Conv2D(filters=16,kernel\_size=(3,3)))\)
6:\(model\_add(BatchNormalization())\)
7:\(model\_add(MaxPooling3D(pool\_size=(2,2)))\)
8:\(model\_add(Conv2D(filters=16,kernel\_size=(3,3)))\)
9:\(model\_add(BatchNormalization())\)
10:\(model\_add(MaxPooling3D(pool\_size=(2,2)))\)
11:\(model\_add(Latent())\)
12:\(model\_add(Dense(32))\)
13:\(model\_add(Dropout(0.3))\)
14:\(model\_add(Dense(2))\)
```  
**Algorithm 1** Pseudo-code of the proposed 2 DCNN architecture  
The flattened feature vector is passed through a series of Dense layers that perform classification. The Dense layers are fully connected layers that take input from all neurons in the previous layer and output a new set of features. Finally, like the sequential model, there is a binary classification into two classes with SoftMax activation. The SoftMax activation function normalizes the output to produce probabilities for each class, and the predicted class is the one with the highest probability. Further details of the layers are shown in Table 2.