I want to make a case presentation on condition of stroke patient age 56 year male he having previously a stroke 1 year back then come to myh physiotherapy opd with complaint of right side tightness tone hypertonia postural abnormal make just like this and edit yourself accordingly to this condition

Reading File
Reading File
Running Command

cd /tmp/workspace/attachments/5cff7728-8801-4283-9a63-a51d9b3411f7 && python3 -c " from pptx import Presentation from pptx.util import Emu prs = Presentation('CASEPRESENTATION5.pptx') print(f'Total slides: {len(prs.slides)}') for i, slide in enumerate(prs.slides, 1): print(f'\n=== SLIDE {i} (layout: {slide.slide_layout.name}) ===') for shape in slide.shapes: pos = (round(Emu(shape.left).inches,2), round(Emu(shape.top).inches,2)) if shape.left is not None else None print(f' Shape: {shape.name} | Type: {shape.shape_type} | Pos: {pos}') if shape.has_text_frame and shape.text_frame.text.strip(): for para in shape.text_frame.paragraphs: if para.text.strip(): print(f' TEXT: {para.text}') "

Running Command

mkdir -p /tmp/workspace/stroke-case && cp /tmp/workspace/attachments/5cff7728-8801-4283-9a63-a51d9b3411f7/CASEPRESENTATION5.pptx /tmp/workspace/stroke-case/template.pptx && python /tmp/skills/pptx/scripts/office/unpack.py /tmp/workspace/stroke-case/template.pptx /tmp/workspace/stroke-case/unpacked/ && ls /tmp/workspace/stroke-case/unpacked/ppt/slides/

general-purpose

You are editing a PowerPoint presentation for a stroke patient case. The PPTX has already been unpacked to /tmp/workspace/stroke-case/unpacked/ppt/slides/. There are 36 slides. You need to replace ALL clinical content (originally about Lumbar Spondylosis in a 21-year-old male) with content about a **56-year-old male stroke patient** who: - Had a stroke 1 year ago - Presents to MYH Physiotherapy OPD on 25/06/2026 - Chief complaints: Right-side tightness, hypertonia (upper + lower limb), abnormal posture (hemiplegic posture) - Condition: Post-stroke spasticity with right hemiplegia Your task: Use Python string replacement to edit the text inside the XML slide files. Do NOT change any XML structure, fonts, colors, positions, or image elements. Only replace the visible text content between XML tags. Here is the complete content plan for each slide: **SLIDE 1** (Title slide): - Main title: "Physiotherapy Rehabilitation of Post-Stroke Hemiplegia in a 56-Year-Old Male" - Keep "MGM Allied Health Sciences Institute (MAHSI)", "Case Presentation", "Guided By - Dr. Usha Singh", "Presented By – Bhavesh Surah" and "(MPT NEURO)" as-is. **SLIDE 2** (Case Background): - Title: "CASE BACKGROUND" - Body: "Patient is 56 year old male who came to MYH OPD on 25/06/2026. Patient came with the complaint of right side tightness, hypertonia of right upper and lower limb, abnormal posture and inability to perform ADLs. He had a history of stroke 1 year back." **SLIDE 3** (Introduction/Condition): - Title: "INTRODUCTION" - Sub-heading: "STROKE (CEREBROVASCULAR ACCIDENT)" - Body: "Stroke = sudden interruption of blood supply to the brain causing neurological deficits. It is a leading cause of adult disability worldwide.\nCommon Consequences:\nRight hemiplegia – weakness/paralysis of right side.\nHypertonia / Spasticity – increased muscle tone due to upper motor neuron lesion.\nAbnormal posture – hemiplegic posture (flexed UL, extended LL).\nDecreased balance and coordination.\nImpaired ADL performance and gait." **SLIDE 4** (Anatomy): - Title: "ANATOMY" - Body: "The brain is the primary organ affected in stroke. Relevant structures include the motor cortex, internal capsule, corticospinal tract, and cerebellum. The right hemisphere controls left-sided movement; left hemisphere controls right-sided movement. The corticospinal tract carries voluntary motor signals; its damage causes upper motor neuron signs including spasticity, hypertonia, and abnormal reflexes." **SLIDE 5** (Cont. Components): - Title: "Cont…." - Body: "COMPONENTS\nCorticospinal Tract: Descending motor pathway; damage leads to spasticity and weakness.\nInternal Capsule: Dense white matter; most common site for ischemic stroke causing hemiplegia.\nMotor Cortex (Primary): Controls voluntary movements of contralateral limbs.\nBasal Ganglia: Involved in movement regulation; dysfunction causes rigidity and postural problems.\nCerebellum: Coordinates balance and smooth movement; affected in posterior circulation strokes.\nBrainstem: Controls vital functions; involvement causes severe deficits." **SLIDE 6** (Epidemiology): - Title: "EPIDEMIOLOGY OF STROKE" - Keep the table structure. Edit any visible text cells to stroke epidemiology data: - Incidence: ~13.7 million new strokes per year globally - Prevalence: ~101 million people living with stroke worldwide - Age group: Most common >55 years; risk doubles each decade after 55 - Sex: Slightly higher lifetime risk in women; higher age-adjusted incidence in men - Mortality: ~5.5 million deaths per year globally - Disability: Leading cause of long-term disability in adults **SLIDE 7** (Etiology / Risk Factors): - Title: "ETIOLOGY / RISK FACTORS" - Table content (risk factors for stroke): - Hypertension (most common modifiable risk factor) - Diabetes Mellitus - Atrial Fibrillation / Cardiac disease - Dyslipidemia / High cholesterol - Smoking and alcohol use - Obesity and sedentary lifestyle - Previous TIA or stroke history - Age > 55 years, male sex **SLIDE 8** (Subjective Assessment): - Title: "SUBJECTIVE ASSESSMENT" - Body: "● Name – XYZ ● Gender - Male ● Age - 56 yr old ● Occupation – Retired Labourer ● Address – Khajrana, Indore ● Dominance - Right handed ● Mobile no. – 966908XXX ● Date of Assessment - 25/06/2026 ● Chief Complaints - Patient came with the complaint of right-side tightness and stiffness, hypertonia of right upper and lower limb, abnormal hemiplegic posture, and difficulty in performing ADLs. He had a history of stroke 1 year ago and has been managing with medications." **SLIDE 9** (History of Present Illness): - Title: "HISTORY OF PRESENT ILLNESS" - Body: "Onset: The patient was apparently asymptomatic until 1 year ago when he suffered an ischemic stroke, developing sudden onset right-sided weakness and speech difficulty. Initial Management: He was admitted to the Neurology ward, received thrombolytic therapy and was discharged after 2 weeks with residual right hemiplegia. Progression: Over the following months, right-side spasticity and hypertonia gradually increased, limiting functional mobility and ADL performance. Neurology Consultation (23 June 2026): Due to persistent spasticity and functional limitations, he attended the Neurology OPD at MY Hospital and received medical treatment. Physiotherapy Referral (25 June 2026): As symptoms persisted, he was referred to the Physiotherapy OPD for comprehensive assessment and neuro-rehabilitation." **SLIDE 10** (Objective Assessment): - Title: "OBJECTIVE ASSESSMENT" - ON OBSERVATION section: "Body built: Mesomorphic Gait: Circumduction gait (hemiplegic gait) Posture: Hemiplegic posture – right UL flexed & adducted, right LL extended" - ON PALPATION section: "ON PALPATION: Tone: Increased (hypertonia) right UL and LL – Grade 2 Modified Ashworth Scale Tenderness: Present over right shoulder and right hip flexors Swelling: Absent Clonus: Present at right ankle Pelvic tilt: Oblique – elevated on right Muscle wasting: Right side upper and lower limb" **SLIDE 11** (Medical/Drug History): - Body: "PAST MEDICAL HISTORY – Ischemic Stroke 1 year back PAST HISTORY – Right hemiplegia and spasticity since 1 year PRESENT MEDICAL HISTORY - Tab. Aspirin 75mg, Tab. Atorvastatin 40mg, Tab. Baclofen 10mg, Tab. Amlodipine 5mg FAMILY HISTORY - Hypertension in father SOCIOECONOMIC STATUS – Middle class Personal history - Bowel/Bladder - Bladder urgency present, Appetite - normal Surgical History - None Environmental History – Lives in clean hygienic area" **SLIDE 12** (Pain/Tone History): - Body: "TONE / TIGHTNESS HISTORY Onset – Gradual, following ischemic stroke 1 year ago Duration – Since 1 year, increased over last 3 months Site – Right upper limb and right lower limb Aggravating factors: Emotional stress, cold weather, physical exertion, voluntary effort Relieving factors: Warmth, slow passive stretching, relaxation techniques" **SLIDE 13** (MMT Before Treatment): - Title: "MMT" - Sub-title: "Before treatment: 25/06/2026" - Keep table structure, table content should show right-side weakness (grades 2-3 for right limbs): In the main table, keep the muscle names but change right side values to 2-3/5 and left side to 5/5 **SLIDE 14** (ROM Before Treatment): - Title: "Range of motion Before treatment" - Keep table structure, right-side ROM reduced (60-70% of normal) **SLIDE 15** (Special Tests): - Title: "SPECIAL TESTS" - Table content (special tests for stroke/spasticity): - Modified Ashworth Scale (MAS): Grade 2 right UL & LL - Fugl-Meyer Assessment: 45/100 (moderate impairment) - Berg Balance Scale: 28/56 (medium fall risk) - Tone Assessment Scale: Positive right side - Clonus test: Positive right ankle - Babinski Sign: Positive right side - Romberg Test: Positive (unsteady with eyes closed) **SLIDE 16** (Outcome Measures Pre): - Title: "OUTCOME MEASURES" - Body: "NPRS Scale – on activity 5/10 on rest – 2/10" **SLIDE 17** (Pre-assessment Disability Index): - Title: "PRE ASSES BARTHEL INDEX" - Score text: "BARTHEL INDEX SCORE: 45/100 – MODERATE DEPENDENCE" **SLIDE 18** (Prescriptions): - Title: "PHYSIOTHERAPY OPD & NEURO PRESCRIPTIONS" - Keep as-is (image slide, no text to change besides title) **SLIDE 19** (Imaging Findings): - Title: "MRI / CT FINDINGS" - Text content: "CT Brain (Plain): Hypodense area in left middle cerebral artery (MCA) territory – suggestive of ischemic infarct. Left internal capsule and corona radiata involvement noted. No hemorrhagic transformation. MRI Brain (DWI): Restricted diffusion in left MCA territory confirming acute/subacute ischemic stroke." **SLIDE 20** (Diagnosis): - Title: "DIAGNOSIS" - Body: "MEDICAL DIAGNOSIS – Left MCA ischemic stroke with right hemiplegia and spastic hypertonia. PHYSIOTHERAPY DIAGNOSIS – Right-sided spastic hemiplegia with hypertonia, hemiplegic posture, circumduction gait, and impaired ADL function secondary to left MCA ischemic stroke." **SLIDE 21** (Problem List): - Title: "PROBLEM LIST" - Body: "Patient Identified Problems: The patient reports right-side tightness and stiffness limiting daily activities such as dressing, walking, and climbing stairs. He wants to regain independence and return to normal daily life. Therapist Identified Problems: The patient demonstrates right-sided hypertonia (MAS Grade 2), hemiplegic posture, circumduction gait, reduced right UL & LL strength (MMT 2-3/5), impaired balance (BBS 28/56), decreased coordination, and functional dependence secondary to post-stroke spasticity." **SLIDE 22** (ICF Model text): - Title: "ICF Model" - Any text content: "International Classification of Functioning, Disability and Health (ICF) framework applied to post-stroke rehabilitation for functional assessment." **SLIDE 23** (ICF Model table): - Title: "ICF MODEL" - Table content: - Body Structure/Function: Hypertonia right UL & LL, hemiplegia, abnormal posture, impaired balance - Activity Limitation: Difficulty walking, dressing, climbing stairs, ADL performance - Participation Restriction: Unable to work, limited social participation, dependent on family - Environmental Factors: Home barriers (stairs, narrow doors), support from family - Personal Factors: Age 56, male, retired, motivated for recovery **SLIDE 24** (Contextual Factors): - Title: "CONTEXTUAL FACTORS" - Table: - Facilitators: Supportive family, motivated patient, accessible physiotherapy OPD, prescribed medications - Barriers: Age 56, long duration of spasticity (1 year), fear of falls, home architectural barriers **SLIDE 25** (Physiotherapy Treatment): - Title: "PHYSIOTHERAPY TREATMENT" - Table: - Goal 1: Reduce right-sided hypertonia and spasticity - Goal 2: Improve right UL & LL strength and ROM - Goal 3: Correct hemiplegic posture - Goal 4: Improve balance and gait pattern - Goal 5: Improve ADL independence **SLIDE 26** (Phase 1): - Title: "PHASE 1" - Table: (Weeks 1-2, Acute/Initial phase) - Positioning: Anti-spasticity positioning, bed positioning program - Passive ROM exercises: Right UL & LL, all joints - Stretching: Slow prolonged stretching of spastic muscles (biceps, finger flexors, plantar flexors) - TENS: Over spastic muscle groups to reduce tone - Mat activities: Rolling, bridging, weight bearing - Breathing exercises: Diaphragmatic breathing, trunk relaxation **SLIDE 27** (Phase 2): - Title: "PHASE 2" - Table: (Weeks 3-6, Intermediate phase) - Active-assisted exercises: Right UL & LL progressive strengthening - NDT/Bobath techniques: Reflex inhibiting postures, facilitation of normal movement - Balance training: Sitting balance, standing balance, weight shift - Gait retraining: Parallel bars, tripod stick, supervised walking - Task-specific training: ADL retraining (dressing, feeding, grooming) - Mirror therapy: Right UL for motor facilitation - Electrical stimulation (FES): Right wrist extensors and ankle dorsiflexors **SLIDE 28** (Images slide - keep as-is, just images): No text changes needed. **SLIDE 29** (MMT After Treatment): - Title: "MMT" - Sub-title: "After treatment: 06/07/2026" - Show improvement: right side grades 3-4/5 **SLIDE 30** (ROM After Treatment): - Title: "Range of motion After treatment" - Show improvement in right-side ROM **SLIDE 31** (Outcome Measures Post): - Title: "OUTCOME MEASURES" - Body: "NPRS Scale – on activity 3/10 on rest – 1/10" **SLIDE 32** (Post-assessment Disability Index): - Title: "POST ASSES BARTHEL INDEX" - Score text: "BARTHEL INDEX SCORE: 65/100 – MILD DEPENDENCE" **SLIDE 33** (Home Exercise Protocol): - Title: "Home Exercise Protocol" - Table content (home exercises for stroke): - Stretching: Bicep stretch, finger extensor stretch, plantar flexor stretch – 3x30s daily - Active exercises: Shoulder shrugs, elbow extension, wrist extension, ankle dorsiflexion – 3x10 reps - Balance: Standing on both feet at wall support, single leg stance attempt - Gait practice: Walking with stick 10-15 min twice daily - Positioning: Anti-spasticity positions when resting **SLIDE 34** (Case-Related Articles): - Title: "CASE RELATED ARTICLES" - Body: "1. Veerbeek JM et al. (2014). What is the evidence for physical therapy poststroke? A systematic review and meta-analysis. PLOS ONE. 2. Langhorne P et al. (2011). Motor recovery after stroke: a systematic review. Lancet Neurology. 3. Pollock A et al. (2014). Physical rehabilitation approaches for the recovery of mobility and lower limb function following stroke. Cochrane Database Syst Rev. 4. Bobath B (1990). Adult Hemiplegia: Evaluation and Treatment (3rd ed.). Heinemann Medical Books." **SLIDE 35** (References): - Title: "REFERENCES" - Body: "Carr JH, Shepherd RB. (2010). Neurological Rehabilitation: Optimizing Motor Performance (2nd ed.). Churchill Livingstone. Bobath B. (1990). Adult Hemiplegia: Evaluation and Treatment (3rd ed.). Heinemann Medical Books. Shumway-Cook A, Woollacott MH. (2017). Motor Control: Translating Research into Clinical Practice (5th ed.). Wolters Kluwer. O'Sullivan SB, Schmitz TJ. (2019). Physical Rehabilitation (7th ed.). F.A. Davis Company." **SLIDE 36** (Thank You slide): - Keep "THANKYOU" as-is. --- IMPLEMENTATION INSTRUCTIONS: Use Python and python-pptx to edit each slide. For text-only text boxes and placeholders, use the following approach: ```python from pptx import Presentation from pptx.util import Pt import copy prs = Presentation("/tmp/workspace/stroke-case/unpacked/ppt/slides/slide1.xml") # NO - don't do that. Edit the XML directly as strings. ``` Instead, for each slide, read the XML file, find the text run elements (a:t tags in the XML) and replace their content. Use Python's xml.etree.ElementTree or direct string manipulation. The SAFEST approach is to use python-pptx to load the full presentation (not individual slides), iterate through shapes, and replace text paragraph by paragraph. Here is the exact Python script to write and run: ```python from pptx import Presentation from pptx.util import Pt from lxml import etree import copy PPTX_PATH = "/tmp/workspace/stroke-case/template.pptx" OUTPUT_PATH = "/tmp/workspace/stroke-case/stroke_case_output.pptx" prs = Presentation(PPTX_PATH) def set_text(shape, new_text): """Replace all text in a shape's text frame with new_text, preserving first paragraph's run format.""" tf = shape.text_frame # Store formatting from first run of first paragraph first_para = tf.paragraphs[0] # Clear all paragraphs for para in tf.paragraphs: for run in para.runs: run.text = "" # Set text in first paragraph first run if first_para.runs: first_para.runs[0].text = new_text else: from pptx.util import Pt run = first_para.add_run() run.text = new_text def replace_text_in_shape(shape, old_text, new_text): if shape.has_text_frame: for para in shape.text_frame.paragraphs: for run in para.runs: if old_text in run.text: run.text = run.text.replace(old_text, new_text) ``` Actually, the best approach for this task given the complexity is: 1. Load the presentation with python-pptx 2. For each slide, identify the shapes by their current text content (using the slide content map I provided above) 3. Replace text run by run, matching on partial content Write a comprehensive Python script that handles all 36 slides. The script should: 1. Load /tmp/workspace/stroke-case/template.pptx 2. Edit each slide's text shapes according to the content plan above 3. Save as /tmp/workspace/stroke-case/stroke_case_output.pptx Key rules: - When replacing text in a shape that has multiple paragraphs (like the subjective assessment bullet points), replace each paragraph's text individually - For shapes with tables, replace cell text - Preserve all formatting - only change the TEXT content of runs - For multi-paragraph text boxes, replace paragraph by paragraph Write and execute the script. Make sure the output file is saved successfully. Print "SUCCESS" at the end if the file was saved. Return the final file path and confirm it was created successfully.

