Analyse these files and build a ppt on Altb(croup) ,epiglottis and foriegn body. The ppt should be simple with maximum 9 lines per page just like altb2 copy 2.pptx .
cd /tmp/workspace/attachments/*/ && python -c " from pptx import Presentation from pptx.util import Emu for f in ['ALTB copy 2.pptx','Epiglottitis_and_Croup_Seminar.pptx']: p=Presentation(f); print('=====',f,p.slide_width,p.slide_height,len(p.slides)) for i,s in enumerate(p.slides,1): print('--- slide',i,s.slide_layout.name) for sh in s.shapes: print(' [%s] %s'%(sh.shape_type,sh.name), end=' ') if sh.has_text_frame: print(repr(sh.text_frame.text[:600])) else: print() "
cd /tmp/workspace/attachments/*/ && mkdir -p /tmp/workspace/croup/ref && python -c " from pptx import Presentation p=Presentation('ALTB copy 2.pptx') for i in [11,12,14]: s=p.slides[i-1] for sh in s.shapes: if sh.has_table: print('slide',i) for r in sh.table.rows: print([c.text for c in r.cells]) for i,s in enumerate(p.slides,1): for sh in s.shapes: if sh.shape_type==13 or (sh.is_placeholder and hasattr(sh,'image')): try: fn='/tmp/workspace/croup/ref/s%d_%s'%(i,sh.image.filename or sh.name) open(fn,'wb').write(sh.image.blob); print(fn,sh.image.size) except Exception as e: pass s=p.slides[9] for sh in s.shapes: print(sh.name,sh.left,sh.top,sh.width,sh.height) if sh.has_text_frame: for para in sh.text_frame.paragraphs: for r in para.runs: print(r.font.size,r.font.name,r.font.bold, r.font.color.rgb if r.font.color and r.font.color.type else None); break print([l.name for l in p.slide_layouts]) "; ls -la /tmp/workspace/croup/ref; python /tmp/skills/pptx/scripts/office/unpack.py "ALTB copy 2.pptx" /tmp/workspace/croup/unp >/dev/null; ls /tmp/workspace/croup/unp/ppt/theme; grep -o '<a:srgbClr val="[0-9A-F]*"' /tmp/workspace/croup/unp/ppt/theme/theme1.xml | head -12; grep -o 'typeface="[^"]*"' /tmp/workspace/croup/unp/ppt/theme/theme1.xml | head -4
cd /tmp/workspace/croup/ref && python -c " from PIL import Image for n in ['s9','s21','s5','s6','s8']: im=Image.open(n+'_image.jpeg').convert('RGB'); im.thumbnail((700,700)); im.save('t_'+n+'.jpg') "; ls
cd /tmp/workspace/attachments/*/ && python -c " from pptx import Presentation p=Presentation('Epiglottitis_and_Croup_Seminar.pptx') for i in [9,20,25,4]: for sh in p.slides[i-1].shapes: if sh.shape_type==13: fn='/tmp/workspace/croup/ref/e%d_%s.%s'%(i,sh.name.replace(' ',''),sh.image.ext); open(fn,'wb').write(sh.image.blob); print(fn,sh.image.size,sh.image.ext) p=Presentation('ALTB copy 2.pptx') for n in ['Title & Bullets','Title, Bullets & Photo','Title - Centre','Title','Photo - Horizontal']: l=[x for x in p.slide_layouts if x.name==n][0] print('==',n) for sh in l.placeholders: print(sh.placeholder_format.idx,sh.placeholder_format.type,sh.name,sh.left,sh.top,sh.width,sh.height) " cd /tmp/workspace/croup/unp/ppt/slideLayouts; grep -l 'Title & Bullets' *.xml | head;
cd /tmp/workspace/croup/unp/ppt && python -c " import re x=open('slideLayouts/slideLayout7.xml').read() print(len(x)); print(re.findall(r'sz=\"\d+\"',x)[:10]); print(re.findall(r'<a:normAutofit[^>]*>|<a:spAutoFit/>',x)) m=open('slideMasters/slideMaster1.xml').read() print(re.findall(r'<p:(?:titleStyle|bodyStyle)>.{0,700}',m,re.S)[0][:900]); print(re.findall(r'<p:bodyStyle>.{0,900}',m,re.S)[0]) "; ls slides | head -30; python -c " x=open('/tmp/workspace/croup/unp/ppt/slides/slide10.xml').read(); print(x[:3500])"; grep -o '<p:bg>.*</p:bg>' slideMasters/slideMaster1.xml | head -c 400
cd /tmp/workspace/croup/unp/ppt && python - <<'E' import re for f in ['slideMasters/slideMaster1.xml','slideLayouts/slideLayout7.xml']: x=open(f).read(); print(f, re.findall(r'<p:bg>.*?</p:bg>',x,re.S)[:1]) print(re.findall(r'<a:dk1>.*?</a:lt2>',open('theme/theme1.xml').read(),re.S)[0][:600]) E python - <<'E' from pptx import Presentation p=Presentation('/tmp/workspace/attachments/2a22ff8a-ede3-41f9-95c8-a4b51018287e/ALTB copy 2.pptx') for i in [13,2,3]: s=p.slides[i-1] print(i,[ (sh.name[:20],sh.left,sh.top,sh.width,sh.height) for sh in s.shapes]) for sh in s.shapes: if sh.shape_type==13: open('/tmp/workspace/croup/ref/x%d_%s.%s'%(i,sh.name,sh.image.ext),'wb').write(sh.image.blob) E ls /tmp/workspace/croup/ref
mkdir -p /tmp/workspace/croup/out /tmp/workspace/croup/img && cat > /tmp/workspace/croup/build.py <<'E' import copy, glob from PIL import Image from pptx import Presentation from pptx.util import Pt, Emu from pptx.dml.color import RGBColor from pptx.enum.text import PP_ALIGN, MSO_ANCHOR SRC=glob.glob('/tmp/workspace/attachments/*/ALTB copy 2.pptx')[0] R='/tmp/workspace/croup/ref/'; I='/tmp/workspace/croup/img/' def prep(src,name,maxw=1800): im=Image.open(R+src).convert('RGB'); im.thumbnail((maxw,maxw)); im.save(I+name,quality=88); return I+name img={'cartoon':prep('s5_image.jpeg','cartoon.jpg'),'larynx':prep('s6_image.jpeg','larynx.jpg'), 'steeple':prep('s9_image.jpeg','steeple.jpg'),'thumb':prep('s13_image.jpeg','thumb.jpg'), 'fb':prep('s21_image.jpeg','fb.jpg')} prs=Presentation(SRC) # remove all existing slides lst=prs.slides._sldIdLst for sid in list(lst): prs.part.drop_rel(sid.rId); lst.remove(sid) L={l.name:l for l in prs.slide_layouts} WHITE=RGBColor(255,255,255) def set_title(sl,text,size,left=762000,top=431800,w=22860000,h=1930034): t=sl.shapes.title; t.left,t.top,t.width,t.height=left,top,w,h t.text_frame.text=text for r in t.text_frame.paragraphs[0].runs: r.font.size=Pt(size) return t def bullets(sl,items,size=44,left=762000,top=2700000,w=22860000,h=10300000,gap=24): b=sl.placeholders[1]; b.left,b.top,b.width,b.height=left,top,w,h tf=b.text_frame for i,t in enumerate(items): p=tf.paragraphs[0] if i==0 else tf.add_paragraph() p.space_before=Pt(gap) r=p.add_run(); r.text=t; r.font.size=Pt(size); r.font.color.rgb=WHITE return b def text_slide(title,items,size=44,tsize=66): sl=prs.slides.add_slide(L['Title & Bullets']); set_title(sl,title,tsize); bullets(sl,items,size); return sl def photo_slide(title,items,pic,size=38,tsize=54,box=(13300000,2500000,11000000,10600000)): sl=prs.slides.add_slide(L['Title & Bullets']) set_title(sl,title,tsize,w=12300000) bullets(sl,items,size,w=12300000,gap=22) bx,by,bw,bh=box im=Image.open(pic); ar=im.width/im.height w=bw; h=w/ar if h>bh: h=bh; w=h*ar sl.shapes.add_picture(pic,int(bx+(bw-w)/2),int(by+(bh-h)/2),int(w),int(h)) return sl # 1 title sl=prs.slides.add_slide(L['Title']) t=sl.shapes.title; t.text_frame.text='ALTB, EPIGLOTTITIS AND FOREIGN BODY ASPIRATION' for r in t.text_frame.paragraphs[0].runs: r.font.size=Pt(72) sl.placeholders[1].text_frame.text='Acute stridor in children' text_slide('Child with stridor',[ 'Stridor = noisy breathing from upper airway obstruction', 'Croup (ALTB): viral, 6 months to 3 years', 'Acute epiglottitis: H. influenzae type B, 3 to 6 years', 'Bacterial tracheitis: S. aureus, toxic child', 'Foreign body aspiration: sudden onset, 1 to 4 years', 'Endoscopy helps diagnosis and can treat (remove foreign body)']) text_slide('Acute laryngotracheobronchitis (croup)',[ 'Inflammation of larynx, trachea and bronchi', 'Peculiar BRASSY (barking) cough is the main feature', 'Viral upper respiratory tract infection', 'Age: 6 months to 3 years', 'Follows an episode of common cold', 'More common in autumn and winter']) text_slide('Aetiology',[ 'Usually viral infection', 'Parainfluenza types 1 (most common), 2 and 3', 'Respiratory syncytial virus (RSV)', 'Influenza virus', 'Adenovirus', 'Rhinovirus', 'Bacterial superinfection is rare']) photo_slide('Clinical features',[ 'Mild cold for a few days first', 'Then brassy (barking) cough', 'Hoarse voice, mild inspiratory stridor', 'Low grade fever, child not toxic', 'Stridor becomes biphasic as obstruction increases', 'Worse at night and on crying', 'Retractions and restlessness; hypoxia if severe'],img['cartoon']) photo_slide('Pathology',[ 'Oedema of the subglottic mucosa', 'Cricoid ring is fixed: no room to expand', '1 mm of oedema in an infant halves the airway area', 'Narrow lumen gives turbulent flow: stridor', 'Swollen vocal cords give hoarseness', 'Crying increases flow and worsens stridor'],img['larynx'],size=38) photo_slide('Radiology',[ 'Diagnosis is mainly clinical', 'AP neck / chest X-ray', 'STEEPLE SIGN: narrowing of the subglottic region', 'X-ray not needed in typical croup', 'A normal film does not exclude croup'],img['steeple'],size=40) text_slide('Assessment of severity',[ 'MILD: happy, feeds well; stridor only on coughing; SpO2 above 92%', 'MODERATE: irritable but comforted by parents; stridor at rest when agitated; tachypnoea and chest retractions', 'SEVERE: restless, agitated or drowsy; stridor at rest, worse on agitation; marked retractions; SpO2 below 92%, may be cyanosed', 'Silent chest and fatigue = impending respiratory failure'],size=42) text_slide('Management of croup (1)',[ 'Most cases are mild and settle in 1 to 2 days', 'Reassurance, cool mist and oral hydration', 'NEBULISED EPINEPHRINE 1:1000, 0.1 to 0.5 mL/kg (max 5 mL)', 'Gives symptomatic relief; effect is brief, so observe', 'Oxygen if hypoxic; keep child with parent', 'Severe croup: call senior airway team and ICU'],size=44) text_slide('Management of croup (2)',[ 'DEXAMETHASONE 0.3 to 0.6 mg/kg single dose', 'Reduces severity if given within the first 24 hours', 'Oral route is equally effective and often preferred to IM', 'Inhaled BUDESONIDE 1 mg twice a day for 2 days', 'ANTIBIOTICS (Staphylococcus, H. influenzae) only if no improvement or purulent secretions', 'Avoid sedatives'],size=44) text_slide('Acute epiglottitis',[ 'Also called supraglottitis', 'Infection of epiglottis and supraglottic structures', 'Cause: Haemophilus influenzae type B', 'Less common than croup but more severe', 'Age: usually 3 to 6 years', 'Incidence has fallen with Hib immunisation', 'Airway emergency: can obstruct within hours']) text_slide('Epiglottitis: clinical features',[ 'Acute sore throat and high fever', 'Toxic looking child', 'Muffled voice', 'Marked dysphagia and DROOLING', 'Inspiratory stridor', 'Cough is usually absent', 'TRIPOD position: sits leaning forward to breathe better', 'Rapid onset, often within hours']) photo_slide('Epiglottitis: diagnosis',[ 'Lateral neck X-ray: THUMBPRINT SIGN (thickened epiglottis)', 'Never delay the airway for an X-ray', 'Do not lay the child flat', 'Flexible endoscopy in atypical cases: oedema and erythema of supraglottis', 'Blood tests only after the airway is secure'],img['thumb'],size=38,tsize=50) text_slide('Epiglottitis: management',[ 'Do NOT examine oropharynx or larynx: can cause fatal laryngospasm', 'Keep child calm, on parent\'s lap, in position of comfort', 'Call senior anaesthetist and ENT surgeon early', 'Rapid airway management in theatre', 'Intubation by skilled personnel, or rigid bronchoscopy followed by tracheostomy', 'IV cefotaxime or ceftriaxone for 7 days'],size=44) sl=prs.slides.add_slide(L['Title - Centre']) sl.shapes.title.text_frame.text='Never examine the oral cavity of a child who is having stridor' # comparison table sl=prs.slides.add_slide(L['Title & Bullets']); set_title(sl,'ALTB versus epiglottitis',66) sl.placeholders[1]._element.getparent().remove(sl.placeholders[1]._element) rows=[('','ALTB (croup)','EPIGLOTTITIS'), ('Cause','Viral (parainfluenza)','Bacterial (H. influenzae type B)'), ('Age','6 months to 3 years','3 to 6 years'), ('Onset','Gradual, after a cold','Sudden, within hours'), ('Fever','Low grade, not toxic','High grade, toxic child'), ('Cough / voice','Barking cough, hoarse','No cough, muffled voice'), ('Swallowing','Normal','Dysphagia and drooling'), ('X-ray','STEEPLE sign (subglottic)','THUMBPRINT sign (epiglottis)'), ('Treatment','Epinephrine, steroids','Secure airway, IV antibiotics')] gs=sl.shapes.add_table(len(rows),3,762000,2500000,22860000,10200000) tb=gs.table tb.columns[0].width=Emu(4800000); tb.columns[1].width=Emu(8800000); tb.columns[2].width=Emu(9260000) for ri,row in enumerate(rows): tb.rows[ri].height=Emu(1130000) for ci,txt in enumerate(row): c=tb.cell(ri,ci); c.fill.solid() c.fill.fore_color.rgb=RGBColor(0x1F,0x6F,0x9F) if ri==0 else (RGBColor(0x38,0x38,0x38) if ri%2 else RGBColor(0x2E,0x2E,0x2E)) c.vertical_anchor=MSO_ANCHOR.MIDDLE tf=c.text_frame; tf.text=txt for r in tf.paragraphs[0].runs: r.font.size=Pt(34); r.font.color.rgb=WHITE; r.font.bold=(ri==0 or ci==0) text_slide('Bacterial tracheitis',[ 'Usually caused by Staphylococcus aureus', 'Affects younger children after a viral URI', 'Child looks toxic with a brassy cough', 'Biphasic or expiratory stridor', 'Thick purulent secretions; poor response to croup treatment', 'Treatment: bronchoscopy to clear airway and IV antibiotics']) text_slide('Foreign body aspiration',[ 'Consider in any child with ACUTE ONSET stridor and airway obstruction', 'Young children (1 to 4 years) aspirate small objects', 'Site depends on size, shape and nature of the object', 'Large object lodges in the supraglottic area', 'Small object passes into trachea and bronchi', 'Sharp pointed objects can stick anywhere'],size=44) text_slide('Nature of foreign body',[ 'NON IRRITATING: plastic, metal', 'May stay symptomless for a long time', 'IRRITATING: organic or vegetable matter (e.g. peanuts)', 'Swells up and causes severe symptoms', 'Commonest site: right main bronchus', 'Larynx: stridor; bronchus: wheeze and cough']) text_slide('Foreign body: clinical features',[ '1. Choking, gagging and wheezing (short period)', 'Object may be coughed out or lodge in larynx or bronchi', '2. Symptomless period', 'Mucosa adapts to the object; lasts hours to weeks', '3. Later symptoms from airway obstruction', 'Cough, wheeze, recurrent chest infection']) text_slide('Foreign body: chest signs',[ 'Hyperresonance, diminished vocal resonance, poor air entry', 'Hyperresonance is hard to elicit in children', 'Localised poor air entry with chronic chest illness: suspect foreign body', 'Partial obstruction: BALL VALVE effect, air trapping and hyperinflation', 'Complete obstruction: distal atelectasis', 'Later: suppuration and BRONCHIECTASIS'],size=44) photo_slide('Foreign body: X-ray',[ 'Many objects are radiolucent', 'Look for hyperinflation, atelectasis, mediastinal shift', 'Expiratory film shows air trapping', 'Figure: foreign body in right main bronchus', 'Normal X-ray does not exclude foreign body'],img['fb'],size=40,tsize=54) text_slide('Foreign body: management',[ 'Remove with a RIGID BRONCHOSCOPE', 'Bronchoscopy if clinical and X-ray picture suggests it, even with no history', 'ANTIBIOTICS for secondary infection', 'Complete airway obstruction: back blows and chest thrusts in infants, Heimlich manoeuvre in older children'],size=44) text_slide('Key points',[ 'Croup: viral, barking cough, steeple sign, steroid + epinephrine', 'Epiglottitis: Hib, toxic, drooling, thumbprint sign, secure airway first', 'Foreign body: sudden choking, rigid bronchoscopy', 'Never examine the throat of a child with stridor'],size=46) sl=prs.slides.add_slide(L['Title - Centre']); sl.shapes.title.text_frame.text='Thank you' prs.save('/tmp/workspace/croup/out/ALTB_Epiglottitis_Foreign_Body.pptx') print(len(prs.slides)) E cd /tmp/workspace/croup && python build.py
cd /tmp/workspace/croup && python - <<'E' from pptx import Presentation import math p=Presentation('out/ALTB_Epiglottitis_Foreign_Body.pptx') for i,s in enumerate(p.slides,1): for sh in s.placeholders: if sh.placeholder_format.idx==1 and sh.has_text_frame and i>1: w=sh.width/914400-0.8 tot=0;hh=0 for para in sh.text_frame.paragraphs: sz=para.runs[0].font.size.pt cpl=w*72/(sz*0.52) n=math.ceil(len(para.text)/cpl); tot+=n; hh+=n*sz*1.2+para.space_before.pt print(i,'lines~',tot,'height in~',round(hh/72,1),'avail',round(sh.height/914400,1)) E
ALTB Epiglottitis Foreign Body
Presentation · PPTX
Replace images and add images from standard texts like nelson pediatrics, don't exactly copy lines from altb copy2 .pptx slide make some alteration.
croup steeple sign AP neck radiograph subglottic narrowing

