---
title: 'SurgeryLSTM: Attention-Based BiLSTM for LOS'
url: https://www.emergentmind.com/topics/surgerylstm
type: topic
---

# SurgeryLSTM: Attention-Based BiLSTM for LOS

Searching arXiv for recent and foundational papers on SurgeryLSTM and related surgical LNN/LSTM models.
SurgeryLSTM denotes, in the narrow and paper-specific sense, the masked bidirectional long short-term memory model with attention proposed for predicting hospital length of stay after elective spine surgery from structured perioperative electronic health records [2507.11570]. In broader surgical-AI usage, the term also evokes a family of LSTM-centered sequence models used for surgical activity recognition, workflow analysis, duration estimation, tool-use inference, and early procedure understanding across kinematics, laparoscopic video, open-surgery video, and EHR streams [1606.06329] [1805.08569]. The named model is therefore both a specific architecture and a late instance of a longer methodological lineage in which surgery is represented as a temporally ordered process rather than as a static classification problem.

## 1. Terminological scope and historical position

The only paper in the supplied corpus whose title explicitly contains “SurgeryLSTM” is “SurgeryLSTM: A Time-Aware Neural Model for Accurate and Explainable Length of Stay Prediction After Spine Surgery” [2507.11570]. That model addresses elective spine surgery and predicts postoperative length of stay, not surgical phase, tool, or gesture labels.

At the same time, LSTM-based surgical sequence modeling predates that paper by several years. An early example is recurrent recognition of surgical activities from da Vinci robot kinematics, where forward LSTM was used for online recognition and bidirectional LSTM for offline recognition of gestures and maneuvers [1606.06329]. In laparoscopic workflow analysis, CNN-LSTM pipelines became standard for phase recognition, including end-to-end self-supervised pre-training via remaining surgery duration prediction [1805.08569] and teacher/student training under scarce manual annotations [1812.00033]. This broader context suggests that “SurgeryLSTM” is best read as a model name embedded in an established LSTM-based surgical sequence-analysis tradition rather than as an isolated architectural invention.

## 2. Clinical objective, cohort, and target variable

In its specific 2025 usage, SurgeryLSTM is a model for predicting length of stay after elective spine surgery using preoperative structured EHR data [2507.11570]. The clinical motivation is operational as well as prognostic: length of stay affects bed availability, staffing, discharge planning, postoperative rehabilitation coordination, and cost control.

The study is a retrospective observational analysis using EHR data from the University of California Irvine Health / UCI Medical Center over 2018–2023. Patients were included if they were age 18 or older, underwent spine surgery, had one of a specified set of CPT codes, and were admitted through planned surgery; patients admitted via the emergency department or outside the study period were excluded. After applying these criteria, 2,077 patients were included. The target variable was LOS in days, defined from surgery date to discharge date [2507.11570].

The LOS distribution was right-skewed. Most patients were discharged within the first few postoperative days: 21% on day 1, 17% on day 3, and 12% on day 5. Beyond 10 days, the count dropped markedly, and fewer than 3% remained hospitalized beyond two weeks. For visualization, LOS was limited to 0–20 days, which covered 2,056 of 2,077 patients; LOS \(> 20\) days were treated as outliers for the visualization. The manuscript also alternates between LOS as a continuous outcome and LOS “categories” or “classes.” Because the reported evaluation uses MAE, MSE, RMSE, and \(R^2\), the main experiments appear regression-oriented. This suggests a residual ambiguity between modeling language and final evaluation protocol rather than a purely categorical formulation [2507.11570].

## 3. Sequence construction, masking, and attention-based BiLSTM formulation

SurgeryLSTM treats the patient’s preoperative course as a time-ordered sequence rather than a static feature bundle [2507.11570]. The EHR data included demographics, diagnosis information via ICD-10 codes, surgical details including surgery dates and surgery codes, laboratory data including lab test type, test date, and test value, and admission and discharge data. Through clinically guided feature selection, the authors selected the 50 most frequently ordered lab tests based on diagnostic relevance and correlation patterns and, with input from two surgeons, finalized 647 features. These included demographics, diagnosis codes, surgery codes, admission/discharge-related variables, and lab results.

The preprocessing pipeline is designed around temporal alignment and leakage prevention. Diagnosis and surgery codes were standardized using ICD-10 and CPT classifications; categorical variables were one-hot encoded; gender was binary encoded as \(0 =\) male and \(1 =\) female; lab results were categorized into high, low, and normal; and continuous variables such as age were scaled with Robust Scaler to reduce outlier influence. All postsurgical information was excluded to avoid data leakage. Temporal variables were normalized relative to the surgery date so that different patients’ timelines were aligned chronologically. Missing lab values were imputed with the mean if the majority reference range for a lab indicated “Normal,” and otherwise with the median; lab types with 100% missingness were removed [2507.11570].

