This resulted in a 39 feature vector at each voxel consisting of the corrected T1, T2, and FLAIR image intensities, as well as the four local features at three spatial scales for each MR contrast  (Figure S2).  Features were then sampled onto the FreeSurfer generated gray-white junction surface. 
To allow for more straightforward estimations of outlierness and similarity, we transformed the data into a latent representation with a known probability density function (PDF).  We standardized each feature within subject, then performed dimensionality reduction and whitening using principal component analysis (PCA) of all vertices in all HVs implemented in scikit-learn in Python \cite{scikit-learn}, retaining 14 components explaining 90% of the variance.  Next, we applied a rotation-based iterative Gaussianization (RBIG) procedure, consisting of 10 iterations of a pair of sequential transformations: 1) a non-linear univariate Gaussianization transformation applied to each of the data matrix columns (marginals)  that converts percentile scores computed using the rank transformation to standard scores (scikit-learn's QuantileTransformer), and 2) a linear orthogonal transformation applied to the entire data matrix using PCA, retaining all components after each iteration \cite{Laparra_2011}.  Source code for generating the features and model is publicly available on GitHub as part of the JEM python package.

Feature Prediction

Because this model theoretically represents an efficient and overcomplete representation of the local features of each image, we hypothesized that we should be able to predict the values of other commonly used local features such as curvature, sulcal depth, cortical thickness, and gray/white contrast (as calculated using FreeSurfer) or measures of myelination, here calculated by dividing the Tintensity by the T2 intensity, as in  \cite{Glasser_2011}, also sampled onto the gray-white junction surface.  Using our feature set as the input, quadratic regression models (ordinary least-squares) were estimated using scikit-learn for each feature using a 10-fold cross validation procedure.  Each fold was trained on 90% of the cortical vertices from all healthy volunteers and tested on the remaining 10% of cortical vertices.  

Distance and Similarity Estimations

To smooth the data and facilitate comparison across subjects, we created patches centered at every vertex, including all neighboring vertices within a 5 mm radius. Across subjects, homotopic and heterotopic patches were defined as patches in the same or different locations, respectively, on the standard surface mesh. For each patch \(p\), the center \(\mathbf{m}_{p}\) was computed by averaging the feature vectors of the vertices within the patch: \(\mathbf{m}_{p}=\sum_{\mathbf{x}\in p}\mathbf{f}(\mathbf{x})\). The direction \(\mathbf{\hat{u}}_{p}\), the unit vector pointing in the direction of the patch’s center, was computed by dividing the patch’s mean feature vector by its length \(\hat{u}_{p}=\mathbf{m}_{p}/\|\mathbf{m}_{p}\|\). In this feature space, the probability of finding a patch with a given average feature vector \(\mathbf{m}_p\), depends only on the magnitude of the feature vector \(\|\mathbf{m}_{p}\|\), i.e. the Mahalanobis distance, \(d_m\), the distance from the origin to the patch’s center, with \(d_m^2\) following a cumulative chi-squared distribution. The similarity between two patches \(p_{i}\) and \(p_{j}\) can be assessed using simple metrics, such as the cosine similarity between their directions \(s_{ij}=\hat{u}_{i}\cdot\hat{u}_{j}\).

Global Anomaly Detection

We wished to investigate the degree to which FCD lesions are global outliers in our feature space.  We measured the Mahalanobis distance (dm) of 1000 randomly sampled patches from normal cortex across HVs and 1000 patches selected from FCD lesion masks. We observed a fairly wide variation in degree of outlierness in both normal cortex and FCDs. To explore whether there were reproducible spatial patterns in this variability, we plotted the average dm across HVs onto the cortical surface, then thresholded this map at dm > 2.7 to retain the top ~5% of patches (p = 0.043) occurring in clusters with > 30 vertices.  We selected 2 of the resulting outlier regions of interest (ROI) in the anterior insula and primary motor cortex as exemplars, and compared their average dm to those of the randomly selected HV  and FCD patches. 

Projections to Measure Similarity

Having observed significant overlap in the outlierness of FCDs and some regions of normal cortex, we then wished to explore whether FCDs appeared different from normal outlier cortex in terms of the underlying features. For the motor and insular ROIs, we defined the center and direction as the average of the patches within that ROI across all HVs, and for the FCD ROI as the average all of the patches within each MRI+ FCD mask (n=11), then averaged across the FCDs, to give each lesion equal weighting regardless of size.  We computed the angles between the 3 ROI centers as an estimate of similarity in this high-dimensional feature space.  To provide a single measure of similarity of all cortical patches to each ROI, we computed the scalar projection of the mean feature vector for each patch onto the ROI average unit vector, creating a similarity map when projected onto the cortical surface.  We compared the similarity maps for our 3 ROIs, averaged across healthy controls.

FCDs as Local Outliers

As FCDs were not more globally anomalous and also appeared to have similar features to some normal cortical regions, we then hypothesized that to be identifiable, FCDs must differ from the expected appearance at their underlying location, or homotopic region, in HVs.  We implemented a local normalization procedure by removing the local mean, calculated across homotopic patches in HVs, followed by variance normalization, calculating the local standard deviation for each patch across HVs after local mean removal for each control subject individually.  Finally, we compared the cosine similarity of 
We expected that after local normalization, reproducible regional differences should no longer be present. However, the effect on FCDs  was unknown. Following normalization, we therefore again compared the Mahalanobis distances of normal cortex, the outlier ROIs, and FCDs as above.  Before and after local normalization, we also computed the cosine similarity between 1000 randomly selected FCD patches and 1) 1000 homotopic patches that fell within the FCD mask in healthy volunteers, 2) 1000 heterotopic patches in healthy volunteers, and 3) non-overlapping FCD patches across patients.  We also compared these distances to the similarities between 1000 pairs of homotopic patches and randomly selected heterotopic patches across healthy volunteers.