Anteroposterior (AP) portable radiograph of the neck and upper thorax showing the cervical spine and proximal airway. The image displays a clear 'steeple sign,' characterized by subglottic narrowing of the tracheal air column, indicated by a horizontal red arrow. This finding is classically associated with croup (laryngotracheobronchitis) or other causes of subglottic edema. Anatomical structures visible include the cervical vertebrae, clavicles, upper ribs, and the radiolucent tracheal column. A 'PORTABLE' label is present in the bottom left, and a right-side marker 'R' is located in the upper left corner. The cervical spine shows normal alignment, while the focal narrowing is centered in the proximal subglottic region below the level of the larynx.

Antero-posterior (AP) soft tissue neck radiograph of a pediatric patient, presented as side-by-side images (unannotated and annotated) to demonstrate the methodology for calculating the Frontal Ratio (FR) of tracheal narrowing. The radiograph displays the cervical spine, base of the skull, clavicles, and the air-filled tracheal column. The annotated image on the right illustrates the measurement technique for subglottic stenosis: label 'A' marks the narrowest diameter of the subglottic trachea, while label 'B' indicates the reference tracheal width measured at the level of the clavicles. The mathematical relationship is provided as FR = A/B. This diagnostic imaging technique is typically used in the evaluation of upper airway obstruction, such as croup (laryngotracheobronchitis), where the 'steeple sign'—the characteristic tapering of the subglottic airway—is a hallmark finding. This material is designed for radiology and pediatric educational purposes to quantify the degree of airway constriction.
epiglottitis thumb sign lateral neck radiograph

