Abstract
Atomic force microscope (AFM) indentation allows high-resolution spatial characterization of biomechanical properties of cells and tissues. Rapid, reproducible, and quantitative analysis of AFM force curves has been challenging due to several technical limitations, such as excessive noise and uncertainty associated with contact-point determination. Here, we propose a novel machine-learning algorithm composed of convolutional bidirectional long short-term memory neural networks called Convolutional Bidirectional Recurrent Architecture (COBRA) that can reliably process raw AFM elastography data, triage poor-quality curves, and accurately identify the contact point without any a priori knowledge of underlying material properties. Using over 5000 manually curated force curves on seven different healthy and diseased cell types, we trained several regression and classification algorithms to compare their utility. In contrast to classical analytical or semi-quantitative techniques and other machine-learning methods, the COBRA approach identified low-quality or anomalous indentation events better, with an area under the curve of 0.92, and it estimated the contact point with the minimal absolute error of 28 ± 3 nm and pointwise elastic modulus with mean absolute percentage error of 5.3% ± 0.7%. The method was also successful in identifying the contact point in independently acquired AFM data from the literature with divergent probes and substrates. In conclusion, our method can rapidly filter low-quality AFM force curves and automatically process raw indentation data with the lowest error levels, allowing high-throughput analyses with increased precision and reproducibility.
Significance
This study introduces a machine-learning framework that automates the analysis of atomic force microscopy indentation data with high precision. By integrating convolutional blocks and bidirectional long short-term memory layers into a unified "COBRA" model, our method reliably identifies the contact point and screens out anomalous curves across diverse cell types and elastic moduli. The approach makes no a priori assumptions regarding the isotropy or homogeneity of the material properties, enhancing its applicability across varied biological samples. This strategy not only eliminates manual curation and subjective bias but also significantly improves the accuracy and reproducibility of elasticity measurements, allowing high-throughput mechanobiology studies with real-time analytics.
Introduction
Mechanical properties of cells and tissues play a critical role in physiological and pathological processes. Among the tools available for quantitative biomechanical measurements, atomic force microscope (AFM) indentation stands out for its high-resolution spatial-mapping capabilities, high sensitivity, and the ability to nondestructively probe living cells and tissues (1,2,3,4,5). However, despite its widespread adoption and proven utility, obtaining rapid, reproducible, and accurate biomechanical measurements from AFM indentation poses unique challenges. The most arduous steps in AFM analysis are precise designation of the contact point (CP) and reproducible recognition of anomalous indentation events (6,7). Although both CP and anomalous curves can be detected by visual inspection in smaller-scale studies, such manual analysis is subjective and tedious, and it quickly becomes infeasible in large experiments, such as high-resolution elastography. Moreover, errors or inconsistencies in CP detection lead to significant inaccuracies in estimated material properties and the final height or topography image (7).
Several algorithms have been proposed for CP detection, including threshold-based, curve-fitting-based, and variance-based approaches (6,7,8,9,10). Although these methods can be effective under certain conditions, they often rely on multiple hyperparameters that need to be fine-tuned and carefully adapted to each experimental setup. Some of these approaches also assume the underlying substrate to be homogeneous along the indentation depth; thus, deviations from this assumption, which are often the case for biomaterials, lead to large errors. Minor variations in sample preparation, AFM cantilever stiffness, fluid viscosity, or cell type can invalidate these hyperparameters, thereby limiting the generalizability of existing approaches. Furthermore, most of these algorithms do not adequately address the problem of anomalous or ambiguous force curves. Instead, they require post hoc manual review to filter out invalid data, which is both time-consuming and prone to operator bias.
In recent years, machine-learning (ML) methods that involve deep-learning architectures, such as convolutional neural networks and residual networks (ResNets), have shown remarkable success in pattern recognition and signal classification (11,12). Others have shown the potential utility of ML-based models for AFM image (13) as well as indentation analyses, including CP identification (14), contact model selection (15), elastic-modulus estimation (16), rapid quality control of high-resolution elastography images (17), and for automated integration of optical and force microscopy data (18). However, purely convolutional architectures can sometimes overlook temporal or sequential aspects inherent to force-depth curves, which capture the progression of cantilever deflection over time and distance. To address this gap, recurrent neural networks, especially those employing bidirectional long short-term memory (BiLSTM) units, can be used as they capture both local and long-range dependencies in sequential data and improve robustness (19,20,21).
In this study, we report a neural-network architecture that combines convolutional blocks and BiLSTM layers, specifically tailored for AFM indentation data, which hereafter we refer to as Convolutional Bidirectional Recurrent Architecture (COBRA). We evaluated our approach on over 5000 curated AFM indentations from various cell types, encompassing diverse mechanical properties and experimental conditions. Our model not only exhibits high accuracy in identifying CPs but also automatically flags and excludes noisy, anomalous, or ambiguous force-depth curves. By integrating quality control and CP detection into a single, end-to-end pipeline, our method obviates extensive manual curation and offers a more robust, reproducible, and generalizable solution for AFM-based mechanobiology studies. This integrated framework has strong potential to streamline large-scale experiments aimed at quantifying the mechanical properties of cells and tissues in real time.
Materials and methods
AFM data collection and annotation
AFM indentations were performed on immortalized human podocytes and immortalized murine collecting duct tubular epithelial cells using thermal-calibrated probes on an Asylum MFP-3D-BIO AFM (Oxford Instruments) at an indentation velocity of 9.92 μm per second with a constant extension of 5000 nm. Indentations on induced pluripotent stem cell (iPSC)-derived vascular smooth muscle cells (22), LM24, MCF7, MCF10a, and HEPG4 cells (23) were collected as part of earlier studies. A total of 5951 indentation curves were analyzed. Full probe and cantilever details for all cell types are provided in Table 2. A custom MATLAB interface was used to manually label each curve’s CP and assess curve quality based on the following criteria: substantial precontact noise or drift, post-contact probe tip slippage, artificial substrate-induced stiffening, ambiguity of the CP, and any other aberration or artifact. Curves with probe slippage, substrate effect, or precontact noise were still used to train the regression model if the CP was not ambiguous, resulting in 5165 unambiguous indentations for CP regression analysis. To validate the reproducibility of the CP annotations, a second expert annotated a subset of 2435 curves that were used to generate Fig. 4 F and G.
Table 2.
Summary of AFM Probe Tip Characteristics Used in This Study
| Cell Type | Probe Geometry | R (nm) | Nominal Spring Constant (nN/nm) | Measured Spring Constant (nN/nm) | Cone Half Angle (º) | Coating | Vendor | Catalog # |
|---|---|---|---|---|---|---|---|---|
| LM24 | blunted pyramidal | 42 ± 12 | 0.09 | 0.065 | 35 ± 10 | Cr/Au | Asylum | BL-TR400PB |
| MCF10a | blunted pyramidal | 42 ± 12 | 0.09 | 0.065 | 35 ± 10 | Cr/Au | Asylum | BL-TR400PB |
| HEPG4 | blunted pyramidal | 42 ± 12 | 0.09 | 0.065 | 35 ± 10 | Cr/Au | Asylum | BL-TR400PB |
| MCF7 | blunted pyramidal | 42 ± 12 | 0.09 | 0.065 | 35 ± 10 | Cr/Au | Asylum | BL-TR400PB |
| Tubule | blunted pyramidal | 42 ± 12 | 0.09 | 0.100 | 35 ± 10 | Cr/Au | Asylum | BL-TR400PB |
| Podocyte | blunted pyramidal | <40 | 0.08 | 0.201 | 35 | Cr/Au | Nano-World | PNP-Tr-Au |
| iPSC VSMC | blunted pyramidal | 30 | 0.09 | 0.080 0.100 0.149 |
39 | Au | Asylum | OMCL-TR400PB |
| Mouse intervertebral disc | spherical (polystyrene) | 2250 | 9.5 | 5.278 7.401 8.260 8.900 |
N/A | Al | Novascan | NA - custom |
R, tip radius (R). Probe coatings include chromium (Cr), gold (Au), and aluminum (Al). Uncertainties were provided by the manufacturer.
Figure 4.
Parameter sensitivity analysis and fine-tuning of COBRA. (A) Contact-point mean absolute error (MAE) as a function of the maximum deflection used for prediction. COBRA was trained on the full-length deflection curves and evaluated on curves truncated at each indicated deflection threshold. (B) Example raw deflection curve exhibiting probe slippage overlaid with the classifier’s rejection probability as a function of extension. The probability of being rejected increases sharply where the probe slips, indicating the optimal truncation point. (C) Hertzian modulus mean absolute percentage error (MAPE) on a holdout set of 100 spherical-indentation curves from mouse spinal tissue, plotted against the number of curves used for fine-tuning (n = 10 bootstrap repetitions per group). Feature importance is quantified by averaged Shapley additive explanations (SHAPs) for (D) regression and (E) classification models for the six input features: Feat1, raw deflection; Feat2, smoothed deflection; Feat3, smoothed first derivative; Feat4, RoV; Feat5, local slope; and Feat6, local R2. (F) Histogram of the absolute differences in contact-point annotations made by two AFM experts across 2435 indentation curves in the training set. (G) The curves annotated by a second expert were evenly split into a training and a validation subset. The pretrained COBRA model was fine-tuned on the training subset using 10 bootstrap repetitions and evaluated on the holdout validation data. Symbols denote the mean, and error bars represent ±standard deviation.
Preprocessing and feature extraction
Raw deflection data were minimum-maximum normalized to [0, 1] and linearly resampled to 2000 points. The CP location was stored as a fractional index between 0 and 1 (i.e., the CP’s position relative to the curve length). From each normalized deflection curve, we derived additional features, including a moving mean smoothed version of the curve, its first derivative, and three metrics computed over sliding windows of 35 data points: the ratio of variance, the local slope, and the R2 value of the local slope. Modulus calculations followed standard Hertz modeling protocols (6), excluding the initial 100 nm of the force curve. Briefly, the force-depth relationship can be generalized as
where is a geometric function that depends on the probe geometry and indentation depth , and is the apparent elastic modulus that can be related to the elastic modulus, , via ), where is the Poisson’s ratio of the material being indented. For a sphere of radius
For a blunted pyramidal tip with the equivalent blunted cone radius , macroscopic cone semi-angle of , and defect radius , takes the same functional form as a sphere when , but when then
where is the contact radius that must be solved as a function of using the following relationship:
Once all these equations are solved, the non-Hertzian pointwise modulus can be calculated at each depth, . On the other hand, the Hertzian modulus assumes that scales linearly with with as the linear scaling constant. This can be calculated by performing least-squares linear regression (with a 0 intercept) on .
Ratio of variance and curve-fitting-based methods
We implemented three methods for estimating the CP in AFM force-indentation curves: bidomain linear quadratic, fitting to a Hertzian model (referred to as “SNAP” after the paper where the method was developed (9)), and ratio of variance. The bidomain linear-quadratic method fits a linear model before the CP and a quadratic model after, optimizing the CP and three functional parameters by minimizing the least-squares error (6,24). The ratio of variance (RoV) method (8) computes the ratio of variances for K points before and after each candidate CP (K = 2–35), selecting the CP at the maximum ratio. In our evaluation, we chose the K that minimizes the mean absolute error (MAE) of annotated and predicted CPs. All methods were applied to the deflection curve up to the first occurrence where the normalized deflection reached 0.1 (RoV) and 0.3 (bidomain linear-quadratic). The SNAP method (9) assigns the contact point based on repeated iterations to fit the force to a Hertzian model, including the CP and Hertzian modulus as fitting parameters. In the implementation here, we used the above equation for the force exerted by blunt pyramidal tips (6).
ML architectures
We developed neural-network models incorporating convolutional and BiLSTM layers for either CP regression or classification of “accept” vs. “reject” indentations. For regression, the networks were trained to predict the normalized CP. All regression models were trained using 200 epochs, the Adam optimizer, a mini-batch size of 32, learning rate of 1e−04, and a MAE loss objective. The classification networks were similarly structured but trained for 30 epochs with binary cross-entropy loss, also using Adam with a learning rate of 1e−04 and a mini-batch size of 32. The visualization of the COBRA network was made with PyDrawNet (https://github.com/nhansendev/PyDrawNet).
The convolutional neural-network architectures for ConvNet-1D and ResNet50-1D were adapted from the original Python implementation in TensorFlow and transcribed into MATLAB. For evaluation, only the preprocessed deflection curves were used, as described in the original study (14). ResNet50-1D is a one-dimensional implementation of ResNet architectures commonly used in image-classification tasks (12). In this study, ResNet50-1D contains 176 layers and 576,929 learnable parameters, and COBRA contains 14 layers and 172,705 learnable parameters for the regression models.
Cross-validation, generalizability, and learning curves
All primary performance evaluations used fivefold cross-validation. For within-cell-type evaluations (training and testing on the same cell type), we averaged metrics (e.g., area under the curve (AUC) or MAE) across all folds. For between-cell-type generalizability analyses, the model was trained on all curves from one cell type and tested on all curves from another, without fold splitting. Classification analyses followed the same protocols (fivefold or leftover splits) for distinguishing accept vs. reject curves.
For the learning curves spanning the entire dataset, a 1000-curve holdout was used for evaluation. Each training size N was sampled five times from the remaining curves, then tested on the same 1000-curve holdout. When incorporating various numbers of cell types, we held out 100 curves per cell type (700 total) and constructed training sets from the remaining curves as uniformly as possible; again, we averaged over five random draws. To assess generalizability across different cell types or Hertzian modulus quartiles, the model was trained on all curves in the designated training set and evaluated on the entire test set. In contrast, self-self evaluations applied the usual fivefold cross-validation within each group, whereas cross-group evaluations used no fold splitting.
SHAP feature attribution
Shapley additive explanations (SHAPs) were computed for the final COBRA regression and classification networks with GradientExplainer (25). Each model was trained on the full dataset except for 1000 curves that were held out exclusively for interpretation; 700 of these curves defined the background distribution, and the remaining 300 formed the test set. For every test curve, the explainer produced a three-dimensional attribution map (curves × spatial samples × channels). We took the absolute SHAP magnitudes and averaged them across the spatial dimension to obtain per-curve importance scores for the six input channels.
Deflection-amount analysis
To assess how limiting the available deflection range influences CP prediction, the COBRA regression network was first trained (fivefold cross-validation) on the full-length, untruncated deflection from all indentations with >40 nm of deflection (all cell types except the iPSC-derived vascular smooth muscle cells, VSMCs). After training, each fold’s model was evaluated on versions of its own test curves that had been truncated at predefined maximum deflection values. Following truncation, the shortened traces were resampled, normalized, and feature engineered with the same preprocessing pipeline used for the original data; the network weights were not re-optimized. Any change in cross-validated MAE therefore reflects the model’s inherent robustness to progressively smaller deflection windows rather than differences in training data.
Prediction-time analysis
Regression and classification networks were first fitted on the full training set in both MATLAB and Python. After training, inference speed was assessed by bootstrapping: for each of 1000 iterations, 1000 curves were sampled without replacement from the complete dataset, fed to the frozen model, and the wall-clock time to produce all 1000 predictions was recorded (MATLAB tic/toc; Python time.perf_counter). The preprocessing time per 1000 curves was calculated in the same way, and the training time was measured over 10 independent runs on the entire dataset.
Fine-tuning
The pretrained COBRA regression network was adapted to a new domain, where indentations collected with a spherical probe on mouse vertebral-disk tissue (26) were processed using supervised fine-tuning. A total of 369 curves were manually annotated with contact points; 100 of these were randomly reserved as a fixed validation set. The remaining 269 curves formed the fine-tuning pool. For each training-size condition (e.g., 0, 25, 50 … 250 curves), the model weights were re-initialized from the original network and fine-tuned for 100 epochs with the same optimizer, learning-rate, and batch-size settings as the original training. Ten bootstrap draws with replacement were performed for every size.
All computational analyses for this study were performed on a Windows 10 workstation equipped with 192 GB DDR5 RAM, a 16-core AMD Ryzen 9 9950X CPU, and an NVIDIA RTX 4080 SUPER GPU (driver 561.09, CUDA runtime 12.6). MATLAB work used R2024b. Python work used Python 3.9.21 with the following key package versions: NumPy 1.24.3, SciPy 1.13.1, pandas 2.2.3, matplotlib 3.9.4, scikit-learn 1.6.1, SHAP 0.47.0, and TensorFlow 2.10.0 (compiled against CUDA Toolkit 11.2 and cuDNN 8.6.0). Unless otherwise specified, all plots report the mean ± the standard deviation.
Results
To evaluate the applicability of ML methods for CP identification and anomalous deflection curve rejection, we manually classified 5951 indentation curves as either accept or reject and annotated the CP in 5165 of them. We then computed the underlying elastic modulus using both Hertzian and the non-Hertzian pointwise methods. These data were collected from seven distinct cell lines: immortalized human podocytes; immortalized murine collecting duct epithelial cells; iPSC-derived VSMCs; and LM24, MCF7, MCF10A, and HEPG4 solid-tumor cell lines (Table 1). Complete probe and cantilever characteristics are provided in Table 2. First, we quantified the impact of small deviations from the annotated CP on the resulting modulus. Our analysis revealed that, for the fine-tip cantilevers used in these indentations, even deviations as small as 100 nm could lead to significant shifts in pointwise modulus, which is a commonly used non-Hertzian approach to estimate depth-dependent mechanical properties (27,28) as a function of indentation depth (Fig. 1 A). Next, we calculated the mean absolute percentage error (MAPE) in both the fitted Hertzian modulus and pointwise modulus at 500-nm depth as a function of CP. Our analysis showed that even a 100-nm deviation, on average, resulted in approximately a 20% error in the Hertzian modulus (Fig. 1 B). For the datasets that we have combined, we found that nearly 30% of all curves (1757 of 5951) were classified as anomalous and rejected. Anomalous curves had a substantial impact in elastography results, both for mapping topography (Fig. 1 C) and elasticity (Fig. 1 D). Various types of anomalous curves are shown in Fig. 1 E along with reasons for rejection.
Table 1.
Summary of the Training Dataset, Including Key Characteristics of the Input Data Used for Model Development
| Cell Type | Total | Unambiguous CP | Accepted | Rejected | Mean Hertzian Modulus, kPa (SD) |
|---|---|---|---|---|---|
| LM24 | 480 | 327 | 292 | 188 | 1.5 (1.1) |
| MCF10a | 480 | 369 | 356 | 124 | 2.0 (1.5) |
| HEPG4 | 480 | 427 | 394 | 86 | 2.2 (2.6) |
| MCF7 | 480 | 434 | 394 | 86 | 2.3 (1.3) |
| Tubule | 2048 | 1756 | 1289 | 759 | 4.0 (4.3) |
| Podocyte | 1184 | 1091 | 899 | 285 | 15.9 (12.8) |
| iPSC VSMC | 799 | 761 | 570 | 229 | 16.0 (13.2) |
| Total | 5951 | 5165 | 4194 | 1757 | 7.7 (10.4) |
Figure 1.
Accurate identification of the CP is crucial for reliable biomechanical analysis. (A) A representative deflection curve on a podocyte illustrating that small deviations from the manually annotated contact point can drastically shift the calculated pointwise modulus. (B) Average errors in both the Hertzian modulus and pointwise modulus at the indentation depth of 500 nm as a function of contact-point error for all regression data in this study. (C) Representative height and (D) elastography images showing erroneous indentations leading to miscalculated height and modulus values using the SNAP method of contact-point identification in a monolayer of kidney tubular epithelial cells. (E) Representative examples of anomalous deflection curves that deviate markedly from typical behavior.
Next, we designed and tested neural networks incorporating long short-term memory layers for CP prediction and evaluated their performance against both conventional and ML-based methods. Our optimal model featured two convolutional blocks, comprising a convolutional layer, batch normalization, rectified linear unit (ReLU) activation, and maximal pooling followed by a BiLSTM layer. A global average pooling layer then condensed the extracted features, which were passed through a fully connected layer with ReLU activation and a final output layer (Fig. 2 A). Minor variations in the architecture or hyperparameters did not yield significant performance improvements. However, incorporating secondary features derived from the deflection curves enhanced prediction accuracy. Specifically, we extracted additional features from each normalized deflection curve, including a smoothed version of the curve, its smoothed first derivative, the local RoV, the local slope, and the R2 value of the local slope.
Figure 2.
COBRA outperforms other contact-point prediction methods, and it can identify anomalous indentation curves. (A) Architecture of the proposed COBRA neural network, consisting of two convolutional blocks, a BiLSTM layer with sequence output, a global average pooling layer, and fully connected layers. For regression, a single output layer is used, whereas, for classification, a two-output layer followed by softmax activation is employed. (B) Top: parity graphs of predicted CP and Hertzian modulus for multiple estimation methods. Bottom: histograms of error distribution overlaid with scaled kernel density estimates. Neural-network results are aggregated over fivefold cross-validation. (C) Receiver operating characteristic (ROC) curves for training and test sets across five folds of cross-validation for COBRA. (D) A representative deflection curve where predictions from various estimation methods for the CP are superimposed.
When benchmarked against other existing methods for CP identification, our one-dimensional BiLSTM-based model, COBRA, produced superior results compared to the next-best-performing method, ResNet50-1D. Specifically, COBRA achieved an average MAE of 28 ± 3 nm or an MAPE of 0.39% ± 0.04%, substantially lower than the 36 ± 10 nm MAE or 0.53% ± 0.15% MAPE obtained by ResNet50-1D. COBRA also yielded a significantly reduced downstream MAPE in the Hertzian modulus of 5.3% ± 0.67%, compared to the 7.3% ± 2.2% observed for ResNet50-1D (Table 3). When analyzing predicted versus actual CPs and Hertzian moduli, COBRA provided the most consistent predictions, exhibiting a narrow, prominent peak around zero in its error histogram (Fig. 2 B). Furthermore, by modifying the final layer of COBRA to output two classes and applying a softmax activation, which converts raw output scores into normalized probabilities, we repurposed the same architecture for classification and obtained an average AUC of 0.92 (across five cross-validation folds) of the receiver operating characteristic curve for detecting anomalous deflection curves (Fig. 2 C). A representative force-indentation curve with predictions of CPs for each network is illustrated in Fig. 2 D.
Table 3.
Comparison of CP and Modulus Statistics across Different CP Prediction Methods
| Method | RoV (Best Interval Size) | SNAP | Bidomain Linear-Quadratic | ConvNet-1D | ResNet50-1D | COBRA |
|---|---|---|---|---|---|---|
| MAE CP (nm) | 2984 | 124 | 71 | 87 (17.2) | 36 (9.9) | 28 (2.7) |
| MAPE CP (%) | 39 | 1.8 | 1.0 | 1.1 (0.18) | 0.53 (0.15) | 0.39 (0.036) |
| MSE CP (normalized) | 0.22 | 1.2e−03 | 4.4e−04 | 4.9e−04 (2.5e−04) | 1.2e−04 (9.0e−05) | 8.3e−05 (2.3e−05) |
| MSE CP (nm2) | 1.5e+07 | 7.1e+04 | 3.4e+04 | 2.9e+04 (2.0e+04) | 7.5e+03 (7.3e+03) | 5.1e+03 (1.71e+03) |
| MAPE Hertzian modulus (%) | 80.6 | 25.8 | 12.0 | 15.7 (1.6) | 7.3 (2.2) | 5.3 (0.67) |
| MAPE 500 nm pointwise modulus (%) | 90.7 | 32.1 | 17.8 | 18.5 (1.12) | 9.5 (1.85) | 7.4 (1.10) |
Results for neural-network-based methods are averaged across five folds of cross-validation and presented with the mean (standard deviation).
To assess practical limitations on performance and generalizability, we evaluated model accuracy as a function of training set size using a 1000-curve holdout spanning all cell types. Our analysis revealed that 2000 training curves were sufficient to achieve an AUC of ∼0.90 (Fig. 3 A), with a CP MAE under 50 nm and a Hertzian modulus MAPE below 10% (Fig. 3 B). However, this evaluation incorporated data from all cell types, prompting us to examine the effect of training set diversity on performance. To this end, we constructed learning curves by varying the number of cell types included in the training data and evaluated performance on a 700-curve holdout set equally distributed across all cell types. Models trained on data from a greater number of cell types consistently exhibited improved performance compared to models trained on fewer cell types, with higher AUCs (Fig. 3 C) and lower CP MAE and modulus MAPE (Fig. 3 D).
Figure 3.
Diversity in the training data increases the generalizability of COBRA. Learning curves for COBRA across the entire dataset appear in (A) area under the curve (AUC) and (B) contact-point mean absolute error (MAE) and Hertzian modulus mean absolute percentage error (MAPE) values validated with a holdout set of 1000 curves. (C) AUC and (D) contact-point MAE and modulus MAPE values for learning curves when different numbers of cell types are used. Each subset is tested on a random 100-curve holdout from each cell type. Generalizability of the approach is tested by training COBRA with one cell type and computing (E) AUC and (F) contact-point MAE or Hertzian modulus MAPE values for another cell type. Additionally, (G) AUC and (H) contact-point MAE or Hertzian modulus MAPE values are computed when COBRA is trained and tested on samples of varying elastic modulus showing the operationality of the system across different stiffness regimes. Symbols denote the mean, and error bars represent ±standard deviation.
Next, we evaluated generalizability across cell types by training the model on all curves from a single cell type and testing it on curves from all other cell types. Although performance was generally strong, albeit lower than models trained on the full dataset, AUC (Fig. 3 E) and CP/modulus metrics (Fig. 3 F) remained stable across most cell types, except for iPSC-derived VSMCs. Notably, models trained exclusively on other cell types struggled to generalize to iPSC-derived VSMCs. This observation suggested that differences in mechanical properties between training and test sets could impact performance. To investigate this further, we divided the dataset into Hertzian modulus quartiles and performed pairwise test-train evaluations. We found that both anomalous curve classification performance (Fig. 3 G) and contact-point/modulus predictions (Fig. 3 H) deteriorated as the stiffness difference between training and test sets increased, highlighting a key factor influencing model generalizability.
In addition to having a higher Hertzian modulus than the other cell types, the maximum amount of deflection in the iPSC-derived VSMCs was also lower (approximately 20 nm, whereas all other training sets had at least 40 nm of deflection), which led us to investigate how capturing more deflection and deeper indentations may impact the model. Using all cell types except the iPSC-derived VSMCs, we trained the COBRA regression model on the full-length deflection curves and then predicted the CP on truncated deflection curves across five folds of cross-validation (Fig. 4 A). We found that the truncated deflection curves had more error, especially the 15-nm group; however, this error quickly decreased with increased amount of maximum deflection. Although insufficient indentation depth may negatively impact prediction accuracy, trimming post-contact segments with late-stage artifacts, such as substrate-induced stiffening or probe slippage, could have the opposite effect on classification accuracy. To test this, we used the classification network to evaluate truncated force curves. In Fig. 4 B an example deflection-extension trace is displayed together with the probability of classifying the truncated curve as anomalous, evaluated as more of the post-contact segment is included in analysis. Using a decision threshold by the minimal-distance criterion, i.e., the closest point to [0, 1] on the training receiver operating characteristic curve (29,30), we show that probability of rejecting the curve switches to 1 at the point of probe slippage. This shows that, by trimming each trace at the anomalous point, we can automatically remove spurious post-contact segments before any downstream analysis.
To evaluate COBRA on data far outside its training domain, we used 369 force curves from a published mouse intervertebral-disk-tissue dataset performed by another group (26), using a large-radius (2.25 μm) spherical tip and a substantially stiffer cantilever that produced much greater deflection (approximately 100 nm) (Table 2). After manually annotating the contact points, we held out 100 curves for validation and fine-tuned a pretrained regression network on the remaining curves in progressively larger subsets (Fig. 4 C). Without any fine-tuning, COBRA’s MAE on this dataset was 800 nm with a corresponding Hertzian modulus MAPE of 12.5%. Adapting the weights with as few as 25 curves cut the error in half and using 250 curves reduced the MAE to approximately 306 ± 58 nm with a corresponding Hertzian modulus MAPE of 5.6% ± 1.1% (similar to MAPE of 5.3% ± 0.7% in cell indentations). Even though this absolute error in the CP exceeds the value reported for the original cell-indentation experiments, the higher absolute uncertainty is expected because the tip radius is two orders of magnitude larger, and both the extension and deflection ranges are substantially greater in the disk-tissue measurements.
To determine which input features drive the network’s decisions, we computed mean absolute SHAPs for the trained COBRA model (31,32,33). All usable curves were used for training except a separate holdout of 1000 curves (700 for the SHAP background distribution, 300 for evaluation). GradientExplainer, a SHAP variant appropriate for deep neural networks that yields expected gradients (25), returned a 300 × 2000 × 6 attribution tensor that we averaged along the spatial axis. The local R2 channel, which is the coefficient of determination obtained from fitting a straight line to a 35-sample sliding window of the deflection signal, was by far the most influential feature in both the regression (Fig. 4 D) and classification tasks (Fig. 4 E). For both regression and classification, other features contributed significantly less, particularly the raw deflection, smoothed deflection, and RoV (p < 0.01, one-way ANOVA with post hoc Tukey test). However, for classification, the smoothed first derivative and the local slope also had significantly higher contributions to determining the output.
We also evaluated COBRA’s runtime performance on a standard PC workstation. Prediction of the CP for 1000 curves required approximately 1.1 s in MATLAB and 0.5 s in Python, whereas classifications of 1000 curves were performed under 1 s in MATLAB and under 0.5 s in Python. Training the regression network on the complete cell-indentation dataset took 1136 ± 65 s in MATLAB versus 1077 ± 78 s in Python, whereas training the classification network required 172 ± 2 s in MATLAB and 199 ± 19 s in Python. Preprocessing 1000 raw curves (feature extraction and normalization) took 0.145 ± 0.013 s in MATLAB and 0.952 ± 0.100 s in Python. These results show that COBRA delivers sub-second inference for large batches and that end-to-end training remains tractable on a single desktop machine.
Finally, we assessed annotation reproducibility by having a second expert label the contact points in 2435 curves. The agreement between two experts was strong with a median absolute error of 20 nm and an interquartile range of 50 nm. A majority of indentations had a CP assignment difference that is less than 20 nm (Fig. 4 F). We then split those curves equally into training and validation sets. Although the original COBRA model exhibited an average MAE of 67 nm relative to the second expert’s annotations, fine-tuning the model with as few as 50 annotations from the second expert (Fig. 4 G) reduced the error to 41 nm (compared to average MAE of 28 nm for the first expert).
Discussion
We report a new neural-network architecture, COBRA, that simultaneously predicts the CP in AFM deflection curves and discriminates between high- and low-quality anomalous force curves. To the best of our knowledge, our extensive validation and quality control on over 5000 curated indentation curves from seven different cell types represents the first generalizable non-Hertzian AFM biomechanical analysis. Compared to earlier approaches, which were validated on a limited range of cell types or on hydrogels, our approach does not rely on biomechanical substrate homogeneity, consistently outperforms traditional curve-fitting methods as well as other neural-network models as shown by significantly reduced errors in CP and modulus estimations, and enables near-real-time automated analysis of biomechanical properties. We noted that accuracy of CP prediction was not cell-type dependent; however, previously published iPSC-derived VSMCs in our cohort consistently underperformed if they were used to predict CP in other cell types. We think that this discrepancy mostly stemmed from the lower indentation depth probed in these cells.
A major advantage of our approach is its dual capability. First, it provides highly accurate and consistent CP prediction without relying on a priori assumption of depth-dependent material homogeneity that is frequently violated in the complex, heterogeneous mechanical environments of cells (34,35). Second, the same model architecture effectively identifies anomalous deflection curves, streamlining data curation and reducing the subjectivity inherent in manual (and, in certain cases, curve-fitting) analyses. Notably, our training criteria for anomaly detection were intentionally stringent. For example, even in cases where most of the indentation appeared acceptable, minor probe slippage toward the end of the curve led to exclusion. This rigorous filtering not only ensures the reliability of our dataset but also demonstrates that the model can be readily retrained, based on alternative training data, to adopt different classification criteria or target other features of interest. The provided MATLAB code includes a graphical user interface and a sample fine-tuning script that facilitates human-in-the-loop training, enabling fine-tuning of the general model on a smaller, user-specific training dataset, a strategy that has proved effective in deep-learning-based segmentation models (36,37).
Although Hertzian modulus values are widely reported in AFM elastography (38,39,40,41) as they capture the average mechanical behavior, our approach enables accurate and reproducible characterization of depth-dependent pointwise modulus with improved performance compared to conventional methods. As we show in Table 3, the non-Hertzian pointwise method is more susceptible to CP-related inaccuracies. As such, our method is essentially necessary for high-throughput non-Hertzian analysis of cell biomechanics. We still report the fitted Hertzian modulus here for adaptability and ease of comparison. Our method’s robust ability to detect and flag anomalous force curves has practical applications beyond CP identification. For example, it can be applied to “clean up” height maps in topographical analyses: rejected points due to poor-quality indentation can be automatically interpolated, yielding a more accurate representation of the sample’s overall topography. Moreover, for elastic-modulus measurements, anomalous curves can be automatically trimmed, increasing the effective sample size and maximizing the information gained from each AFM run (Fig. 4 B).
The integration of convolutional and BiLSTM layers in our model allows us to leverage both spatial and sequential features inherent in AFM force curves. This results in robust CP detection and modulus estimation even across a broad spectrum of cell types with varying mechanical properties. We note that, although our pretrained models can essentially be implemented with minimal user intervention in an automated manner, to obtain minimal error in context-specific manner, human-in-the-loop training may be necessary. Therefore, although our results are promising, further studies are warranted to validate complete generalizability of our approach under diverse experimental conditions. We also note that a major limitation of this study is that our results rely on “ground truth” that was determined by only two expert operators and not thoroughly vetted by a wider community. In addition, although we have tested our pretrained model on an independent dataset, our external validation remains limited. Future work will explore real-time data processing, greater validation, incorporation of additional biophysical features to further enhance predictive accuracy, and calculation of other biophysical behaviors of interest such as adhesion or viscoelasticity.
In summary, we present an integrated ML framework that represents a significant step forward for AFM elastography. As noted by Thorpe and colleagues (42), integration of ML methods with AFM analytics could enable wider adoption of the technique and its use in clinical settings, reducing reliance on manual curation and overcoming the limitations of classical models. Our method not only improves the reproducibility and reliability of cellular mechanical property measurements but also paves the way for more accurate and automated mechanobiology studies that are accessible to biologists without specialized training in biophysics.
Data and code availability
All annotated code and data (as MAT files) used in this manuscript are freely available through Zenodo repository DOI at 10.5281/zenodo.15272309. For file processing, the raw ARDF files were converted to HDF5 format using an executable from the Asylum Research forums (also included in the repository) and then imported into MATLAB.
Acknowledgments
This study was funded by NIH grants R01 DK118222 and R01 DK131047 and Department of Defense grant W81XWH-20-1-0837 (E.U.A.). J.H. was partially funded by T32 HD075735. We would like to acknowledge Jacob Wright, Dr. Miran Yoo, Dr. Smiti Bhattacharya, and Dr. Luca Gusella for technical assistance with cell culture; Dr. Robert Wiener and Dr. Kevin Costa for their help with access to their published datasets and for the use of Mount Sinai Atomic Force Microscopy Core Facility, which was funded by the NIH S10 RR027609; and the peer reviewers of this manuscript for their valuable suggestions.
Author contributions
J.H. designed, tested, and validated all computational analysis methods; prepared all the figures; and wrote the initial draft. E.U.A. performed AFM indentations and secured funding and resources. J.H. and E.U.A. jointly conceived the project and wrote the paper.
Declaration of interests
The authors are inventors on a pending patent application related to the technology discussed in this paper.
Editor: Guy Genin.
References
- 1.Radmacher M. Measuring the elastic properties of living cells by the atomic force microscope. Methods Cell Biol. 2002;68:67–90. doi: 10.1016/s0091-679x(02)68005-7. [DOI] [PubMed] [Google Scholar]
- 2.Binnig G., Quate C.F., Gerber C. Atomic Force Microscope. Phys. Rev. Lett. 1986;56:930–933. doi: 10.1103/PhysRevLett.56.930. [DOI] [PubMed] [Google Scholar]
- 3.Petersen N.O., McConnaughey W.B., Elson E.L. Dependence of locally measured cellular deformability on position on the cell, temperature, and cytochalasin B. Proc. Natl. Acad. Sci. USA. 1982;79:5327–5331. doi: 10.1073/pnas.79.17.5327. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4.A-Hassan E., Heinz W.F., et al. Hoh J.H. Relative Microelastic Mapping of Living Cells by Atomic Force Microscopy. Biophys. J. 1998;74:1564–1578. doi: 10.1016/S0006-3495(98)77868-3. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5.Ge X., Zhang T., et al. Azeloglu E.U. LIM-Nebulette Reinforces Podocyte Structural Integrity by Linking Actin and Vimentin Filaments. J. Am. Soc. Nephrol. 2020;31:2372–2391. doi: 10.1681/ASN.2019121261. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 6.Azeloglu E.U., Costa K.D. In: Atomic Force Microscopy in Biomedical Research: Methods and Protocols. Braga P.C., Ricci D., editors. Humana Press; Totowa, NJ: 2011. Atomic Force Microscopy in Mechanobiology: Measuring Microelastic Heterogeneity of Living Cells; pp. 303–329. [DOI] [PubMed] [Google Scholar]
- 7.Crick S.L., Yin F.C.P. Assessing Micromechanical Properties of Cells with Atomic Force Microscopy: Importance of the Contact Point. Biomech. Model. Mechanobiol. 2007;6:199–210. doi: 10.1007/s10237-006-0046-x. [DOI] [PubMed] [Google Scholar]
- 8.Gavara N. Combined strategies for optimal detection of the contact point in AFM force-indentation curves obtained on thin samples and adherent cells. Sci. Rep. 2016;6 doi: 10.1038/srep21267. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 9.Schillers H., Rianna C., et al. Radmacher M. Standardized Nanomechanical Atomic Force Microscopy Procedure (SNAP) for Measuring Soft and Biological Samples. Sci. Rep. 2017;7:5117. doi: 10.1038/s41598-017-05383-0. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 10.Chang Y.-R., Raghunathan V.K., et al. Murphy C.J. Automated AFM force curve analysis for determining elastic modulus of biomaterials and biological samples. J. Mech. Behav. Biomed. Mater. 2014;37:209–218. doi: 10.1016/j.jmbbm.2014.05.027. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11.Paranjpe I., Wang X., et al. Azeloglu E.U. Deep learning on electronic medical records identifies distinct subphenotypes of diabetic kidney disease driven by genetic variations in the Rho pathway. medRxiv. 2023 doi: 10.1101/2023.09.06.23295120. Preprint at. [DOI] [Google Scholar]
- 12.He K., Zhang X., Sun J., et al. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. IEEE; 2016. Deep residual learning for image recognition. [Google Scholar]
- 13.Masud N., Rade J., et al. Sarkar A. Machine learning approaches for improving atomic force microscopy instrumentation and data analytics. Front. Physiol. 2024;12 doi: 10.3389/fphy.2024.1347648. [DOI] [Google Scholar]
- 14.Sotres J., Boyd H., Gonzalez-Martinez J.F. Locating critical events in AFM force measurements by means of one-dimensional convolutional neural networks. Sci. Rep. 2022;12 doi: 10.1038/s41598-022-17124-z. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 15.Nguyen L.T.P., Liu B.H. Machine learning approach for reducing uncertainty in AFM nanomechanical measurements through selection of appropriate contact model. Eur. J. Mech. Solid. 2022;94 doi: 10.1016/j.euromechsol.2022.104579. [DOI] [Google Scholar]
- 16.Nguyen L.T.P., Liu B.H. Machine learning framework for determination of elastic modulus without contact model fitting. Int. J. Solid Struct. 2022;256 doi: 10.1016/j.ijsolstr.2022.111976. [DOI] [Google Scholar]
- 17.Müller P., Abuhattum S., et al. Guck J. nanite: using machine learning to assess the quality of atomic force microscopy-enabled nano-indentation data. BMC Bioinf. 2019;20:465. doi: 10.1186/s12859-019-3010-3. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 18.Stashko C., Hayward M.-K., et al. Weaver V.M. A convolutional neural network STIFMap reveals associations between stromal stiffness and EMT in breast cancer. Nat. Commun. 2023;14:3561. doi: 10.1038/s41467-023-39085-1. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 19.Hochreiter S., Schmidhuber J. Long Short-Term Memory. Neural Comput. 1997;9:1735–1780. doi: 10.1162/neco.1997.9.8.1735. [DOI] [PubMed] [Google Scholar]
- 20.Greff K., Srivastava R.K., et al. Schmidhuber J. LSTM: A search space odyssey. IEEE Transact. Neural Networks Learn. Syst. 2016;28:2222–2232. doi: 10.1109/TNNLS.2016.2582924. [DOI] [PubMed] [Google Scholar]
- 21.Graves A., Schmidhuber J. Framewise phoneme classification with bidirectional LSTM and other neural network architectures. Neural Netw. 2005;18:602–610. doi: 10.1016/j.neunet.2005.06.042. [DOI] [PubMed] [Google Scholar]
- 22.Wiener R.J., Orins H., Costa K.D. Intrinsic Mechanics of Human Stem Cell Derived Aortic Smooth Muscle Cells Support a Developmental Basis for Aneurysm Localization in Marfan Syndrome. bioRxiv. 2023 doi: 10.1101/2023.10.03.560723. Preprint at. [DOI] [Google Scholar]
- 23.Bhattacharya S., Ettela A., et al. Azeloglu E.U. A high-throughput microfabricated platform for rapid quantification of metastatic potential. Sci. Adv. 2024;10 doi: 10.1126/sciadv.adk0015. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 24.Azeloglu E.U., Costa K.D. Cross-bridge cycling gives rise to spatiotemporal heterogeneity of dynamic subcellular mechanics in cardiac myocytes probed with atomic force microscopy. Am. J. Physiol. Heart Circ. Physiol. 2010;298:H853–H860. doi: 10.1152/ajpheart.00427.2009. [DOI] [PubMed] [Google Scholar]
- 25.Lundberg S.M., Lee S.-I. Vol. 30. 2017. A unified approach to interpreting model predictions. (Advances in Neural Information Processing Systems). [Google Scholar]
- 26.D’Erminio D.N., Adelzadeh K.A., et al. Iatridis J.C. Regenerative potential of mouse neonatal intervertebral disc depends on collagen crosslink density. iScience. 2024;27 doi: 10.1016/j.isci.2024.110883. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 27.Costa K.D., Sim A.J., Yin F.C.P. Non-Hertzian approach to analyzing mechanical properties of endothelial cells probed by atomic force microscopy. J. Biomech. Eng. 2006;128:176–184. doi: 10.1115/1.2165690. [DOI] [PubMed] [Google Scholar]
- 28.Costa K.D., Yin F.C. Analysis of indentation: implications for measuring mechanical properties with atomic force microscopy. J. Biomech. Eng. 1999;121:462–471. doi: 10.1115/1.2835074. [DOI] [PubMed] [Google Scholar]
- 29.Unal I. Defining an Optimal Cut-Point Value in ROC Analysis: An Alternative Approach. Comput. Math. Methods Med. 2017;2017 doi: 10.1155/2017/3762651. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 30.Zweig M.H., Campbell G. Receiver-operating characteristic (ROC) plots: a fundamental evaluation tool in clinical medicine. Clin. Chem. 1993;39:561–577. doi: 10.1093/clinchem/39.4.561. [DOI] [PubMed] [Google Scholar]
- 31.Lundberg S.M., Erion G., et al. Lee S.-I. From local explanations to global understanding with explainable AI for trees. Nat. Mach. Intell. 2020;2:56–67. doi: 10.1038/s42256-019-0138-9. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 32.Li Z. Extracting spatial effects from machine learning model using local interpretation method: An example of SHAP and XGBoost. Comput. Environ. Urban Syst. 2022;96 [Google Scholar]
- 33.Loh H.W., Ooi C.P., et al. Acharya U.R. Application of explainable artificial intelligence for healthcare: A systematic review of the last decade (2011–2022) Comput. Methods Progr. Biomed. 2022;226 doi: 10.1016/j.cmpb.2022.107161. [DOI] [PubMed] [Google Scholar]
- 34.Pogoda K., Jaczewska J., et al. Lekka M. Depth-sensing analysis of cytoskeleton organization based on AFM data. Eur. Biophys. J. 2012;41:79–87. doi: 10.1007/s00249-011-0761-9. [DOI] [PubMed] [Google Scholar]
- 35.Roduit C., Sekatski S., et al. Kasas S. Stiffness Tomography by Atomic Force Microscopy. Biophys. J. 2009;97:674–677. doi: 10.1016/j.bpj.2009.05.010. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 36.Pachitariu M., Stringer C. Cellpose 2.0: how to train your own model. Nat. Methods. 2022;19:1634–1641. doi: 10.1038/s41592-022-01663-4. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 37.Walker C., Talawalla T., et al. Janowczyk A. PatchSorter: a high throughput deep learning digital pathology tool for object labeling. npj Digit. Med. 2024;7:164. doi: 10.1038/s41746-024-01150-4. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 38.Abdallah M., Martin M., et al. Bechelany M. Influence of Hydrolyzed Polyacrylamide Hydrogel Stiffness on Podocyte Morphology, Phenotype, and Mechanical Properties. ACS Appl. Mater. Interfaces. 2019;11:32623–32632. doi: 10.1021/acsami.9b09337. [DOI] [PubMed] [Google Scholar]
- 39.Calizo R.C., Bhattacharya S., et al. Azeloglu E.U. Disruption of podocyte cytoskeletal biomechanics by dasatinib leads to nephrotoxicity. Nat. Commun. 2019;10:2061. doi: 10.1038/s41467-019-09936-x. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 40.Wyss H.M., Henderson J.M., et al. Miller R.T. Biophysical properties of normal and diseased renal glomeruli. Am. J. Physiol. Cell Physiol. 2011;300:C397–C405. doi: 10.1152/ajpcell.00438.2010. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 41.Cook J.R., Carta L., et al. Ramirez F. Abnormal muscle mechanosignaling triggers cardiomyopathy in mice with Marfan syndrome. J. Clin. Investig. 2014;124:1329–1339. doi: 10.1172/JCI71059. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 42.O’Dowling A.T., Rodriguez B.J., et al. Thorpe S.D. Machine learning and artificial intelligence: Enabling the clinical translation of atomic force microscopy-based biomarkers for cancer diagnosis. Comput. Struct. Biotechnol. J. 2024;24:661–671. doi: 10.1016/j.csbj.2024.10.006. [DOI] [PMC free article] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Data Availability Statement
All annotated code and data (as MAT files) used in this manuscript are freely available through Zenodo repository DOI at 10.5281/zenodo.15272309. For file processing, the raw ARDF files were converted to HDF5 format using an executable from the Asylum Research forums (also included in the repository) and then imported into MATLAB.