FCD Detection

Lastly, we implemented several approaches to automated FCD detection. 
We also implemented a two stage machine-learning method using a quadratic discriminant analysis implemented in Scikit-learn, and a leave-one-out cross-validation strategy for each FCD patient and each healthy volunteer to build a subject specific model trained using the labeled data from the other subjects (see supplementary materials for details).  For each surviving cluster, we computed a cluster weight, calculated as area \(\times\)mean FCD probability, as well as the cluster's rank among surviving clusters in that subject.

Statistical Analysis

All statistical analysis was carried out using XXX.  For the logistic regression feature prediction models, performance was evaluated for each model using the coefficient of determination \(r{^2}\); effect size was reported as in \cite{cohen1988statistical}\(r=0.1\) as small\(r=0.3\) as medium, and \(r=0.5\) as large.  For each distance-wise comparison between patches, Welch's t-test was used to estimate the effect size of the differences, reported as in \cite{cohen1988statistical}\(d=0.2\) as small\(d=0.5\) as medium, and \(d=0.5\) as large
Sensitivity of each classifier was assessed initially for MRI+ patients and then for all patients.  We calculated a receiver operating characteristics (ROC) curve and area under the curve (AUC).  True positives were defined as MRI+ patients with co-localization of a detected cluster and the manual lesion mask, and for MRI- patients, as overlap of a detected cluster with the resection mask.  False positives were defined as HVs with detected clusters detected above a given threshold.  The optimal threshold to apply to the resulting clusters for each method was determined using the Youden Index (calculated as sensitivity + specificity - 1 for each threshold).  Lesion detection and number of extralesional clusters (outside of the lesion or resection masks or in HVs) were assessed for all patients and HVs individually.  

Results

Study Participants

A total of 15 patients with drug resistant focal epilepsy and FCD (median age 27, range 15-53, 11 females) and 30 healthy controls (median age 23, range 8-63, 12 females) were included in this study.  FCDs were identified in the radiological reports in 6/15 patients, an additional 5 patients had lesions identifiable on post-hoc analysis (MRI+ n=11).  See Table 1 for further details.