The temporal representation uses fixed-length sequences built from variable-length histories. Timestamps such as lab result dates were transformed into relative differences from the surgery date, data were sorted by patient ID and time, and for LSTM models the time difference was included as a time-step identifier. Because patients had different numbers of recorded preoperative events, the authors used a sliding window approach to construct fixed-length sequences, zero-padding for shorter sequences, and a masking layer so padded positions would be ignored during training. The sequence length was set to 14 days, chosen based on the 75th percentile of patient record lengths. The paper gives the window as
\[
S_t = [x_t, \ldots, x_{t+13}],
\]
with overlapping sequences generated with stride 1 when more than 14 recorded events were available [2507.11570].

Architecturally, SurgeryLSTM is a masked BiLSTM with attention. The paper does not print explicit equations in the body text. A standard formulation consistent with the description is:
\[
i_t = \sigma(W_i x_t + U_i h_{t-1} + b_i), \quad
f_t = \sigma(W_f x_t + U_f h_{t-1} + b_f),
\]
\[
o_t = \sigma(W_o x_t + U_o h_{t-1} + b_o), \quad
\tilde{c}_t = \tanh(W_c x_t + U_c h_{t-1} + b_c),
\]
\[
c_t = f_t \odot c_{t-1} + i_t \odot \tilde{c}_t, \quad
h_t = o_t \odot \tanh(c_t).
\]
For bidirectional encoding,
\[
\overrightarrow{h_t} = \mathrm{LSTM}_{f}(x_t, \overrightarrow{h}_{t-1}), \qquad
\overleftarrow{h_t} = \mathrm{LSTM}_{b}(x_t, \overleftarrow{h}_{t+1}),
\]
and
\[
h_t = [\overrightarrow{h_t}; \overleftarrow{h_t}].
\]
If \(m_t \in \{0,1\}\) denotes the mask for real versus padded steps, then masked hidden states may be written as
\[
\hat{h}_t = m_t h_t.
\]
A standard attention formulation consistent with the paper description is
\[
e_t = v^\top \tanh(W_a \hat{h}_t + b_a), \qquad
\alpha_t = \frac{\exp(e_t)}{\sum_{k=1}^{T} m_k \exp(e_k)},
\]
\[
c = \sum_{t=1}^{T} \alpha_t \hat{h}_t, \qquad
\hat{y} = W_y c + b_y.
\]
The “time-aware” aspect is explicitly not a specialized time-decay LSTM or irregular-time recurrent formulation; it is operationalized through temporal ordering and relative time-to-surgery encoding rather than a custom time gate [2507.11570].

## 4. Empirical performance and explainability

The empirical comparison in the SurgeryLSTM paper includes linear regression, random forest, support vector machine, XGBoost, a masked BiLSTM without attention, and SurgeryLSTM itself [2507.11570].

| Model | MAE / MSE / RMSE | \(R^2\) |
|---|---|---:|
| Linear Regression | 2.68 / 21.99 / 4.69 | 0.55 |
| Random Forest | 2.69 / 19.64 / 4.43 | 0.60 |
| Support Vector Machine | 1.07 / 18.45 / 4.30 | 0.63 |
| XGBoost | 1.63 / 7.59 / 2.75 | 0.85 |
| Masked BiLSTM without attention | 2.73 / 23.73 / 4.87 | 0.52 |
| SurgeryLSTM | 1.48 / 7.21 / 2.69 | 0.86 |

SurgeryLSTM achieved the highest predictive accuracy, with \(R^2 = 0.86\), slightly outperforming XGBoost at \(R^2 = 0.85\). The comparison with masked BiLSTM without attention is especially consequential: bidirectionality and masking alone were not sufficient, whereas the attention-equipped model produced the best reported result. The paper does not report formal statistical significance testing, confidence intervals, repeated-run variability, or external validation, so the margin over XGBoost is reported descriptively rather than inferentially [2507.11570].

Interpretability is addressed through two distinct mechanisms. First, SurgeryLSTM’s attention weights provide time-step-level explanation by indicating which temporal segments of the preoperative sequence were weighted most strongly when predicting LOS. The reported pattern is that attention weights generally peak near the surgery date, while earlier preoperative steps still retain nonzero weight. This suggests that immediate perioperative status is especially informative, but longer-range history also contributes. Second, SHAP was applied not to SurgeryLSTM itself, but to the XGBoost baseline. The SHAP summary plot highlighted the top 20 predictors of LOS, including bone disorder, chronic kidney disease, lumbar fusion, lumbar decompression, anterior spinal fusion / anterior fusion, additional spinal fusion, spinal instrumentation, cervical decompression, lumbar laminectomy, obesity, cancer metastasis, multiple myeloma, vitreous disorder, skin abscess, fatigue, BMI, age, ethnicity, race, sex, and zip code regions. The paper specifically states that bone disorder, chronic kidney disease, and lumbar fusion were among the most impactful predictors [2507.11570].