This diagnostic image is a lateral soft tissue neck radiograph (X-ray) demonstrating classic findings associated with acute epiglottitis. The primary finding is a markedly enlarged and swollen epiglottis, presenting the 'thumbprint sign'—a radiographic hallmark where the normally thin, leaf-like epiglottis becomes rounded and thickened, resembling the silhouette of a thumb. The surrounding supraglottic soft tissues are edematous, leading to a visible narrowing of the supraglottic airway column. Key anatomical structures visible include the cervical vertebrae (C1-C7), the mandible and teeth, the hyoid bone, and the prevertebral soft tissues. The orientation shows the airway anterior to the cervical spine, with the pathology localized to the upper laryngeal region. This radiographic view is clinically significant for evaluating upper airway obstruction and differentiating epiglottitis from other conditions like croup or retropharyngeal abscess. The image is suitable for medical education in emergency medicine, radiology, and otolaryngology.

This lateral soft tissue neck X-ray of a pediatric patient demonstrates classic diagnostic signs of acute epiglottitis (supraglottitis). The imaging modality focuses on the upper airway, revealing a significantly enlarged and rounded epiglottis, often referred to as the 'thumb sign.' Additionally, the arytenoid cartilages and aryepiglottic folds appear thickened and convex due to edema. There is a secondary distention of the hypopharynx, indicative of partial airway obstruction. The radiograph also captures the cervical vertebrae, skull base, and upper thorax, where the skeletal structures appear normal for age. This clinical image is a critical educational tool for identifying life-threatening pediatric airway emergencies. Key concepts include airway management, recognizing radiographic signs of inflammation, and the anatomical relationship between the tongue base, epiglottis, and laryngeal inlet.
foreign body aspiration bronchus chest radiograph hyperinflation air trapping