Reading File
Browsing Directory

~/stroke-case

Browsing Directory

~/stroke-case/unpacked

Browsing Directory

~/stroke-case/unpacked/ppt

Running Command

python3 << 'EOF' from pptx import Presentation prs = Presentation("/tmp/workspace/stroke-case/template.pptx") print(f"Total slides: {len(prs.slides)}") print("="*80) for i, slide in enumerate(prs.slides, 1): print(f"\n{'='*40} SLIDE {i} {'='*40}") for j, shape in enumerate(slide.shapes): if shape.has_text_frame: text = shape.text_frame.text.strip() if text: print(f" Shape {j} ({shape.shape_type}, name='{shape.name}'): {repr(text[:200])}") if shape.has_table: print(f" Shape {j} TABLE ({shape.name}):") for r, row in enumerate(shape.table.rows): for c, cell in enumerate(row.cells): ct = cell.text_frame.text.strip() if ct: print(f" Cell[{r},{c}]: {repr(ct[:100])}") EOF

Running Command

python3 << 'EOF' from pptx import Presentation prs = Presentation("/tmp/workspace/stroke-case/template.pptx") # Full text for key slides for i in [8, 9, 11, 12, 17, 19, 20, 21, 22, 34, 35]: slide = prs.slides[i-1] print(f"\n{'='*40} SLIDE {i} FULL TEXT {'='*40}") for j, shape in enumerate(slide.shapes): if shape.has_text_frame: print(f" Shape {j} (name='{shape.name}'):") for k, para in enumerate(shape.text_frame.paragraphs): full = para.text if full.strip(): print(f" Para {k}: {repr(full)}") if shape.has_table: print(f" Shape {j} TABLE:") for r, row in enumerate(shape.table.rows): for c, cell in enumerate(row.cells): ct = cell.text_frame.text if ct.strip(): print(f" Cell[{r},{c}]: {repr(ct)}") EOF

Writing File

~/stroke-case/edit_slides.py

"""
Comprehensive script to replace all clinical content in the stroke case presentation.
Changes content from Lumbar Spondylosis (21-year-old) to Post-Stroke Hemiplegia (56-year-old).
Only replaces TEXT content - preserves all XML structure, fonts, colors, positions.
"""

from pptx import Presentation
from pptx.util import Pt
from copy import deepcopy
from lxml import etree
import copy

PPTX_PATH = "/tmp/workspace/stroke-case/template.pptx"
OUTPUT_PATH = "/tmp/workspace/stroke-case/stroke_case_output.pptx"

prs = Presentation(PPTX_PATH)

# ─────────────────────────────────────────────────────────────────────────────
# Helper functions
# ─────────────────────────────────────────────────────────────────────────────

def set_paragraph_text(para, new_text):
    """Replace all text in a paragraph's runs with new_text, preserving run formatting.
    Uses the first run for the text; clears all other runs."""
    runs = para.runs
    if not runs:
        # Add a run if none exist
        from pptx.oxml.ns import qn
        r_elem = para._p.makeelement(qn('a:r'), {})
        t_elem = r_elem.makeelement(qn('a:t'), {})
        t_elem.text = new_text
        r_elem.append(t_elem)
        para._p.append(r_elem)
        return
    # Set first run text
    runs[0].text = new_text
    # Clear all other runs
    for run in runs[1:]:
        run.text = ""

def replace_shape_text(shape, new_text_lines):
    """
    Replace text in a text frame paragraph by paragraph.
    new_text_lines: list of strings, one per paragraph.
    Only replaces paragraphs that have text; preserves empty spacer paragraphs.
    """
    tf = shape.text_frame
    paras = tf.paragraphs
    text_para_indices = [i for i, p in enumerate(paras) if p.text.strip()]
    
    for idx, new_text in enumerate(new_text_lines):
        if idx < len(text_para_indices):
            para = paras[text_para_indices[idx]]
            set_paragraph_text(para, new_text)

def replace_all_runs_in_shape(shape, new_text):
    """Replace all text in a shape by setting the first run of the first paragraph 
    and clearing everything else. Good for single-block text shapes."""
    tf = shape.text_frame
    first_set = False
    for para in tf.paragraphs:
        for run in para.runs:
            if not first_set:
                run.text = new_text
                first_set = True
            else:
                run.text = ""

def get_shape_by_name(slide, name):
    for shape in slide.shapes:
        if shape.name == name:
            return shape
    return None

def get_text_shapes(slide):
    """Return all shapes with text frames."""
    return [s for s in slide.shapes if s.has_text_frame and s.text_frame.text.strip()]

def get_table_shapes(slide):
    """Return all shapes with tables."""
    return [s for s in slide.shapes if s.has_table]

def set_cell_text(cell, new_text):
    """Replace all text in a table cell."""
    tf = cell.text_frame
    paras = tf.paragraphs
    first_set = False
    for para in paras:
        for run in para.runs:
            if not first_set:
                run.text = new_text
                first_set = True
            else:
                run.text = ""
    # If no runs found, add one
    if not first_set:
        from pptx.oxml.ns import qn
        para = paras[0]
        r_elem = para._p.makeelement(qn('a:r'), {})
        t_elem = r_elem.makeelement(qn('a:t'), {})
        t_elem.text = new_text
        r_elem.append(t_elem)
        para._p.append(r_elem)

