The binary volumes obtained after the thresholding were processed to identify clusters of six-connected voxels (i.e., with at least six faces attached to another voxel above the threshold). Then, a shape analysis of these binary clusters was carried out to separate the electrodes from the other metal objects. Six geometric features were extracted for each cluster of voxels: (1) Volume; (2) Primary axis length; (3) Secondary axis length; (4) Tertiary axis length; (5) Circularity and (6) Cylinder similarity. The volume, primary, secondary and tertiary axes lengths were computed via the MATLAB® function “regionprops3,” which also provided the 3D coordinates of centroids belonging to each cluster of voxels. The volume is defined as the number of voxels belonging to the cluster. The primary, secondary and tertiary axes lengths (sorted from the highest to the lowest) correspond to those of an ellipsoid that entirely comprises the cluster [19]. The circularity describes the roundness of a cluster and is defined as:

The cylinder similarity indicates how similar the cluster is to a cylinder with a diameter equal to the average of primary and secondary axes lengths, and the height equal to the tertiary axis length. It is defined as:

The electrodes essentially have the shape of a considerably flattened cylinder (like a small coin), therefore, they should have circularity and cylinder similarity both equal to 1; on the contrary, the circularity and cylinder similarity of threads and sutures segments, which have an elongated and potentially curved shape, should exhibit substantial deviations from unity.

The shape analysis is divided in two steps (see Fig. 3), namely the geometric features extraction and the classification. The former is aimed at extracting the considered geometric features for each of the metal objects within the CT volume, as well as their centroids, and organizing them in a proper dataset; the latter takes such dataset as input and provides the predicted class for all considered objects as output. A training phase is usually required for a classifier to achieve good performances and demands the a priori knowledge of the true class for each object. Indeed, this is required by the classifier to learn the optimal criteria for discriminating between instances of different classes.

In practice, before being able to use the proposed method to automatically recognize electrodes, the construction of a training dataset via feature extraction and manual classification, as well as the classifier training are mandatory. To this aim, a distinct dataset was built for each patient, with rows corresponding to all metal objects within the CT volume, and columns to the six geometric features and a manually assigned class. By considering the 24 Neuromed single-patient datasets, and the seven Mayo single-patient datasets including only ECoG electrodes (Mayo patient IDs #12, #16, #20, #22, #26, #28, #31), two classes were considered: “ECoG” and “Non-electrode”. Moreover, for the two Mayo single-patient datasets including only depth electrodes (Mayo patient IDs #5, #17), the two classes were: “Depth” and “Non-electrode.” Finally, in case of the Mayo single-patient dataset with both ECoG and depth electrodes (Mayo patient ID #27; 12 depth electrodes, 35 ECoG electrodes and 92 non-electrodes), three classes were taken into account: “ECoG”, “Depth” and “Non-electrode”. “ECoG” and “Depth” classes were assigned to the actual electrodes, while the “Non-electrode” class was assigned to all the other metal objects detected (screws, cables, etc.).

Furthermore, combined datasets were also built and named as:

“C1” (1753 ECoG electrodes, 17928 non-electrodes) obtained by joining all Neuromed single-patient datasets;

“C2” (531 ECoG electrodes and 4848 non-electrodes) obtained by joining the seven Mayo single-patient datasets containing ECoG electrodes (IDs #12, #16, #20, #22, #26, #28, #31);

“C3” (32 depth electrodes, 531 ECoG electrodes and 5970 non-electrodes) obtained by joining the seven Mayo single-patient datasets containing ECoG electrodes (IDs #12, #16, #20, #22, #26, #28, #31) and the two Mayo single-patient datasets containing depth electrodes (IDs #5, #17).

A Gaussian support vector machine (G-SVM) [20] was used as a classifier to discriminate between the considered classes and its classification performances were assessed by applying the tenfold cross-validation on each single-patient and combined dataset. In tenfold cross-validation, the dataset is randomly divided into ten subsets of equal size, and then each subset is tested using the classifier trained on the remaining nine subsets. Then, the obtained ten classification accuracies are averaged to provide an overall classification accuracy [20].

Further analyses were carried out by using completely distinct datasets for classifier training and testing (i.e., without using the tenfold cross-validation on the same dataset). First, the feasibility of recognizing ECoG electrodes in CT volumes of a medical center by using a classifier trained on data acquired from another center was investigated. To this aim, a G-SVM classifier was trained on the combined dataset C1 and tested on the single-patient datasets with Mayo IDs #12, #16, #20, #22, #26, #28, #31. Finally, the three-class classifier trained on the combined dataset C3 was tested on the Mayo single-patient dataset ID #27.