## 5. Relation to the broader SurgeryLSTM-style literature

Long before the named LOS model, LSTMs were used to map surgical time series into clinically structured outputs. In robotic surgery, recurrent models were applied to da Vinci kinematics for joint segmentation and classification of low-level gestures and higher-level maneuvers, with bidirectional LSTM slightly exceeding the previous best LC-SC-CRF on JIGSAWS and substantially improving maneuver recognition on MISTIC-SL [1606.06329]. In laparoscopic phase recognition, end-to-end CNN-LSTM training over full surgeries outperformed a frozen-CNN plus LSTM pipeline, and self-supervised pre-training via remaining surgery duration prediction reduced the need for manual annotations [1805.08569]. A related teacher/student formulation used a CNN-biLSTM-CRF teacher to generate synthetic labels and train an online CNN-LSTM student under low-label conditions [1812.00033].

The same design pattern also appears in duration and workflow prediction. A CNN-LSTM regressor for remaining surgery duration was improved by an unsupervised temporal video segmentation auxiliary task and by a corridor-based regression loss, yielding \(8.7 \pm 0.2\) min MAE in the best reported configuration [2002.11367]. Long-term context aggregation was later added to an LSTM backbone through a sufficient statistics model, improving phase recognition especially on shorter, more ambiguous phases in MGH100 [2009.00681]. In multitask video understanding, a ResNet-50 plus Bi-LSTM architecture jointly identified tools and phases and introduced a joint distribution loss over tool-phase co-occurrence, reporting tool average precision \(0.99\) and phase average precision \(0.857\) on Cholec80 [1905.08315].

Other task variants extend the same recurrent logic into distinct surgical settings. Short 10-second video shots were classified into laparoscopic phases using CNN features, elapsed time, and an LSTM, with ResNet101 + saliency + elapsed time + LSTM reaching 86% accuracy [1807.07853]. Cross-surgery transfer work evaluated bidirectional LSTM baselines and proposed TSAN as a stronger hybrid temporal model for workflow-step recognition across cholecystectomy, right hemicolectomy, sleeve gastrectomy, and appendectomy [2102.12308]. Open-surgery analysis used high-frequency and low-frequency LSTMs over multi-camera detector outputs to recover global tool-in-hand state under occlusion, with the final multi-camera classifier reaching accuracy \(0.93\) and weighted F1 \(0.94\) [2111.06098]. Early surgery-type recognition from laparoscopic video likewise used a CNN+LSTM pipeline and introduced a “Future-State Predicting LSTM,” reporting average accuracy of 75% after observing only the first 10 minutes of a surgery on Laparo425 [1811.11727]. Collectively, these works show that the named SurgeryLSTM paper is unusual mainly in modality and endpoint—structured perioperative EHR and LOS—rather than in its reliance on recurrent temporal abstraction.

## 6. Limitations, ambiguities, and common confusions

The named SurgeryLSTM study has several explicit limitations [2507.11570]. The cohort comes from one institution, so generalizability is uncertain. No external test set is reported, and the authors explicitly note that multi-institutional validation is needed. Important model details are missing, including exact final hyperparameter values, optimizer, hidden size, attention dimension, activation details in dense layers, the exact train/validation/test decomposition, and whether LOS was modeled strictly as regression or partly discretized into classes. The manuscript also alternates between LOS as a continuous outcome and LOS categories or classes, and it describes sequence targets as \(y_{t+14}\), which sounds like next-step forecasting even though the clinical task is overall postoperative LOS prediction. This suggests a degree of unresolved methodological ambiguity in the sequential formulation.

There are also fairness and deployment concerns. Race, ethnicity, sex, and zip code were included as predictors. The paper acknowledges mixed demographic effects but does not conduct fairness audits. Missingness, coding variation, and documentation inconsistency remain concerns even after imputation and masking. Because formal significance tests are absent, the reported edge over XGBoost should be read as an observed comparison rather than a stability claim [2507.11570].

A separate naming confusion arises with “Surgery” and “SurgeryV2.” Those methods address representation alignment in model merging-based multitask learning, use ViT and BERT backbones, and do not present any model called SurgeryLSTM or any LSTM-based architecture [2410.14389]. Within surgical AI, “SurgeryLSTM” therefore refers most precisely to the 2025 masked attention-based BiLSTM for LOS prediction, while more informal use points to the broader recurrent family of surgical sequence models spanning kinematics, video, and EHR. Future directions proposed for the named model include multi-institutional validation, integration of structured EHR with unstructured clinical notes, incorporation of natural language embeddings, real-time inference capability for operational deployment, integration into hospital dashboards, and use of large language models combined with structured data to improve risk assessment and interpretability [2507.11570].

Source: https://www.emergentmind.com/topics/surgerylstm