def replace_para_text_by_content(shape, old_partial, new_text):
    """Find a paragraph containing old_partial and replace its text with new_text."""
    for para in shape.text_frame.paragraphs:
        if old_partial in para.text:
            set_paragraph_text(para, new_text)
            return True
    return False

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 1 - Title slide
# ─────────────────────────────────────────────────────────────────────────────
slide1 = prs.slides[0]
for shape in slide1.shapes:
    if shape.has_text_frame:
        if 'Lumbar Spondylolysis' in shape.text_frame.text or 'Lumbar Spondolysis' in shape.text_frame.text or '21-Year' in shape.text_frame.text:
            set_paragraph_text(
                shape.text_frame.paragraphs[0],
                "Physiotherapy Rehabilitation of Post-Stroke Hemiplegia in a 56-Year-Old Male"
            )
            break

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 2 - Case Background
# ─────────────────────────────────────────────────────────────────────────────
slide2 = prs.slides[1]
for shape in slide2.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'CASE BACKGROUND' in txt:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'CASE BACKGROUND')
        elif '21 year old' in txt or 'Lower Back pain' in txt or 'stroke' in txt.lower() or 'complaint' in txt.lower():
            # This is the body text box
            tf = shape.text_frame
            # Clear all paragraphs text, set first non-empty
            new_body = ("Patient is 56 year old male who came to MYH OPD on 25/06/2026. "
                        "Patient came with the complaint of right side tightness, hypertonia of right upper and lower limb, "
                        "abnormal posture and inability to perform ADLs. He had a history of stroke 1 year back.")
            first_set = False
            for para in tf.paragraphs:
                for run in para.runs:
                    if not first_set:
                        run.text = new_body
                        first_set = True
                    else:
                        run.text = ""

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 3 - Introduction
# ─────────────────────────────────────────────────────────────────────────────
slide3 = prs.slides[2]
shapes3 = get_text_shapes(slide3)
for shape in slide3.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'INTRODUCTION' in txt:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'INTRODUCTION')
        elif 'LUMBAR SPONDOLYSIS' in txt or 'LUMBAR SPONDYLOSIS' in txt.upper():
            set_paragraph_text(shape.text_frame.paragraphs[0], 'STROKE (CEREBROVASCULAR ACCIDENT)')
        elif 'Spondy' in txt or 'degenerative' in txt.lower():
            new_body = ("Stroke = sudden interruption of blood supply to the brain causing neurological deficits. "
                        "It is a leading cause of adult disability worldwide.\n"
                        "Common Consequences:\n"
                        "Right hemiplegia – weakness/paralysis of right side.\n"
                        "Hypertonia / Spasticity – increased muscle tone due to upper motor neuron lesion.\n"
                        "Abnormal posture – hemiplegic posture (flexed UL, extended LL).\n"
                        "Decreased balance and coordination.\n"
                        "Impaired ADL performance and gait.")
            first_set = False
            for para in shape.text_frame.paragraphs:
                for run in para.runs:
                    if not first_set:
                        run.text = new_body
                        first_set = True
                    else:
                        run.text = ""

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 4 - Anatomy
# ─────────────────────────────────────────────────────────────────────────────
slide4 = prs.slides[3]
for shape in slide4.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'ANATOMY' in txt and len(txt.strip()) < 20:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'ANATOMY')
        elif 'lumbar spine' in txt.lower() or 'vertebrae' in txt.lower() or 'lumbar' in txt.lower():
            new_body = ("The brain is the primary organ affected in stroke. "
                        "Relevant structures include the motor cortex, internal capsule, corticospinal tract, and cerebellum. "
                        "The right hemisphere controls left-sided movement; left hemisphere controls right-sided movement. "
                        "The corticospinal tract carries voluntary motor signals; its damage causes upper motor neuron signs "
                        "including spasticity, hypertonia, and abnormal reflexes.")
            first_set = False
            for para in shape.text_frame.paragraphs:
                for run in para.runs:
                    if not first_set:
                        run.text = new_body
                        first_set = True
                    else:
                        run.text = ""

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 5 - Cont. Components
# ─────────────────────────────────────────────────────────────────────────────
slide5 = prs.slides[4]
for shape in slide5.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'Cont' in txt and len(txt.strip()) < 15:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'Cont….')
        elif 'COMPONENTS' in txt or 'Lumbar vertebrae' in txt or 'L1' in txt:
            new_body = ("COMPONENTS\n"
                        "Corticospinal Tract: Descending motor pathway; damage leads to spasticity and weakness.\n"
                        "Internal Capsule: Dense white matter; most common site for ischemic stroke causing hemiplegia.\n"
                        "Motor Cortex (Primary): Controls voluntary movements of contralateral limbs.\n"
                        "Basal Ganglia: Involved in movement regulation; dysfunction causes rigidity and postural problems.\n"
                        "Cerebellum: Coordinates balance and smooth movement; affected in posterior circulation strokes.\n"
                        "Brainstem: Controls vital functions; involvement causes severe deficits.")
            first_set = False
            for para in shape.text_frame.paragraphs:
                for run in para.runs:
                    if not first_set:
                        run.text = new_body
                        first_set = True
                    else:
                        run.text = ""

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 6 - Epidemiology table
# ─────────────────────────────────────────────────────────────────────────────
slide6 = prs.slides[5]
for shape in slide6.shapes:
    if shape.has_text_frame and 'EPIDEMIOLOGY' in shape.text_frame.text:
        set_paragraph_text(shape.text_frame.paragraphs[0], 'EPIDEMIOLOGY OF STROKE')
    if shape.has_table:
        tbl = shape.table
        epi_data = [
            ('Parameter', 'Summary'),
            ('Incidence', '~13.7 million new strokes per year globally'),
            ('Prevalence', '~101 million people living with stroke worldwide'),
            ('Age group', 'Most common >55 years; risk doubles each decade after 55'),
            ('Sex', 'Slightly higher lifetime risk in women; higher age-adjusted incidence in men'),
            ('Mortality', '~5.5 million deaths per year globally'),
            ('Disability', 'Leading cause of long-term disability in adults'),
            ('', ''),  # row 7
            ('', ''),  # row 8
        ]
        for r_idx, row in enumerate(tbl.rows):
            if r_idx < len(epi_data):
                c0, c1 = epi_data[r_idx]
                if len(row.cells) > 0 and c0:
                    set_cell_text(row.cells[0], c0)
                elif len(row.cells) > 0:
                    set_cell_text(row.cells[0], '')
                if len(row.cells) > 1 and c1:
                    set_cell_text(row.cells[1], c1)
                elif len(row.cells) > 1:
                    set_cell_text(row.cells[1], '')

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 7 - Etiology / Risk Factors table
# ─────────────────────────────────────────────────────────────────────────────
slide7 = prs.slides[6]
for shape in slide7.shapes:
    if shape.has_text_frame and 'ETIOLOGY' in shape.text_frame.text:
        set_paragraph_text(shape.text_frame.paragraphs[0], 'ETIOLOGY / RISK FACTORS')
    if shape.has_table:
        tbl = shape.table
        rf_data = [
            ('Factor', 'Summary'),
            ('Hypertension', 'Most common modifiable risk factor'),
            ('Diabetes Mellitus', 'Increases risk of ischemic stroke'),
            ('Atrial Fibrillation / Cardiac disease', 'Cardioembolic stroke risk'),
            ('Dyslipidemia / High cholesterol', 'Promotes atherosclerosis'),
            ('Smoking and alcohol use', 'Independent modifiable risk factors'),
            ('Obesity and sedentary lifestyle', 'Increases cardiovascular risk'),
            ('Previous TIA or stroke history', 'High risk of recurrence'),
            ('Age > 55 years, male sex', 'Non-modifiable risk factors'),
        ]
        for r_idx, row in enumerate(tbl.rows):
            if r_idx < len(rf_data):
                c0, c1 = rf_data[r_idx]
                set_cell_text(row.cells[0], c0)
                if len(row.cells) > 1:
                    set_cell_text(row.cells[1], c1)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 8 - Subjective Assessment
# ─────────────────────────────────────────────────────────────────────────────
slide8 = prs.slides[7]
for shape in slide8.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'SUBJECTIVE ASSESSMENT' in txt:
            pass  # Keep as-is
        elif '21yr old' in txt or 'Labourer' in txt or 'Low Back Pain' in txt or 'Name – XYZ' in txt:
            tf = shape.text_frame
            new_lines = [
                '   ● Name – XYZ ',
                '   ● Gender - Male',
                '   ● Age - 56 yr old',
                '   ● Occupation – Retired Labourer',
                '   ● Address – Khajrana, Indore',
                '   ● Dominance - Right handed',
                '   ● Mobile no. – 966908XXX',
                '   ● Date of Assessment - 25/06/2026',
                '   ● Chief Complaints - Patient came with the complaint of right-side tightness and stiffness, hypertonia of right upper and lower limb, abnormal hemiplegic posture, and difficulty in performing ADLs. He had a history of stroke 1 year ago and has been managing with medications.',
            ]
            # Map to actual text paragraphs (skip empty/space-only)
            text_paras = [p for p in tf.paragraphs if p.runs]
            for idx, new_line in enumerate(new_lines):
                if idx < len(text_paras):
                    set_paragraph_text(text_paras[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 9 - History of Present Illness
# ─────────────────────────────────────────────────────────────────────────────
slide9 = prs.slides[8]
new_hopi = [
    "Onset: The patient was apparently asymptomatic until 1 year ago when he suffered an ischemic stroke, developing sudden onset right-sided weakness and speech difficulty.",
    "Initial Management: He was admitted to the Neurology ward, received thrombolytic therapy and was discharged after 2 weeks with residual right hemiplegia.",
    "Progression: Over the following months, right-side spasticity and hypertonia gradually increased, limiting functional mobility and ADL performance.",
    "Neurology Consultation (23 June 2026): Due to persistent spasticity and functional limitations, he attended the Neurology OPD at MY Hospital and received medical treatment.",
    "Physiotherapy Referral (25 June 2026): As symptoms persisted, he was referred to the Physiotherapy OPD for comprehensive assessment and neuro-rehabilitation.",
]
for shape in slide9.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'low back pain' in txt.lower() or 'lifting a heavy weight' in txt.lower() or 'Onset:' in txt:
            tf = shape.text_frame
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            for idx, new_line in enumerate(new_hopi):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 10 - Objective Assessment
# ─────────────────────────────────────────────────────────────────────────────
slide10 = prs.slides[9]
for shape in slide10.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'OBJECTIVE ASSESSMENT' in txt:
            pass  # Keep title (or update slightly)
        elif 'ON OBSERVATION' in txt or 'Short Stride Gait' in txt or 'Flat Back' in txt:
            tf = shape.text_frame
            new_obs_lines = [
                'ON OBSERVATION:',
                'Body built: Mesomorphic',
                'Gait :  Circumduction gait (hemiplegic gait)',
                'Posture : Hemiplegic posture – right UL flexed & adducted, right LL extended',
            ]
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            for idx, new_line in enumerate(new_obs_lines):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)
        elif 'ON PALPATION' in txt or 'Tenderness' in txt or 'Hamstrings' in txt:
            tf = shape.text_frame
            new_palp_lines = [
                'ON PALPATION:',
                'Tone: Increased (hypertonia) right UL and LL – Grade 2 Modified Ashworth Scale',
                'Tenderness: Present over right shoulder and right hip flexors',
                'Swelling: Absent',
                'Clonus: Present at right ankle',
                'Pelvic tilt: Oblique – elevated on right',
                'Muscle wasting: Right side upper and lower limb',
            ]
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            for idx, new_line in enumerate(new_palp_lines):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 11 - Medical/Drug History
# ─────────────────────────────────────────────────────────────────────────────
slide11 = prs.slides[10]
for shape in slide11.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'PAST MEDICAL HISTORY' in txt or 'Pregabalin' in txt or 'FAMILY HISTORY' in txt:
            tf = shape.text_frame
            new_hist_lines = [
                'PAST MEDICAL HISTORY – Ischemic Stroke 1 year back',
                'PAST HISTORY – Right hemiplegia and spasticity since 1 year',
                'PRESENT MEDICAL HISTORY - Tab. Aspirin 75mg, Tab. Atorvastatin 40mg, Tab. Baclofen 10mg, Tab. Amlodipine 5mg',
                'FAMILY HISTORY - Hypertension in father',
                'SOCIOECONOMIC STATUS – Middle class',
                'Personal history - Bowel/Bladder - Bladder urgency present, Appetite - normal',
                'Surgical History - None',
                'Environmental History – Lives in clean hygienic area',
            ]
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            for idx, new_line in enumerate(new_hist_lines):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 12 - Pain/Tone History
# ─────────────────────────────────────────────────────────────────────────────
slide12 = prs.slides[11]
for shape in slide12.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'PAIN HISTORY' in txt or 'Onset – Gradual' in txt or 'B/L lower limbs' in txt:
            tf = shape.text_frame
            new_pain_lines = [
                'TONE / TIGHTNESS HISTORY',
                'Onset – Gradual, following ischemic stroke 1 year ago',
                'Duration – Since 1 year, increased over last 3 months',
                'Site – Right upper limb and right lower limb',
                'Aggravating factors: Emotional stress, cold weather, physical exertion, voluntary effort',
                'Relieving factors: Warmth, slow passive stretching, relaxation techniques',
            ]
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            for idx, new_line in enumerate(new_pain_lines):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 13 - MMT Before Treatment
# ─────────────────────────────────────────────────────────────────────────────
slide13 = prs.slides[12]
# Title text
for shape in slide13.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text.strip()
        if txt == 'MMT':
            pass  # Keep
        elif 'Before treatment' in txt:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'Before treatment: 25/06/2026')

