This study aims to explore whether personalized external diaphragm pacing (EDP) guided by real-time diaphragm ultrasound (DU) can improve outcomes for patients on invasive mechanical ventilation. Diaphragm ultrasound will be used to assess each patient's diaphragm function and adjust the pacing intensity, creating a customized treatment plan. By using this individualized approach, the investigators hope to prevent diaphragm muscle weakening, which is a common issue during prolonged ventilation, and improve the chances of successful weaning from the ventilator. The study will also incorporate advanced diaphragm function metrics, such as diaphragm thickening fraction (DTF) and diaphragmatic rapid shallow breathing index (D-RSBI), to enhance the accuracy of treatment and improve patient recovery. This trial aims to improve overall outcomes and quality of care for patients requiring long-term mechanical ventilation.