This diagnostic image is a posterior-anterior (PA) chest radiograph of a pediatric patient. The primary finding is a significant asymmetry in lung lucency, with the left lung field appearing markedly hyperlucent compared to the right. This hyperlucency is accompanied by signs of hyperinflation on the left side, including subtle widening of the intercostal spaces and a more horizontal orientation of the ribs. The mediastinum remains relatively midline, and the cardiac silhouette appears normal in size and contour for the patient's age. The diaphragmatic domes are visualized, with the left potentially slightly flattened due to air trapping. The bony structures, including the clavicles, proximal humeri, and visualized vertebral bodies, show no obvious acute fractures. This imaging pattern is classically associated with obstructive emphysema or air trapping, which in a pediatric context may suggest a foreign body aspiration or external compression of the left main bronchus by a mediastinal mass.

This diagnostic image is a portable supine chest radiograph of a pediatric patient following endotracheal intubation. The most striking visual finding is a hyperlucent left hemithorax compared to the right, indicative of severe obstructive emphysema or a tension pneumothorax. Associated mass effect is evidenced by a significant mediastinal shift toward the contralateral (right) side and a flattened, depressed ipsilateral (left) hemidiaphragm. An endotracheal tube is visualized with its distal tip positioned above the carina. A small radiopaque density is noted in the region of the left mainstem bronchus, suggesting a foreign body aspiration as the primary cause of the unilateral air trapping (check-valve obstruction). The ribs on the left appear more horizontally oriented and the intercostal spaces are widened, further supporting significant pulmonary hyperinflation. This image serves as a critical educational example of the radiological signs of pediatric airway obstruction and secondary tension-like effects on mediastinal structures.
croup pathophysiology subglottic edema airway diagram child
child tripod position sitting forward drooling epiglottitis
Is it over
Is it over
mkdir -p /tmp/workspace/croup/lib && cd /tmp/workspace/croup/lib && python - <<'E' import json,subprocess,base64 B='https://cdn.orris.care/cdss_images/pmc_clinical_VQA_%s.jpg' ids={'steeple1':'57e97979f2d04d6e4b617bd8771263ec99967c0987e0fa40c242ba213bc4ca9b','steeple2':'4fb55ca2cfb3c279c1a6cfefacaf05e41f5547c4b7692579a779087ade20cef7', 'thumb1':'59f4fa939e89f94d53a67916d488aa01a326681cb52b7a7b2f105a68f116c00a','thumb2':'296093f0daabf943e1daa19d5b1272d11a631f2853793f681ac7542c768e076d', 'laryng1':'623fd8b4b065c691b510c6204aa6bd1ad25e4b4d7bc2cae4dbfe27c0519ec262','laryng2':'6ae99c2c1c67db652b158eae9589c93317d3c273734198a557af1e46a4f75750', 'subglot':'3aeeb3d9d899b861209fb4e900e37a30b64984eb959f9134173e846691965769', 'fb1':'6c59ba6dd87ae7ad6457532eda354b11ab7f1b7ee715abc7170f8b96422abf92','fb2':'1e3c68f059f115c921b441df05f1fb5a6b8f0935ae204ef175f61f47b0ba77d8','fbbronch':'02e4cf3a1ca8b052b26bbde6bc9abbb6a2f921d7f19213a5534e9c471db856e8'} urls=[B%v for v in ids.values()] out=json.loads(subprocess.check_output(['python','/tmp/skills/shared/scripts/fetch_images.py']+urls)) for k,o in zip(ids,out): if o['base64']: mime,b=o['base64'].split(';base64,'); open(k+'.jpg','wb').write(base64.b64decode(b)); print(k,'ok') else: print(k,o['error']) from PIL import Image,ImageDraw import glob fs=sorted(glob.glob('*.jpg')); W=Image.new('RGB',(5*340,2*360),'white') for i,f in enumerate(fs): im=Image.open(f).convert('RGB'); print(f,im.size); im.thumbnail((330,330)); W.paste(im,((i%5)*340,(i//5)*360+20)); ImageDraw.Draw(W).text(((i%5)*340,(i//5)*360+2),f,fill='red') W.save('/tmp/workspace/croup/montage.png') E
cd /tmp/workspace/croup && python -c " from PIL import Image im=Image.open('montage.png').convert('RGB'); im.save('montage.jpg',quality=70) "; ls -la montage.jpg
cd /tmp/workspace/croup && python - <<'E' import re s=open('build.py').read() head=s.split("# 1 title")[0] # swap image prep for library images head=re.sub(r"img=\{.*?\n\n","",head,flags=re.S) if False else head open('head.py','w').write(head) print(head[-900:]) E
cd /tmp/workspace/croup && cat > body2.py <<'E' exec(open('/tmp/workspace/croup/head.py').read()) from pptx.util import Pt LB='/tmp/workspace/croup/lib/' def lib(n,maxw=1600): im=Image.open(LB+n+'.jpg').convert('RGB'); im.thumbnail((maxw,maxw)); im.save(I+'L_'+n+'.jpg',quality=88); return I+'L_'+n+'.jpg' G=RGBColor(0xBB,0xBB,0xBB) def caption(sl,text,x,y,w,size=26): tb=sl.shapes.add_textbox(int(x),int(y),int(w),500000); tf=tb.text_frame; tf.word_wrap=True tf.text=text; tf.paragraphs[0].alignment=PP_ALIGN.CENTER for r in tf.paragraphs[0].runs: r.font.size=Pt(size); r.font.color.rgb=G def pics_slide(title,items,pics,size=38,tsize=54): """pics: list of (name, caption). 1 or 2 images in right-hand area""" sl=prs.slides.add_slide(L['Title & Bullets']) set_title(sl,title,tsize,w=12300000); bullets(sl,items,size,w=12300000,gap=22) bx,by,bw,bh=13300000,2300000,11000000,10300000 n=len(pics); gap=300000; cw=(bw-gap*(n-1))/n; ch=bh-900000 for k,(nm,cap) in enumerate(pics): path=lib(nm); im=Image.open(path); ar=im.width/im.height w=cw; h=w/ar if h>ch: h=ch; w=h*ar x=bx+k*(cw+gap)+(cw-w)/2 sl.shapes.add_picture(path,int(x),int(by+(ch-h)/2),int(w),int(h)) caption(sl,cap,bx+k*(cw+gap),by+ch+80000,cw) caption(sl,'Images: open-access clinical figures from the Orris image library (PMC)',bx,12900000,bw,22) return sl # 1 sl=prs.slides.add_slide(L['Title']) t=sl.shapes.title; t.text_frame.text='CROUP, EPIGLOTTITIS AND AIRWAY FOREIGN BODY' for r in t.text_frame.paragraphs[0].runs: r.font.size=Pt(72) sl.placeholders[1].text_frame.text='Causes of acute stridor in children' text_slide('The child with stridor',[ 'Stridor: a harsh sound from a narrowed upper airway', 'Croup (ALTB): viral, infants and toddlers', 'Epiglottitis: Hib infection, preschool children', 'Bacterial tracheitis: Staph. aureus, toxic appearance', 'Foreign body: abrupt choking, toddlers', 'Laryngoscopy / bronchoscopy confirms and may treat']) text_slide('Croup (acute laryngotracheobronchitis)',[ 'Viral infection of larynx, trachea and bronchi', 'Hallmark: brassy, seal-like barking cough', 'Affects children from 6 months to 3 years', 'Usually begins a few days after a common cold', 'Peaks in autumn and winter; boys slightly more', 'Epiglottitis is a separate, more dangerous disease']) text_slide('Causes of croup',[ 'Almost always a virus', 'Parainfluenza 1: the leading cause (types 2 and 3 also)', 'Respiratory syncytial virus', 'Influenza, adenovirus, rhinovirus', 'Secondary bacterial infection is uncommon']) text_slide('Croup: how it presents',[ 'Runny nose and low fever for 1 to 3 days', 'Barking cough and hoarse voice follow', 'Inspiratory stridor, first on crying, later at rest', 'Stridor turns biphasic when obstruction is greater', 'Child is alert, not toxic, and swallows normally', 'Symptoms are worse at night', 'Chest retractions and restlessness signal severity'],size=44) pics_slide('Why the airway narrows',[ 'Virus inflames subglottic mucosa', 'Cricoid ring cannot stretch outward', 'Swelling of 1 mm halves the lumen in an infant', 'Turbulent airflow produces stridor', 'Cord oedema produces a hoarse voice', 'Crying makes obstruction worse'],[('subglot','Endoscopy: subglottic oedema and erythema')],size=38) pics_slide('Croup on X-ray',[ 'Clinical diagnosis in most children', 'AP neck film: STEEPLE sign', 'Tapered narrowing of the subglottic air column', 'Film is optional, only if diagnosis unclear', 'A normal film does not rule out croup'],[('steeple1','AP neck: steeple sign (arrow)'),('steeple2','AP neck: subglottic narrowing (arrow)')],size=38,tsize=54) text_slide('Grading croup',[ 'MILD: playful, drinking; stridor only with cough; SpO2 over 92%', 'MODERATE: fretful but settles with parent; stridor at rest when upset; faster breathing, retractions', 'SEVERE: agitated or drowsy; stridor at rest; deep retractions; SpO2 under 92%, possible cyanosis', 'Quiet chest with exhaustion warns of respiratory failure'],size=42) text_slide('Croup: treatment, part 1',[ 'Mild croup settles within 1 to 2 days at home', 'Calm the child, keep with parent, give fluids', 'Cool mist is traditional; benefit is unproven', 'Moderate or severe: nebulised epinephrine 1:1000', 'Dose 0.1 to 0.5 mL/kg, maximum 5 mL', 'Effect lasts a short time, so observe afterwards', 'Oxygen for hypoxia'],size=44) text_slide('Croup: treatment, part 2',[ 'DEXAMETHASONE 0.3 to 0.6 mg/kg as a single dose', 'Works best when given in the first 24 hours', 'Oral route is as effective as injection', 'BUDESONIDE 1 mg inhaled, twice daily for 2 days', 'Antibiotics only if no improvement or pus is present', 'Target organisms: Staphylococcus, H. influenzae', 'Avoid sedatives'],size=44) text_slide('Acute epiglottitis (supraglottitis)',[ 'Bacterial infection of epiglottis and supraglottis', 'Classic organism: Haemophilus influenzae type B', 'Usually 3 to 6 years of age', 'Rarer now because of Hib vaccination', 'More severe than croup', 'Can close the airway within hours']) pics_slide('Epiglottitis: bedside picture',[ 'High fever and a toxic look', 'Severe sore throat, painful swallowing', 'DROOLING and muffled voice', 'Soft inspiratory stridor', 'Cough usually absent', 'TRIPOD posture: leaning forward, chin out', 'Abrupt onset over a few hours'],[('laryng2','Fibreoptic view: swollen, rounded epiglottis')],size=38) pics_slide('Epiglottitis on X-ray',[ 'Lateral neck film: THUMBPRINT sign', 'Epiglottis is thick and rounded', 'Aryepiglottic folds thickened', 'Do not move an unstable child for imaging', 'Normal film does not exclude disease', 'Bloods only after airway is safe'],[('thumb1','Lateral neck: thumb sign'),('thumb2','Lateral neck: enlarged epiglottis')],size=38,tsize=50) pics_slide('Epiglottitis: treatment',[ 'Never inspect the throat or use a spatula', 'Risk: sudden laryngospasm and arrest', 'Child stays on parent\'s lap, unfrightened', 'Summon anaesthetist and ENT surgeon', 'Secure the airway in theatre', 'Intubation, or rigid bronchoscopy then tracheostomy', 'IV ceftriaxone or cefotaxime for 7 days'],[('laryng1','Supraglottic oedema, before and after intubation')],size=36,tsize=50) sl=prs.slides.add_slide(L['Title - Centre']) sl.shapes.title.text_frame.text='A child with stridor: no throat examination' sl=prs.slides.add_slide(L['Title & Bullets']); set_title(sl,'Croup compared with epiglottitis',66) sl.placeholders[1]._element.getparent().remove(sl.placeholders[1]._element) rows=[('','CROUP','EPIGLOTTITIS'), ('Organism','Virus (parainfluenza)','Bacteria (Hib)'), ('Age','6 months to 3 years','3 to 6 years'), ('Onset','Days, after a cold','Hours, abrupt'), ('General state','Mild fever, alert','High fever, toxic'), ('Cough and voice','Barking cough, hoarse','No cough, muffled'), ('Swallowing','Preserved','Painful, drooling'), ('Film sign','Steeple (AP)','Thumbprint (lateral)'), ('Therapy','Steroid, epinephrine','Airway first, IV antibiotic')] gs=sl.shapes.add_table(len(rows),3,762000,2500000,22860000,10200000); tb=gs.table tb.columns[0].width=Emu(4800000); tb.columns[1].width=Emu(8800000); tb.columns[2].width=Emu(9260000) for ri,row in enumerate(rows): tb.rows[ri].height=Emu(1130000) for ci,txt in enumerate(row): c=tb.cell(ri,ci); c.fill.solid() c.fill.fore_color.rgb=RGBColor(0x1F,0x6F,0x9F) if ri==0 else (RGBColor(0x38,0x38,0x38) if ri%2 else RGBColor(0x2E,0x2E,0x2E)) c.vertical_anchor=MSO_ANCHOR.MIDDLE; tf=c.text_frame; tf.text=txt for r in tf.paragraphs[0].runs: r.font.size=Pt(34); r.font.color.rgb=WHITE; r.font.bold=(ri==0 or ci==0) text_slide('Bacterial tracheitis',[ 'Mostly Staphylococcus aureus', 'Follows a viral upper respiratory infection', 'Toxic child with a brassy cough', 'Biphasic or expiratory stridor', 'Does not respond to croup treatment', 'Needs bronchoscopic clearance and IV antibiotics']) text_slide('Airway foreign body',[ 'Suspect when stridor or wheeze starts suddenly', 'Typical age: 1 to 4 years; they put things in the mouth', 'Level of lodgement depends on size and shape', 'Bulky object stops above the glottis', 'Smaller object travels to trachea or bronchi', 'Pointed objects may embed at any level'],size=44) text_slide('Type of foreign body',[ 'INERT: plastic, metal; may cause few symptoms', 'REACTIVE: nuts, seeds, organic matter', 'Reactive objects swell and inflame the mucosa', 'Right main bronchus is the commonest site', 'Larynx: stridor; bronchus: cough and wheeze']) text_slide('Foreign body: course',[ 'Stage 1: choking, gagging, wheeze for a short time', 'Object may be coughed out or may lodge', 'Stage 2: silent interval of hours to weeks', 'Mucosa adapts, so symptoms fade', 'Stage 3: obstruction, cough, wheeze, repeated chest infection'],size=44) text_slide('Foreign body: chest findings',[ 'Hyperresonance, reduced vocal resonance, poor air entry', 'Percussion changes are hard to find in small children', 'One area of poor air entry plus lingering chest illness: think foreign body', 'Partial block acts as a ONE-WAY VALVE: air trapping, hyperinflation', 'Complete block: collapse beyond the object', 'Neglected cases: pus and bronchiectasis'],size=44) pics_slide('Foreign body: X-ray',[ 'Many objects are not radio-opaque', 'Look for one hyperlucent lung', 'Mediastinal shift away from the affected side', 'Expiratory film shows air trapping', 'Normal film does not exclude it'],[('fb1','Chest film: hyperlucent left lung'),('fb2','Chest film: unilateral hyperinflation')],size=38,tsize=54) pics_slide('Foreign body: removal',[ 'RIGID BRONCHOSCOPY is the method of choice', 'Proceed even without a clear history if signs fit', 'Antibiotics for secondary infection', 'Complete choking: back blows, chest thrusts in infants', 'Abdominal thrusts in older children'],[('fbbronch','Bronchoscopic view of an airway foreign body')],size=40,tsize=54) text_slide('Take-home points',[ 'Croup: viral, barking cough, steeple sign, steroid and epinephrine', 'Epiglottitis: Hib, toxic, drooling, thumbprint sign, airway first', 'Foreign body: abrupt choking, rigid bronchoscopy', 'Never examine the throat of a stridulous child'],size=46) sl=prs.slides.add_slide(L['Title - Centre']); sl.shapes.title.text_frame.text='Thank you' prs.save('/tmp/workspace/croup/out/Croup_Epiglottitis_Foreign_Body_v2.pptx'); print(len(prs.slides)) E python body2.py && python - <<'E' from pptx import Presentation import math p=Presentation('/tmp/workspace/croup/out/Croup_Epiglottitis_Foreign_Body_v2.pptx') for i,s in enumerate(p.slides,1): for sh in s.placeholders: if sh.placeholder_format.idx==1 and i>1 and sh.has_text_frame: w=sh.width/914400-0.8; tot=0;hh=0 for para in sh.text_frame.paragraphs: sz=para.runs[0].font.size.pt; n=math.ceil(len(para.text)/(w*72/(sz*0.52))); tot+=n; hh+=n*sz*1.2+para.space_before.pt print(i,tot,round(hh/72,1),round(sh.height/914400,1)) E
Croup Epiglottitis Foreign Body v2
Presentation · PPTX