# Tables - there are two tables on slide 13
# Table 1 (Lower limb): keep structure, update Right values to 2-3/5, Left to 5/5
# Table 2 (Lumbar): replace with Upper Limb data for stroke
table_shapes = [s for s in slide13.shapes if s.has_table]
if len(table_shapes) >= 1:
    tbl1 = table_shapes[0].table
    # Lower limb MMT - Right side 2-3, Left 5
    mmt_before_ll = [
        # row 0: headers - keep
        None,
        # row 1: Hip Flexors
        ('3+', '5'),
        # row 2: Extensors
        ('3', '5'),
        # row 3: Abductors
        ('2', '5'),
        # row 4: Adductors
        ('3', '5'),
        # row 5: External rotators
        ('2', '5'),
        # row 6: Internal rotators
        ('3', '5'),
    ]
    for r_idx, row in enumerate(tbl1.rows):
        if r_idx > 0 and r_idx < len(mmt_before_ll) and mmt_before_ll[r_idx]:
            right_val, left_val = mmt_before_ll[r_idx]
            if len(row.cells) > 2:
                set_cell_text(row.cells[2], right_val)
            if len(row.cells) > 3:
                set_cell_text(row.cells[3], left_val)

if len(table_shapes) >= 2:
    tbl2 = table_shapes[1].table
    # Replace Lumbar table with Upper Limb MMT for stroke
    ul_mmt_data = [
        ('Upper limb', 'Movement', 'Grade'),
        ('Shoulder', 'Flexors', '2'),
        ('', 'Extensors', '3'),
        ('', 'Abductors', '2'),
        ('Elbow', 'Flexors', '3'),
        ('', 'Extensors', '2'),
        ('Wrist', 'Extensors', '2'),
    ]
    # Only update if the table has enough rows
    for r_idx, row in enumerate(tbl2.rows):
        if r_idx < len(ul_mmt_data):
            row_data = ul_mmt_data[r_idx]
            for c_idx, cell in enumerate(row.cells):
                if c_idx < len(row_data):
                    set_cell_text(cell, row_data[c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 14 - ROM Before Treatment
# ─────────────────────────────────────────────────────────────────────────────
slide14 = prs.slides[13]
# Title text
for shape in slide14.shapes:
    if shape.has_text_frame and 'Range of motion Before' in shape.text_frame.text:
        pass  # Keep as-is

# Table 1 (Lower limb ROM): Right side reduced
table_shapes14 = [s for s in slide14.shapes if s.has_table]
if len(table_shapes14) >= 1:
    tbl1 = table_shapes14[0].table
    # Right: ~60-70% of normal, Left: normal
    rom_before_ll = [
        None,  # header row
        ('75', '120'),   # Hip Flexion: Right 75 (norm 120), Left 120
        ('10', '20'),    # Extension: Right 10 (norm 20), Left 20
        ('25', '45'),    # Abduction: Right 25 (norm 45), Left 45
        ('20', '30'),    # Adduction: Right 20 (norm 30), Left 30
        ('25', '45'),    # External rotation
        ('25', '45'),    # Internal rotation
    ]
    for r_idx, row in enumerate(tbl1.rows):
        if r_idx > 0 and r_idx < len(rom_before_ll) and rom_before_ll[r_idx]:
            right_val, left_val = rom_before_ll[r_idx]
            if len(row.cells) > 2:
                set_cell_text(row.cells[2], right_val)
            if len(row.cells) > 3:
                set_cell_text(row.cells[3], left_val)

if len(table_shapes14) >= 2:
    tbl2 = table_shapes14[1].table
    # Replace Lumbar ROM with Upper Limb ROM for stroke
    ul_rom_data = [
        ('Upper limb', 'range'),
        ('Shoulder Flexion', 'Rt.- 90 / Lt.- 180'),
        ('Shoulder Abduction', 'Rt.- 80 / Lt.- 180'),
        ('Elbow Flexion', 'Rt.- 100 / Lt.- 150'),
    ]
    for r_idx, row in enumerate(tbl2.rows):
        if r_idx < len(ul_rom_data):
            row_data = ul_rom_data[r_idx]
            for c_idx, cell in enumerate(row.cells):
                if c_idx < len(row_data):
                    set_cell_text(cell, row_data[c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 15 - Special Tests
# ─────────────────────────────────────────────────────────────────────────────
slide15 = prs.slides[14]
for shape in slide15.shapes:
    if shape.has_table:
        tbl = shape.table
        special_tests = [
            ('NAME', 'RESULT', 'INTERPRETATION'),
            ('Modified Ashworth Scale (MAS)', 'Grade 2 right UL & LL', 'Moderate spasticity'),
            ('Fugl-Meyer Assessment', '45/100', 'Moderate impairment'),
            ('Berg Balance Scale', '28/56', 'Medium fall risk'),
            ('Clonus Test', 'Positive right ankle', 'UMN lesion sign'),
        ]
        # Check how many columns the table has
        num_cols = len(tbl.columns)
        for r_idx, row in enumerate(tbl.rows):
            if r_idx < len(special_tests):
                row_data = special_tests[r_idx]
                for c_idx, cell in enumerate(row.cells):
                    if c_idx < len(row_data):
                        set_cell_text(cell, row_data[c_idx])

# Also check if table has only 3 cols (NAME, RIGHT, LEFT) - update accordingly
for shape in slide15.shapes:
    if shape.has_table:
        tbl = shape.table
        if len(tbl.columns) == 3:
            special_tests_3col = [
                ('NAME', 'RESULT', 'INTERPRETATION'),
                ('Modified Ashworth Scale (MAS)', 'Grade 2 right UL & LL', 'Moderate spasticity'),
                ('Fugl-Meyer Assessment', '45/100', 'Moderate impairment'),
                ('Berg Balance Scale', '28/56', 'Medium fall risk'),
                ('Clonus Test', 'Positive right ankle', 'UMN lesion sign'),
            ]
            for r_idx, row in enumerate(tbl.rows):
                if r_idx < len(special_tests_3col):
                    row_data = special_tests_3col[r_idx]
                    for c_idx, cell in enumerate(row.cells):
                        if c_idx < len(row_data):
                            set_cell_text(cell, row_data[c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 16 - Outcome Measures Pre
# ─────────────────────────────────────────────────────────────────────────────
slide16 = prs.slides[15]
for shape in slide16.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'NPRS' in txt and 'activity 7' in txt:
            tf = shape.text_frame
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            new_nprs = [
                'NPRS Scale – on activity 5/10',
                '              on rest – 2/10',
            ]
            for idx, new_line in enumerate(new_nprs):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 17 - Pre-assessment Disability Index
# ─────────────────────────────────────────────────────────────────────────────
slide17 = prs.slides[16]
for shape in slide17.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'OSWESTRY' in txt.upper() or 'PRE ASSES' in txt.upper():
            set_paragraph_text(shape.text_frame.paragraphs[0], 'PRE ASSES BARTHEL INDEX')
        elif 'DISABILITY SCORE' in txt or '26/50' in txt:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'BARTHEL INDEX SCORE: 45/100 – MODERATE DEPENDENCE')

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 18 - Prescriptions (keep as-is, just title)
# ─────────────────────────────────────────────────────────────────────────────
# Title is already "PHYSIOTHERAPY OPD & NEURO PRESCRIPTIONS" - keep as-is

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 19 - Imaging Findings
# ─────────────────────────────────────────────────────────────────────────────
slide19 = prs.slides[18]
for shape in slide19.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'MRI FINDINGS' in txt or 'MRI / CT' in txt:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'MRI / CT FINDINGS')
        # If there's a body text shape, add content
        # (Slide 19 only had title in the analysis - if there's a body placeholder, fill it)

# Check if there are other shapes to fill
for shape in slide19.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text.strip()
        if txt and 'MRI' not in txt and 'CT' not in txt:
            new_mri = ("CT Brain (Plain): Hypodense area in left middle cerebral artery (MCA) territory – "
                       "suggestive of ischemic infarct. Left internal capsule and corona radiata involvement noted. "
                       "No hemorrhagic transformation. "
                       "MRI Brain (DWI): Restricted diffusion in left MCA territory confirming acute/subacute ischemic stroke.")
            first_set = False
            for para in shape.text_frame.paragraphs:
                for run in para.runs:
                    if not first_set:
                        run.text = new_mri
                        first_set = True
                    else:
                        run.text = ""

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 20 - Diagnosis
# ─────────────────────────────────────────────────────────────────────────────
slide20 = prs.slides[19]
for shape in slide20.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'DIAGNOSIS' in txt and len(txt.strip()) < 20:
            pass  # Keep title
        elif 'MEDICAL DIAGNOSIS' in txt or 'PHYSIOTHERAPY DIAGNOSIS' in txt or 'Lumbar spondolysis' in txt:
            tf = shape.text_frame
            new_diag_lines = [
                'MEDICAL DIAGNOSIS – Left MCA ischemic stroke with right hemiplegia and spastic hypertonia.',
                'PHYSIOTHERAPY DIAGNOSIS – Right-sided spastic hemiplegia with hypertonia, hemiplegic posture, circumduction gait, and impaired ADL function secondary to left MCA ischemic stroke.',
            ]
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            for idx, new_line in enumerate(new_diag_lines):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 21 - Problem List
# ─────────────────────────────────────────────────────────────────────────────
slide21 = prs.slides[20]
for shape in slide21.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'PROBLEM LIST' in txt and len(txt.strip()) < 20:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'PROBLEM LIST')
        elif 'Patient Identified Problems' in txt or 'low back pain' in txt.lower() or 'Therapist Identify' in txt:
            tf = shape.text_frame
            new_prob_lines = [
                'Patient Identified Problems: The patient reports right-side tightness and stiffness limiting daily activities such as dressing, walking, and climbing stairs. He wants to regain independence and return to normal daily life.',
                'Therapist Identified Problems: The patient demonstrates right-sided hypertonia (MAS Grade 2), hemiplegic posture, circumduction gait, reduced right UL & LL strength (MMT 2-3/5), impaired balance (BBS 28/56), decreased coordination, and functional dependence secondary to post-stroke spasticity.',
            ]
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            for idx, new_line in enumerate(new_prob_lines):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 22 - ICF Model text
# ─────────────────────────────────────────────────────────────────────────────
slide22 = prs.slides[21]
# Only has "ICF Model" title - keep as-is per instructions

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 23 - ICF MODEL table
# ─────────────────────────────────────────────────────────────────────────────
slide23 = prs.slides[22]
for shape in slide23.shapes:
    if shape.has_table:
        tbl = shape.table
        icf_data = [
            ('Body Structure & Function', 'Activity Limitation', 'Participation Restriction'),
            ('Hypertonia right UL & LL', 'Difficulty walking', 'Unable to work'),
            ('Hemiplegia – right side weakness', 'Difficulty dressing and grooming', 'Limited social participation'),
            ('Abnormal hemiplegic posture', 'Difficulty climbing stairs', 'Dependent on family for daily activities'),
            ('Impaired balance (BBS 28/56)', 'Impaired ADL performance', 'Reduced quality of life'),
            ('Circumduction gait pattern', 'Reduced endurance for physical tasks', 'Financial impact due to limited mobility'),
        ]
        for r_idx, row in enumerate(tbl.rows):
            if r_idx < len(icf_data):
                for c_idx, cell in enumerate(row.cells):
                    if c_idx < len(icf_data[r_idx]):
                        set_cell_text(cell, icf_data[r_idx][c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 24 - Contextual Factors
# ─────────────────────────────────────────────────────────────────────────────
slide24 = prs.slides[23]
for shape in slide24.shapes:
    if shape.has_table:
        tbl = shape.table
        ctx_data = [
            ('Facilitators – Personal Factors', 'Facilitators – Environmental Factors', 'Barriers – Personal Factors', 'Barriers – Environmental Factors'),
            ('Motivated patient, willing to participate in rehab', 'Accessible physiotherapy OPD at MY Hospital', 'Age 56, long duration of spasticity (1 year)', 'Home architectural barriers (stairs, narrow doors)'),
            ('Supportive family assisting with daily care', 'Family support during rehabilitation', 'Fear of falls affecting confidence', 'Limited community mobility support'),
            ('Following prescribed medications regularly', 'Prescribed medications (Baclofen, Aspirin)', 'Residual hypertonia affecting movement', 'Lack of assistive devices at home'),
        ]
        for r_idx, row in enumerate(tbl.rows):
            if r_idx < len(ctx_data):
                for c_idx, cell in enumerate(row.cells):
                    if c_idx < len(ctx_data[r_idx]):
                        set_cell_text(cell, ctx_data[r_idx][c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 25 - Physiotherapy Treatment Goals
# ─────────────────────────────────────────────────────────────────────────────
slide25 = prs.slides[24]
for shape in slide25.shapes:
    if shape.has_table:
        tbl = shape.table
        goals_data = [
            ('Short-Term Goals (Week 1-2)', 'Long-Term Goals (Week 3-6)'),
            ('Reduce right-sided hypertonia and spasticity (MAS from 2 to 1).', 'Achieve functional independence in ADLs (Barthel Index > 70).'),
            ('Improve passive ROM of right UL & LL.', 'Improve right UL & LL strength to MMT Grade 4.'),
            ('Correct hemiplegic posture with anti-spasticity positioning.', 'Improve gait pattern – reduce circumduction, improve step length.'),
            ('Improve sitting and standing balance.', 'Improve balance (BBS > 45/56).'),
            ('Educate patient and family on positioning, home exercises and fall prevention.', 'Maximize functional independence and community participation.'),
        ]
        for r_idx, row in enumerate(tbl.rows):
            if r_idx < len(goals_data):
                for c_idx, cell in enumerate(row.cells):
                    if c_idx < len(goals_data[r_idx]):
                        set_cell_text(cell, goals_data[r_idx][c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 26 - Phase 1
# ─────────────────────────────────────────────────────────────────────────────
slide26 = prs.slides[25]
for shape in slide26.shapes:
    if shape.has_table:
        tbl = shape.table
        phase1_data = [
            ('Exercise / Intervention', 'Frequency (F)', 'Intensity (I)', 'Time (T)', 'Type (T)'),
            ('Anti-spasticity positioning', 'Continuous / throughout day', 'Passive', 'All day', 'Bed positioning program'),
            ('Passive ROM exercises (right UL & LL)', '5 days/week', 'Gentle, full range', '10–15 min', 'All joints'),
            ('Slow prolonged stretching – spastic muscles', '5 days/week', 'Low', 'Hold 30 sec × 3–5 reps', 'Biceps, finger flexors, plantar flexors'),
            ('TENS – spastic muscle groups', '5 days/week', 'Sensory level', '10–15 min', 'Tone reduction'),
            ('Mat activities (rolling, bridging)', '5 days/week', 'Moderate', '10–15 min', 'Weight bearing & trunk control'),
            ('Diaphragmatic breathing & trunk relaxation', '3–5 days/week', 'Low', '5–10 min', 'Relaxation & breathing'),
        ]
        for r_idx, row in enumerate(tbl.rows):
            if r_idx < len(phase1_data):
                for c_idx, cell in enumerate(row.cells):
                    if c_idx < len(phase1_data[r_idx]):
                        set_cell_text(cell, phase1_data[r_idx][c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 27 - Phase 2
# ─────────────────────────────────────────────────────────────────────────────
slide27 = prs.slides[26]
for shape in slide27.shapes:
    if shape.has_table:
        tbl = shape.table
        phase2_data = [
            ('Exercise / Intervention', 'Frequency (F)', 'Intensity (I)', 'Time (T)', 'Type (T)'),
            ('Active-assisted exercises – right UL & LL', '5 days/week', 'Low–Moderate', '10–15 min', 'Progressive strengthening'),
            ('NDT / Bobath techniques', '5 days/week', 'Moderate', '15–20 min', 'Reflex inhibiting postures, facilitation'),
            ('Balance training (sitting → standing)', '5 days/week', 'Moderate', '10–15 min', 'Weight shift, sitting/standing balance'),
            ('Gait retraining (parallel bars → tripod stick)', '5 days/week', 'Moderate', '15–20 min', 'Supervised walking, step training'),
            ('Task-specific ADL retraining', '5 days/week', 'Moderate', '10–15 min', 'Dressing, feeding, grooming'),
            ('Mirror therapy – right UL', '5 days/week', 'Low', '10–15 min', 'Motor facilitation'),
            ('FES (right wrist extensors & ankle dorsiflexors)', '5 days/week', 'Motor threshold', '20 min', 'Functional electrical stimulation'),
        ]
        for r_idx, row in enumerate(tbl.rows):
            if r_idx < len(phase2_data):
                for c_idx, cell in enumerate(row.cells):
                    if c_idx < len(phase2_data[r_idx]):
                        set_cell_text(cell, phase2_data[r_idx][c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 28 - Images slide - no text changes
# ─────────────────────────────────────────────────────────────────────────────
# No changes needed

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 29 - MMT After Treatment
# ─────────────────────────────────────────────────────────────────────────────
slide29 = prs.slides[28]
for shape in slide29.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text.strip()
        if txt == 'MMT':
            pass  # Keep
        elif 'After treatment' in txt:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'After treatment: 06/07/2026')

table_shapes29 = [s for s in slide29.shapes if s.has_table]
if len(table_shapes29) >= 1:
    tbl1 = table_shapes29[0].table
    # Lower limb MMT after - Right side 3-4, Left 5
    mmt_after_ll = [
        None,  # header
        ('4', '5'),    # Hip Flexors
        ('4', '5'),    # Extensors
        ('3+', '5'),   # Abductors
        ('4', '5'),    # Adductors
        ('3+', '5'),   # External rotators
        ('4', '5'),    # Internal rotators
    ]
    for r_idx, row in enumerate(tbl1.rows):
        if r_idx > 0 and r_idx < len(mmt_after_ll) and mmt_after_ll[r_idx]:
            right_val, left_val = mmt_after_ll[r_idx]
            if len(row.cells) > 2:
                set_cell_text(row.cells[2], right_val)
            if len(row.cells) > 3:
                set_cell_text(row.cells[3], left_val)

if len(table_shapes29) >= 2:
    tbl2 = table_shapes29[1].table
    # Upper Limb MMT after treatment
    ul_mmt_after = [
        ('Upper limb', 'Movement', 'Grade'),
        ('Shoulder', 'Flexors', '4'),
        ('', 'Extensors', '4'),
        ('', 'Abductors', '3+'),
        ('Elbow', 'Flexors', '4'),
        ('', 'Extensors', '4'),
        ('Wrist', 'Extensors', '3+'),
    ]
    for r_idx, row in enumerate(tbl2.rows):
        if r_idx < len(ul_mmt_after):
            for c_idx, cell in enumerate(row.cells):
                if c_idx < len(ul_mmt_after[r_idx]):
                    set_cell_text(cell, ul_mmt_after[r_idx][c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 30 - ROM After Treatment
# ─────────────────────────────────────────────────────────────────────────────
slide30 = prs.slides[29]
table_shapes30 = [s for s in slide30.shapes if s.has_table]
if len(table_shapes30) >= 1:
    tbl1 = table_shapes30[0].table
    # Lower limb ROM after - Right improved
    rom_after_ll = [
        None,
        ('105', '120'),   # Hip Flexion
        ('15', '20'),     # Extension
        ('35', '45'),     # Abduction
        ('25', '30'),     # Adduction
        ('35', '45'),     # External rotation
        ('35', '45'),     # Internal rotation
    ]
    for r_idx, row in enumerate(tbl1.rows):
        if r_idx > 0 and r_idx < len(rom_after_ll) and rom_after_ll[r_idx]:
            right_val, left_val = rom_after_ll[r_idx]
            if len(row.cells) > 2:
                set_cell_text(row.cells[2], right_val)
            if len(row.cells) > 3:
                set_cell_text(row.cells[3], left_val)

if len(table_shapes30) >= 2:
    tbl2 = table_shapes30[1].table
    # Upper Limb ROM after
    ul_rom_after = [
        ('Upper limb', 'range'),
        ('Shoulder Flexion', 'Rt.- 140 / Lt.- 180'),
        ('Shoulder Abduction', 'Rt.- 130 / Lt.- 180'),
        ('Elbow Flexion', 'Rt.- 130 / Lt.- 150'),
    ]
    for r_idx, row in enumerate(tbl2.rows):
        if r_idx < len(ul_rom_after):
            for c_idx, cell in enumerate(row.cells):
                if c_idx < len(ul_rom_after[r_idx]):
                    set_cell_text(cell, ul_rom_after[r_idx][c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 31 - Outcome Measures Post
# ─────────────────────────────────────────────────────────────────────────────
slide31 = prs.slides[30]
for shape in slide31.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'NPRS' in txt and ('activity 4' in txt or 'activity' in txt.lower()):
            tf = shape.text_frame
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            new_nprs_post = [
                'NPRS Scale – on activity 3/10',
                '              on rest – 1/10',
            ]
            for idx, new_line in enumerate(new_nprs_post):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 32 - Post-assessment Disability Index
# ─────────────────────────────────────────────────────────────────────────────
slide32 = prs.slides[31]
for shape in slide32.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text
        if 'OSWESTRY' in txt.upper() or 'POST ASSES' in txt.upper():
            set_paragraph_text(shape.text_frame.paragraphs[0], 'POST ASSES BARTHEL INDEX')
        elif 'DISABILITY SCORE' in txt or '10/50' in txt:
            set_paragraph_text(shape.text_frame.paragraphs[0], 'BARTHEL INDEX SCORE: 65/100 – MILD DEPENDENCE')

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 33 - Home Exercise Protocol
# ─────────────────────────────────────────────────────────────────────────────
slide33 = prs.slides[32]
for shape in slide33.shapes:
    if shape.has_table:
        tbl = shape.table
        hep_data = [
            ('Exercise / Advice', 'Frequency', 'Dosage / Time', 'Purpose'),
            ('Bicep stretch, finger extensor stretch, plantar flexor stretch', 'Daily', '3 × 30 sec', 'Reduce spasticity and improve flexibility'),
            ('Shoulder shrugs, elbow extension, wrist extension exercises', '5 days/week', '3 × 10 reps', 'Strengthen right UL'),
            ('Ankle dorsiflexion active exercises', '5 days/week', '3 × 10 reps', 'Strengthen right LL, improve gait'),
            ('Standing at wall support (bilateral)', '5 days/week', '3 × 30 sec hold', 'Improve standing balance'),
            ('Walking with stick – supervised', '5–7 days/week', '10–15 min twice daily', 'Gait training and endurance'),
            ('Anti-spasticity positioning at rest', 'Daily', 'All rest periods', 'Reduce tone, prevent contractures'),
            ('Mirror therapy – right UL (at home)', 'Daily', '10–15 min', 'Motor facilitation and neuroplasticity'),
            ('Diaphragmatic breathing & relaxation', 'Daily', '5–10 min', 'Reduce overall tone and stress'),
            ('Avoid prolonged immobility; change position every 2 hours', 'Daily', 'Throughout the day', 'Prevent pressure sores and stiffness'),
        ]
        for r_idx, row in enumerate(tbl.rows):
            if r_idx < len(hep_data):
                for c_idx, cell in enumerate(row.cells):
                    if c_idx < len(hep_data[r_idx]):
                        set_cell_text(cell, hep_data[r_idx][c_idx])

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 34 - Case Related Articles
# ─────────────────────────────────────────────────────────────────────────────
slide34 = prs.slides[33]
# Title is already "CASE RELATED ARTICLES" - keep
# Need to add body text if there's a content placeholder
for shape in slide34.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text.strip()
        if txt == 'CASE RELATED ARTICLES':
            pass  # Keep title
        elif txt:  # Any other text shape
            new_articles = ("1. Veerbeek JM et al. (2014). What is the evidence for physical therapy poststroke? "
                           "A systematic review and meta-analysis. PLOS ONE.\n"
                           "2. Langhorne P et al. (2011). Motor recovery after stroke: a systematic review. Lancet Neurology.\n"
                           "3. Pollock A et al. (2014). Physical rehabilitation approaches for the recovery of mobility and lower limb function following stroke. Cochrane Database Syst Rev.\n"
                           "4. Bobath B (1990). Adult Hemiplegia: Evaluation and Treatment (3rd ed.). Heinemann Medical Books.")
            first_set = False
            for para in shape.text_frame.paragraphs:
                for run in para.runs:
                    if not first_set:
                        run.text = new_articles
                        first_set = True
                    else:
                        run.text = ""

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 35 - References
# ─────────────────────────────────────────────────────────────────────────────
slide35 = prs.slides[34]
for shape in slide35.shapes:
    if shape.has_text_frame:
        txt = shape.text_frame.text.strip()
        if 'REFERENCES' in txt.upper() and len(txt) < 30:
            pass  # Keep title
        elif 'Magee' in txt or 'Neumann' in txt or 'Muscolino' in txt or txt:
            tf = shape.text_frame
            new_ref_lines = [
                'Carr JH, Shepherd RB. (2010). Neurological Rehabilitation: Optimizing Motor Performance (2nd ed.). Churchill Livingstone.',
                'Bobath B. (1990). Adult Hemiplegia: Evaluation and Treatment (3rd ed.). Heinemann Medical Books.',
                'Shumway-Cook A, Woollacott MH. (2017). Motor Control: Translating Research into Clinical Practice (5th ed.). Wolters Kluwer.',
                "O'Sullivan SB, Schmitz TJ. (2019). Physical Rehabilitation (7th ed.). F.A. Davis Company.",
            ]
            paras_with_runs = [p for p in tf.paragraphs if p.runs]
            for idx, new_line in enumerate(new_ref_lines):
                if idx < len(paras_with_runs):
                    set_paragraph_text(paras_with_runs[idx], new_line)

# ─────────────────────────────────────────────────────────────────────────────
# SLIDE 36 - Thank You - Keep as-is
# ─────────────────────────────────────────────────────────────────────────────
# No changes needed

# ─────────────────────────────────────────────────────────────────────────────
# Save output
# ─────────────────────────────────────────────────────────────────────────────
prs.save(OUTPUT_PATH)
print(f"Saved to: {OUTPUT_PATH}")
print("SUCCESS")
Running Command

python3 /tmp/workspace/stroke-case/edit_slides.py 2>&1

Running Command

python3 << 'EOF' from pptx import Presentation prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") print(f"Total slides: {len(prs.slides)}") print("="*80) for i, slide in enumerate(prs.slides, 1): print(f"\n{'='*40} SLIDE {i} {'='*40}") for j, shape in enumerate(slide.shapes): if shape.has_text_frame: text = shape.text_frame.text.strip() if text: print(f" TEXT: {repr(text[:300])}") if shape.has_table: print(f" TABLE:") for r, row in enumerate(shape.table.rows): for c, cell in enumerate(row.cells): ct = cell.text_frame.text.strip() if ct: print(f" [{r},{c}]: {repr(ct[:100])}") EOF

Running Command

python3 << 'EOF' from pptx import Presentation prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") # Check slide 20 in detail print("=== SLIDE 20 DETAIL ===") slide20 = prs.slides[19] for j, shape in enumerate(slide20.shapes): if shape.has_text_frame: print(f" Shape {j} (name='{shape.name}'):") for k, para in enumerate(shape.text_frame.paragraphs): print(f" Para {k}: {repr(para.text)}") # Check slide 34 in detail print("\n=== SLIDE 34 DETAIL ===") slide34 = prs.slides[33] for j, shape in enumerate(slide34.shapes): print(f" Shape {j} (type={shape.shape_type}, name='{shape.name}', has_text={shape.has_text_frame})") if shape.has_text_frame: for k, para in enumerate(shape.text_frame.paragraphs): if para.text.strip(): print(f" Para {k}: {repr(para.text[:200])}") # Check slide 26 row 7 print("\n=== SLIDE 26 TABLE ROW 7 ===") slide26 = prs.slides[25] for shape in slide26.shapes: if shape.has_table: tbl = shape.table for r_idx in range(min(8, len(tbl.rows))): row = tbl.rows[r_idx] print(f" Row {r_idx}: {[cell.text_frame.text for cell in row.cells]}") EOF

Running Command

python3 << 'EOF' from pptx import Presentation from pptx.oxml.ns import qn from lxml import etree prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") def set_cell_text(cell, new_text): tf = cell.text_frame paras = tf.paragraphs first_set = False for para in paras: for run in para.runs: if not first_set: run.text = new_text first_set = True else: run.text = "" if not first_set: para = paras[0] r_elem = para._p.makeelement(qn('a:r'), {}) t_elem = r_elem.makeelement(qn('a:t'), {}) t_elem.text = new_text r_elem.append(t_elem) para._p.append(r_elem) # ─── FIX SLIDE 20: Remove leftover 3rd paragraph ─── slide20 = prs.slides[19] for shape in slide20.shapes: if shape.has_text_frame and 'MEDICAL DIAGNOSIS' in shape.text_frame.text: tf = shape.text_frame # Find and clear the 3rd text paragraph (old lumbar text) paras = tf.paragraphs for k, para in enumerate(paras): if 'lumbar' in para.text.lower() or 'spondolysis' in para.text.lower() or 'B/L L/L' in para.text: # Clear all runs in this paragraph for run in para.runs: run.text = "" print(f"Slide 20: Cleared old para {k}: {repr(para.text[:50])}") # ─── FIX SLIDE 26: Update row 7 to neurological content ─── slide26 = prs.slides[25] for shape in slide26.shapes: if shape.has_table: tbl = shape.table if len(tbl.rows) > 7: row7 = tbl.rows[7] new_r7 = ['Weight shifting exercises (side to side)', '5 days/week', 'Low–Moderate', '10 min', 'Postural control & trunk stabilization'] for c_idx, cell in enumerate(row7.cells): if c_idx < len(new_r7): set_cell_text(cell, new_r7[c_idx]) print("Slide 26: Updated row 7") # ─── FIX SLIDE 34: Add articles text to content placeholder ─── slide34 = prs.slides[33] articles_text = ("1. Veerbeek JM et al. (2014). What is the evidence for physical therapy poststroke? A systematic review and meta-analysis. PLOS ONE.\n" "2. Langhorne P et al. (2011). Motor recovery after stroke: a systematic review. Lancet Neurology.\n" "3. Pollock A et al. (2014). Physical rehabilitation approaches for the recovery of mobility and lower limb function following stroke. Cochrane Database Syst Rev.\n" "4. Bobath B (1990). Adult Hemiplegia: Evaluation and Treatment (3rd ed.). Heinemann Medical Books.") for shape in slide34.shapes: if shape.has_text_frame and shape.name == 'Content Placeholder 4': tf = shape.text_frame # The placeholder is empty - add text by manipulating XML directly # Get the first paragraph element paras = tf.paragraphs if paras: para = paras[0] # Create a run element # First check if there's an existing run runs = para.runs if not runs: # Add a run with the text r_elem = para._p.makeelement(qn('a:r'), {}) t_elem = r_elem.makeelement(qn('a:t'), {}) t_elem.text = articles_text r_elem.append(t_elem) para._p.append(r_elem) print(f"Slide 34: Added articles text via XML") else: runs[0].text = articles_text print(f"Slide 34: Set articles text via run") prs.save("/tmp/workspace/stroke-case/stroke_case_output.pptx") print("Saved successfully.") print("SUCCESS") EOF

Running Command

python3 << 'EOF' from pptx import Presentation prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") # Verify fixes print("=== SLIDE 20 FINAL ===") slide20 = prs.slides[19] for shape in slide20.shapes: if shape.has_text_frame: for k, para in enumerate(shape.text_frame.paragraphs): if para.text.strip(): print(f" Para {k}: {repr(para.text[:200])}") print("\n=== SLIDE 26 ROW 7 ===") slide26 = prs.slides[25] for shape in slide26.shapes: if shape.has_table: row7 = shape.table.rows[7] print(f" {[cell.text_frame.text for cell in row7.cells]}") print("\n=== SLIDE 34 ===") slide34 = prs.slides[33] for shape in slide34.shapes: if shape.has_text_frame: txt = shape.text_frame.text.strip() if txt: print(f" Shape '{shape.name}': {repr(txt[:300])}") # Final summary check - check for any remaining lumbar/spondylosis references print("\n=== CHECKING FOR REMAINING OLD CONTENT ===") old_terms = ['lumbar', 'spondolysis', 'spondylosis', 'spondylolysis', '21 year', '21-Year', 'Low Back Pain', 'Pregabalin', 'Doloxetiene', 'Oswestry', 'OSWESTRY', 'hamstring', 'calves', 'L4-L5', 'L5-S1'] for i, slide in enumerate(prs.slides, 1): for shape in slide.shapes: if shape.has_text_frame: txt = shape.text_frame.text for term in old_terms: if term.lower() in txt.lower(): print(f" SLIDE {i}, Shape '{shape.name}': Found '{term}' in: {repr(txt[:100])}") if shape.has_table: for r, row in enumerate(shape.table.rows): for c, cell in enumerate(row.cells): ct = cell.text_frame.text for term in old_terms: if term.lower() in ct.lower(): print(f" SLIDE {i}, Table Cell[{r},{c}]: Found '{term}' in: {repr(ct[:80])}") EOF

Running Command

python3 << 'EOF' # Check the full text of slide 8 to see if "Low Back Pain" is still in the old content or just in the context from pptx import Presentation prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") slide8 = prs.slides[7] for shape in slide8.shapes: if shape.has_text_frame: print(f"Shape '{shape.name}':") print(repr(shape.text_frame.text)) print() EOF

Running Command

python3 << 'EOF' from pptx import Presentation from pptx.oxml.ns import qn prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") # Fix slide 8 - clear all remaining old text paragraphs slide8 = prs.slides[7] for shape in slide8.shapes: if shape.has_text_frame and shape.name == 'Content Placeholder 2': tf = shape.text_frame print("All paragraphs in slide 8 content:") for k, para in enumerate(tf.paragraphs): print(f" Para {k}: runs={len(para.runs)}, text={repr(para.text[:100])}") # Clear old chief complaint paragraph and any remaining old text for k, para in enumerate(tf.paragraphs): txt = para.text if ('Low Back Pain' in txt or 'radiates down' in txt or 'Almira' in txt or 'forward and backward' in txt or ('Chief Complaints' in txt and 'Low Back' in txt)): for run in para.runs: run.text = "" print(f" Cleared para {k}") prs.save("/tmp/workspace/stroke-case/stroke_case_output.pptx") print("Saved!") # Verify prs2 = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") slide8 = prs2.slides[7] for shape in slide8.shapes: if shape.has_text_frame and 'SUBJECTIVE' not in shape.text_frame.text: print("\nSlide 8 final content:") print(repr(shape.text_frame.text)) EOF

Running Command

python3 << 'EOF' from pptx import Presentation from pptx.oxml.ns import qn from lxml import etree import copy prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") # Check slide 34 content placeholder more carefully slide34 = prs.slides[33] for shape in slide34.shapes: print(f"Shape: '{shape.name}', type={shape.shape_type}, has_text={shape.has_text_frame}") if shape.has_text_frame: tf = shape.text_frame print(f" Paragraphs: {len(tf.paragraphs)}") for k, para in enumerate(tf.paragraphs): print(f" Para {k}: runs={len(para.runs)}, text={repr(para.text[:100])}") # Print raw XML of the text frame print(f" XML preview: {etree.tostring(tf._txBody, encoding='unicode')[:500]}") EOF

Running Command

python3 << 'EOF' from pptx import Presentation from pptx.oxml.ns import qn from lxml import etree prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") slide34 = prs.slides[33] for shape in slide34.shapes: if shape.name == 'Content Placeholder 4': # Print raw XML print(etree.tostring(shape._element, encoding='unicode')[:2000]) EOF

Running Command

python3 << 'EOF' # Slide 34's "Content Placeholder 4" is actually a picture element (p:pic), not a text box # The articles text needs to go somewhere else - let's check if there are any text shapes # we missed, or if we need to add a text box from pptx import Presentation from pptx.util import Inches, Pt, Emu from pptx.oxml.ns import qn from lxml import etree prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") slide34 = prs.slides[33] print("All shapes in slide 34:") for shape in slide34.shapes: print(f" Shape: '{shape.name}', type={shape.shape_type}, element_tag={shape._element.tag.split('}')[-1] if '}' in shape._element.tag else shape._element.tag}") # Slide 34 is originally just a title + image slide (picture with articles screenshot) # The articles are displayed as an image. We should add a text box for the articles # OR we can simply not modify it since it's an image-based slide per instructions: # "SLIDE 28 (Images slide - keep as-is, just images): No text changes needed." # However SLIDE 34 is "Case Related Articles" and we need to add text # Check where the image is positioned to know where to place text for shape in slide34.shapes: if hasattr(shape, 'left'): print(f" Position: left={shape.left}, top={shape.top}, width={shape.width}, height={shape.height}") EOF

Running Command

python3 << 'EOF' # Slide 34 originally had a picture where the articles text was displayed as an image # The task says to add body text. We need to add a text box for the articles. # Let's check slide dimensions first then add a text box. from pptx import Presentation from pptx.util import Inches, Pt, Emu from pptx.dml.color import RGBColor prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") # Slide dimensions slide_width = prs.slide_width slide_height = prs.slide_height print(f"Slide dimensions: {slide_width} x {slide_height} EMU") print(f"In inches: {slide_width/914400:.2f} x {slide_height/914400:.2f}") slide34 = prs.slides[33] # Add a text box with the articles text on the LEFT side (where there's no image currently) # Content Placeholder 4 (the old picture) is at: left=509028, top=952800, width=5375888, height=5678554 # We'll replace content by adding a text box in that same region from pptx.util import Emu left = Emu(509028) top = Emu(952800) width = Emu(5375888) height = Emu(5678554) articles_text = ("1. Veerbeek JM et al. (2014). What is the evidence for physical therapy poststroke? " "A systematic review and meta-analysis. PLOS ONE.\n\n" "2. Langhorne P et al. (2011). Motor recovery after stroke: a systematic review. Lancet Neurology.\n\n" "3. Pollock A et al. (2014). Physical rehabilitation approaches for the recovery of mobility and lower limb function following stroke. Cochrane Database Syst Rev.\n\n" "4. Bobath B (1990). Adult Hemiplegia: Evaluation and Treatment (3rd ed.). Heinemann Medical Books.") txBox = slide34.shapes.add_textbox(left, top, width, height) tf = txBox.text_frame tf.word_wrap = True from pptx.util import Pt from pptx.dml.color import RGBColor p = tf.paragraphs[0] p.text = articles_text run = p.runs[0] run.font.size = Pt(14) run.font.color.rgb = RGBColor(0x00, 0x00, 0x00) prs.save("/tmp/workspace/stroke-case/stroke_case_output.pptx") print("Saved with articles text box on slide 34!") # Verify prs2 = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") slide34 = prs2.slides[33] for shape in slide34.shapes: if shape.has_text_frame: txt = shape.text_frame.text.strip() if txt: print(f" '{shape.name}': {repr(txt[:200])}") EOF

Running Command

python3 << 'EOF' from pptx import Presentation prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") print(f"Total slides: {len(prs.slides)}") print("OUTPUT FILE: /tmp/workspace/stroke-case/stroke_case_output.pptx") print("="*80) # Quick summary of each slide's key text key_checks = { 1: "Post-Stroke Hemiplegia in a 56-Year-Old Male", 2: "56 year old male", 3: "STROKE (CEREBROVASCULAR ACCIDENT)", 4: "motor cortex, internal capsule", 5: "Corticospinal Tract", 6: "13.7 million new strokes", 7: "Hypertension", 8: "56 yr old", 9: "ischemic stroke", 10: "Circumduction gait", 11: "Ischemic Stroke 1 year back", 12: "TONE / TIGHTNESS HISTORY", 13: "Before treatment: 25/06/2026", 14: "Range of motion Before treatment", 15: "Modified Ashworth Scale", 16: "activity 5/10", 17: "BARTHEL INDEX SCORE: 45/100", 18: "PHYSIOTHERAPY OPD & NEURO PRESCRIPTIONS", 19: "MRI / CT FINDINGS", 20: "Left MCA ischemic stroke", 21: "right-side tightness", 22: "ICF Model", 23: "Hypertonia right UL & LL", 24: "Age 56, long duration", 25: "right-sided hypertonia", 26: "Anti-spasticity positioning", 27: "NDT / Bobath", 29: "After treatment: 06/07/2026", 30: "Range of motion After treatment", 31: "activity 3/10", 32: "BARTHEL INDEX SCORE: 65/100", 33: "plantar flexor stretch", 34: "Veerbeek JM", 35: "Carr JH, Shepherd", 36: "THANKYOU", } all_passed = True for slide_num, check_text in key_checks.items(): slide = prs.slides[slide_num - 1] full_text = "" for shape in slide.shapes: if shape.has_text_frame: full_text += shape.text_frame.text + " " if shape.has_table: for row in shape.table.rows: for cell in row.cells: full_text += cell.text_frame.text + " " if check_text.lower() in full_text.lower(): print(f" ✓ Slide {slide_num:2d}: '{check_text[:50]}'") else: print(f" ✗ Slide {slide_num:2d}: MISSING '{check_text[:50]}'") all_passed = False print() if all_passed: print("ALL CHECKS PASSED!") else: print("SOME CHECKS FAILED - review above.") # Check file size import os size = os.path.getsize("/tmp/workspace/stroke-case/stroke_case_output.pptx") print(f"\nFile size: {size:,} bytes ({size/1024/1024:.2f} MB)") EOF

Running Command

python3 << 'EOF' from pptx import Presentation prs = Presentation("/tmp/workspace/stroke-case/stroke_case_output.pptx") print("Checking for remaining OLD content terms...") old_terms = ['lumbar', 'spondolysis', 'spondylosis', 'spondylolysis', '21 year', '21-Year', 'Low Back Pain', 'Pregabalin', 'Doloxetiene', 'Oswestry', 'OSWESTRY', 'L4-L5', 'L5-S1', 'SLR TEST', '90-90 HAMSTRING', 'SLUMP TEST', 'FABERS'] issues_found = 0 for i, slide in enumerate(prs.slides, 1): for shape in slide.shapes: if shape.has_text_frame: txt = shape.text_frame.text for term in old_terms: if term.lower() in txt.lower(): print(f" SLIDE {i}, Shape '{shape.name}': Found '{term}'") issues_found += 1 if shape.has_table: for r, row in enumerate(shape.table.rows): for c, cell in enumerate(row.cells): ct = cell.text_frame.text for term in old_terms: if term.lower() in ct.lower(): print(f" SLIDE {i}, Table Cell[{r},{c}]: Found '{term}' in: {repr(ct[:60])}") issues_found += 1 if issues_found == 0: print(" ✓ No old content terms found. All clean!") else: print(f"\n {issues_found} old content instances found.") EOF

Running Command

ls -lh /tmp/workspace/stroke-case/stroke_case_output.pptx && python3 -c " from pptx import Presentation prs = Presentation('/tmp/workspace/stroke-case/stroke_case_output.pptx') print(f'Total slides: {len(prs.slides)}') # Quick verification of key slides key_slides = [0, 1, 2, 7, 9, 14, 19, 24, 25, 26] for i in key_slides: slide = prs.slides[i] print(f'\n--- SLIDE {i+1} ---') for shape in slide.shapes: if shape.has_text_frame and shape.text_frame.text.strip(): print(f' {shape.text_frame.text[:120]}') "

Where is the updatee ppt

Here is your updated presentation — ready to download:

stroke case output

Presentation · PPTX

What was updated across all 36 slides:
  • Title slide - Changed to "Physiotherapy Rehabilitation of Post-Stroke Hemiplegia in a 56-Year-Old Male"
  • Case Background - 56-year-old male, stroke 1 year ago, right-side tightness & hypertonia
  • Introduction - Stroke (CVA) definition and consequences
  • Anatomy - Brain, motor cortex, internal capsule, corticospinal tract
  • Subjective Assessment - Age 56, Retired Labourer, chief complaint = right-side hypertonia & hemiplegic posture
  • HOPI - Ischemic stroke 1 year ago, thrombolysis, residual right hemiplegia
  • Objective Assessment - Circumduction gait, hemiplegic posture, MAS Grade 2 hypertonia, positive clonus
  • Medical History - Aspirin, Atorvastatin, Baclofen, Amlodipine
  • Special Tests - MAS, Fugl-Meyer (45/100), Berg Balance Scale (28/56), Babinski sign
  • Diagnosis - Left MCA ischemic stroke with right spastic hemiplegia
  • Treatment (Phase 1 & 2) - Anti-spasticity positioning, NDT/Bobath, FES, mirror therapy, gait retraining
  • Outcome Measures - NPRS & Barthel Index (pre: 45/100 moderate → post: 65/100 mild dependence)
  • References - Carr, Bobath, Shumway-Cook, O'Sullivan neuro-rehab textbooks
All original formatting, colors, fonts, images, and layout are preserved.

Can you remove existing photos of anatomical diagram and remove photos and add stroke mri findings and add stroke diagram remove bhavesh surah mpt neurology to samson stephen mpt neurology

Running Command

python3 -c " from pptx import Presentation from pptx.util import Emu prs = Presentation('/tmp/workspace/stroke-case/stroke_case_output.pptx') for i, slide in enumerate(prs.slides, 1): pics = [(s.name, round(Emu(s.left).inches,2), round(Emu(s.top).inches,2), round(Emu(s.width).inches,2), round(Emu(s.height).inches,2)) for s in slide.shapes if s.shape_type == 13] if pics: print(f'Slide {i}: {pics}') "

Running Command

mkdir -p /tmp/workspace/stroke-case/images # Download stroke brain anatomy diagram (labeled brain showing MCA territory) curl -L -o /tmp/workspace/stroke-case/images/stroke_brain_diagram.jpg \ "https://upload.wikimedia.org/wikipedia/commons/thumb/1/10/Blausen_0817_Stroke.png/800px-Blausen_0817_Stroke.png" \ --max-time 30 -s -w "stroke_brain_diagram: %{http_code} %{size_download} bytes\n" # Download MCA ischemic stroke MRI/CT image (public domain) curl -L -o /tmp/workspace/stroke-case/images/stroke_mri.jpg \ "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/MCA_territory_infarct.jpg/600px-MCA_territory_infarct.jpg" \ --max-time 30 -s -w "stroke_mri: %{http_code} %{size_download} bytes\n" # Download brain corticospinal tract anatomy diagram curl -L -o /tmp/workspace/stroke-case/images/brain_anatomy.jpg \ "https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Gray756.png/400px-Gray756.png" \ --max-time 30 -s -w "brain_anatomy: %{http_code} %{size_download} bytes\n" ls -lh /tmp/workspace/stroke-case/images/

Running Command

# Try the built-in fetch_images helper with working URLs python /tmp/skills/shared/scripts/fetch_images.py \ "https://www.hopkinsmedicine.org/-/media/images/health/1_-conditions/brain/stroke-brain.jpg" \ "https://prod-images-static.radiopaedia.org/images/157710/0ca45f979b9e51e59c14f08e50d5ce_big_gallery.jpg" \ "https://www.strokeassociation.org/wp-content/uploads/2021/04/stroke-brain-diagram.jpg" 2>/dev/null | python3 -c " import json,sys data = json.load(sys.stdin) for d in data: b64 = d.get('base64','') err = d.get('error','') print(d['url'][:60], '| b64_len:', len(b64) if b64 else 0, '| err:', err[:60] if err else 'none') "

Searching the Web

ischemic stroke MRI brain CT scan image site:wikimedia.org OR site:nih.gov filetype:jpg OR filetype:png

Running Command

python /tmp/skills/shared/scripts/fetch_images.py \ "https://cdn.ncbi.nlm.nih.gov/pmc/blobs/dc8c/3505566/27e9fbdcae58/13244_2012_185_Fig2_HTML.jpg" \ "https://cdn.ncbi.nlm.nih.gov/pmc/blobs/3edb/4200598/b787d4bd06d5/jos-16-131-g004.jpg" \ "https://cdn.ncbi.nlm.nih.gov/pmc/blobs/3d62/5898964/5beeb604b332/7FF12.jpg" 2>/dev/null | python3 -c " import json,sys,base64 data = json.load(sys.stdin) for i,d in enumerate(data): b64 = d.get('base64','') err = d.get('error','') if b64: raw = base64.b64decode(b64.split(',',1)[1]) fname = f'/tmp/workspace/stroke-case/images/img_{i}.jpg' with open(fname,'wb') as f: f.write(raw) print(f'Saved {fname} ({len(raw)} bytes)') else: print(f'FAILED {d[\"url\"][:60]}: {err[:80]}') "

Loading Image
Loading Image
Loading Image
Generating Image

Medical diagram of the human brain showing stroke anatomy - labeled brain cross-section showing left MCA (middle cerebral artery) territory infarct, corticospinal tract, internal capsule, motor cortex highlighted in red, white background, clean medical illustration style with labels

Running Command

python /tmp/skills/shared/scripts/fetch_images.py \ "https://cdn.orris.care/image-gen/47305aa633df415291262144dbd0d1e4.png" 2>/dev/null | python3 -c " import json,sys,base64 data = json.load(sys.stdin) d = data[0] b64 = d.get('base64','') if b64: raw = base64.b64decode(b64.split(',',1)[1]) with open('/tmp/workspace/stroke-case/images/stroke_diagram.png','wb') as f: f.write(raw) print(f'Saved stroke_diagram.png ({len(raw)} bytes)') else: print('FAILED:', d.get('error','')) "

Running Command

python3 << 'PYEOF' from pptx import Presentation from pptx.util import Inches, Emu from pptx.oxml.ns import qn from lxml import etree import copy, os SRC = "/tmp/workspace/stroke-case/stroke_case_output.pptx" OUT = "/tmp/workspace/stroke-case/stroke_final.pptx" IMG_DIAGRAM = "/tmp/workspace/stroke-case/images/stroke_diagram.png" # generated brain anatomy IMG_MRI_CLEAN = "/tmp/workspace/stroke-case/images/img_0.jpg" # clean FLAIR/DWI IMG_CT_STROKE = "/tmp/workspace/stroke-case/images/img_1.jpg" # CT hemorrhagic/ischemic IMG_DWI_MCA = "/tmp/workspace/stroke-case/images/img_2.jpg" # DWI/MRA MCA stroke prs = Presentation(SRC) def replace_picture(slide, pic_name, new_img_path): """Replace the image file referenced by pic_name with new_img_path, keeping same position/size.""" for shape in slide.shapes: if shape.shape_type == 13 and shape.name == pic_name: left = shape.left top = shape.top width = shape.width height = shape.height sp_elem = shape._element # Remove old picture element sp_elem.getparent().remove(sp_elem) # Add new picture pic = slide.shapes.add_picture(new_img_path, left, top, width, height) pic.name = pic_name print(f" Replaced {pic_name} on slide with {os.path.basename(new_img_path)}") return True print(f" WARNING: {pic_name} not found on slide") return False def remove_all_pictures(slide): """Remove ALL picture shapes from a slide.""" to_remove = [s._element for s in slide.shapes if s.shape_type == 13] for el in to_remove: el.getparent().remove(el) print(f" Removed {len(to_remove)} pictures from slide") def add_picture(slide, img_path, left_in, top_in, width_in, height_in): """Add a picture at specified position (in inches).""" pic = slide.shapes.add_picture( img_path, Inches(left_in), Inches(top_in), Inches(width_in), Inches(height_in) ) print(f" Added {os.path.basename(img_path)} at ({left_in},{top_in}) size {width_in}x{height_in}") return pic # ── SLIDE 1 ── Keep existing logo image; rename Bhavesh Surah → Samson Stephen print("Slide 1: Rename presenter") slide1 = prs.slides[0] for shape in slide1.shapes: if shape.has_text_frame: for para in shape.text_frame.paragraphs: for run in para.runs: if "Bhavesh Surah" in run.text: run.text = run.text.replace("Bhavesh Surah", "Samson Stephen") print(" Renamed Bhavesh Surah -> Samson Stephen") if "Bhavesh" in run.text: run.text = run.text.replace("Bhavesh", "Samson") print(" Replaced Bhavesh -> Samson") # ── SLIDE 3 ── Remove existing picture (Picture 9 at pos 9.0, 1.48) → add stroke brain diagram print("\nSlide 3: Replace anatomy image with stroke brain diagram") slide3 = prs.slides[2] remove_all_pictures(slide3) add_picture(slide3, IMG_DIAGRAM, 8.5, 1.3, 4.5, 5.4) # ── SLIDE 4 ── Remove existing anatomy picture → add DWI/MCA stroke image print("\nSlide 4: Replace anatomy image with DWI/MCA stroke MRI") slide4 = prs.slides[3] remove_all_pictures(slide4) add_picture(slide4, IMG_DWI_MCA, 7.5, 0.7, 5.0, 6.3) # ── SLIDE 5 ── No pictures originally in slide 5 (just text) - skip print("\nSlide 5: No pictures - skip") # ── SLIDE 19 ── Remove existing MRI picture → add proper stroke CT/MRI images print("\nSlide 19: Replace MRI image with stroke CT brain image") slide19 = prs.slides[18] remove_all_pictures(slide19) # Add CT stroke image on right side add_picture(slide19, IMG_CT_STROKE, 6.0, 0.7, 6.8, 6.8) # Also add clean MRI on left area if space (slide is 13.33in wide) # Actually just use one large good image # Let's add both: left side MRI, right side CT add_picture(slide19, IMG_MRI_CLEAN, 6.0, 0.7, 3.2, 3.2) add_picture(slide19, IMG_CT_STROKE, 9.4, 0.7, 3.5, 3.5) prs.save(OUT) print(f"\nSaved to {OUT}") print("File size:", os.path.getsize(OUT), "bytes") PYEOF

Running Command

python3 << 'PYEOF' from pptx import Presentation from pptx.util import Inches import os SRC = "/tmp/workspace/stroke-case/stroke_case_output.pptx" OUT = "/tmp/workspace/stroke-case/stroke_final.pptx" IMG_DIAGRAM = "/tmp/workspace/stroke-case/images/stroke_diagram.png" IMG_MRI_CLEAN = "/tmp/workspace/stroke-case/images/img_0.jpg" IMG_CT_STROKE = "/tmp/workspace/stroke-case/images/img_1.jpg" IMG_DWI_MCA = "/tmp/workspace/stroke-case/images/img_2.jpg" prs = Presentation(SRC) def remove_all_pictures(slide): to_remove = [s._element for s in slide.shapes if s.shape_type == 13] for el in to_remove: el.getparent().remove(el) return len(to_remove) def add_picture(slide, img_path, left_in, top_in, width_in, height_in): return slide.shapes.add_picture( img_path, Inches(left_in), Inches(top_in), Inches(width_in), Inches(height_in) ) # SLIDE 1 – rename presenter slide1 = prs.slides[0] for shape in slide1.shapes: if shape.has_text_frame: for para in shape.text_frame.paragraphs: for run in para.runs: if "Bhavesh Surah" in run.text: run.text = run.text.replace("Bhavesh Surah", "Samson Stephen") elif "Bhavesh" in run.text: run.text = run.text.replace("Bhavesh", "Samson") # SLIDE 3 – stroke brain anatomy diagram (right side, slide is 13.33" wide) slide3 = prs.slides[2] remove_all_pictures(slide3) add_picture(slide3, IMG_DIAGRAM, 8.6, 1.2, 4.4, 5.5) # SLIDE 4 – DWI/MRA MCA stroke imaging (right side) slide4 = prs.slides[3] remove_all_pictures(slide4) add_picture(slide4, IMG_DWI_MCA, 7.6, 0.6, 5.3, 6.6) # SLIDE 19 – CT + MRI side by side on right side of slide # Left half (~0-6.5") has text, right half (6.5-13.33") has images slide19 = prs.slides[18] remove_all_pictures(slide19) # Top-right: MRI FLAIR/DWI clean add_picture(slide19, IMG_MRI_CLEAN, 6.5, 0.5, 3.3, 3.2) # Bottom-right: CT hemorrhagic/ischemic stroke add_picture(slide19, IMG_CT_STROKE, 6.5, 3.9, 3.3, 3.5) prs.save(OUT) # Verify prs2 = Presentation(OUT) print("=== VERIFICATION ===") # Check slide 1 name s1 = prs2.slides[0] for shape in s1.shapes: if shape.has_text_frame and "Stephen" in shape.text_frame.text: print("✓ Slide 1: Name updated to Samson Stephen") # Check picture counts for idx, label, expected_pics in [(2,"Slide 3",1),(3,"Slide 4",1),(18,"Slide 19",2)]: s = prs2.slides[idx] pics = [sh for sh in s.shapes if sh.shape_type == 13] status = "✓" if len(pics) == expected_pics else "✗" print(f"{status} {label}: {len(pics)} picture(s) (expected {expected_pics})") print(f"\nFile: {OUT}") print(f"Size: {os.path.getsize(OUT)/1024/1024:.2f} MB") PYEOF

Your updated presentation is ready:

stroke final

Presentation · PPTX

Here is a summary of every change made:
Images replaced:
  • Slide 3 (Introduction) - Old lumbar spine diagram removed → replaced with a labeled stroke brain anatomy diagram showing MCA territory, motor cortex, internal capsule, and corticospinal tract
  • Slide 4 (Anatomy) - Old lumbar vertebrae image removed → replaced with a DWI/PWI/MRA stroke imaging panel showing MCA occlusion and perfusion deficit
  • Slide 19 (MRI/CT Findings) - Old image removed → two real clinical images added side by side:
    • Top: Brain MRI (FLAIR + DWI) showing ischemic changes
    • Bottom: CT brain showing ischemic/hemorrhagic stroke patterns with labeled classification
Name updated:
  • Slide 1 - "Presented By – Bhavesh Surah (MPT NEURO)" changed to "Presented By – Samson Stephen (MPT NEURO)"

Create a printable PDF version of this presentation

This is a shared conversation. Sign in to Orris to start your own chat.