Make content which can help in viva for this topics
Check all content and correct if needed Improve this content
~/
~/attachments/cf57c144-570a-4c38-afd4-4a5d16068d2f
mkdir -p "/tmp/workspace/surgical-specimens-review/src" "/tmp/workspace/surgical-specimens-review/output" && python -c "from pptx import Presentation; p=Presentation('/tmp/workspace/attachments/cf57c144-570a-4c38-afd4-4a5d16068d2f/Surgical Specimens MS Exam-1.pptx'); out='/tmp/workspace/surgical-specimens-review/src/extracted.txt'; f=open(out,'w'); print('SLIDES',len(p.slides)); f.write('SLIDES: %d\n'%len(p.slides));\nfor i,s in enumerate(p.slides,1):\n f.write('\\n'+'='*25+' SLIDE %d '%i+'='*25+'\\n');\n f.write('LAYOUT: '+s.slide_layout.name+'\\n');\n for sh in s.shapes:\n if hasattr(sh,'text') and sh.text.strip(): f.write(sh.name+': '+sh.text.replace('\\v',' | ').replace('\\n',' / ')+'\\n');\nf.close()"
surgical oncology AND guideline
NCCN clinical practice guidelines colon gastric breast thyroid renal testicular cancer 2025
~/surgical-specimens-review/src/extract_ppt.py
from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE_TYPE
src = '/tmp/workspace/attachments/cf57c144-570a-4c38-afd4-4a5d16068d2f/Surgical Specimens MS Exam-1.pptx'
out = '/tmp/workspace/surgical-specimens-review/src/extracted.txt'
prs = Presentation(src)
with open(out, 'w', encoding='utf-8') as f:
f.write(f'SLIDES: {len(prs.slides)}\n')
for i, slide in enumerate(prs.slides, 1):
f.write('\n' + '='*25 + f' SLIDE {i} ' + '='*25 + '\n')
f.write(f'LAYOUT: {slide.slide_layout.name}\n')
for shape in slide.shapes:
f.write(f'[{shape.shape_type}] {shape.name} pos=({shape.left},{shape.top},{shape.width},{shape.height})\n')
if shape.has_text_frame and shape.text.strip():
f.write('TEXT: ' + shape.text.replace('\v', ' | ').replace('\n', ' / ') + '\n')
if shape.shape_type == MSO_SHAPE_TYPE.PICTURE:
f.write('PICTURE\n')
print('Slides:', len(prs.slides))
python "/tmp/workspace/surgical-specimens-review/src/extract_ppt.py"
~/surgical-specimens-review/src/list_text.py
from pptx import Presentation
src='/tmp/workspace/attachments/cf57c144-570a-4c38-afd4-4a5d16068d2f/Surgical Specimens MS Exam-1.pptx'
p=Presentation(src)
with open('/tmp/workspace/surgical-specimens-review/src/slide_text.txt','w',encoding='utf8') as f:
for n,s in enumerate(p.slides,1):
f.write(f'\n### SLIDE {n}\n')
for sh in s.shapes:
if hasattr(sh,'text') and sh.text.strip(): f.write(sh.text.strip()+'\n')
python "/tmp/workspace/surgical-specimens-review/src/list_text.py"
Give me updated PDF
~/
surgical oncology management guideline
NCCN guidelines cancer type treatment 2026 colorectal gastric breast thyroid kidney testicular
~/surgical-specimens-review
~/
mkdir -p "/tmp/workspace/surgical-specimens-review/src" "/tmp/workspace/surgical-specimens-review/output"
~/surgical-specimens-review/src/create_updated_handbook.py
from reportlab.lib import colors
from reportlab.lib.enums import TA_CENTER
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak, KeepTogether
from reportlab.pdfbase.pdfmetrics import stringWidth
out='/tmp/workspace/surgical-specimens-review/output/Updated_Surgical_Specimens_MS_Viva_Handbook.pdf'
styles=getSampleStyleSheet()
styles.add(ParagraphStyle(name='CoverTitle', parent=styles['Title'], fontName='Helvetica-Bold', fontSize=24, leading=30, textColor=colors.HexColor('#123B5D'), alignment=TA_CENTER, spaceAfter=12))
styles.add(ParagraphStyle(name='CoverSub', parent=styles['Normal'], fontName='Helvetica', fontSize=12, leading=17, alignment=TA_CENTER, textColor=colors.HexColor('#385A72')))
styles.add(ParagraphStyle(name='H1b', parent=styles['Heading1'], fontName='Helvetica-Bold', fontSize=16, leading=20, textColor=colors.HexColor('#123B5D'), spaceBefore=5, spaceAfter=8))
styles.add(ParagraphStyle(name='H2b', parent=styles['Heading2'], fontName='Helvetica-Bold', fontSize=12.5, leading=15, textColor=colors.HexColor('#8C3D20'), spaceBefore=9, spaceAfter=4))
styles.add(ParagraphStyle(name='Bodyx', parent=styles['BodyText'], fontName='Helvetica', fontSize=9.1, leading=12.2, spaceAfter=4))
styles.add(ParagraphStyle(name='Pearl', parent=styles['BodyText'], fontName='Helvetica-Bold', fontSize=9.2, leading=12.2, backColor=colors.HexColor('#EAF3F8'), borderColor=colors.HexColor('#76A6C6'), borderWidth=.5, borderPadding=6, spaceBefore=4, spaceAfter=7))
styles.add(ParagraphStyle(name='Small', parent=styles['BodyText'], fontName='Helvetica', fontSize=8, leading=10, textColor=colors.HexColor('#4B5964')))
specimens=[
('1. Carcinoma colon','Identification: Resected colon with an irregular ulceroproliferative or annular constricting lesion, most consistent with colorectal adenocarcinoma.','Gross: Left-sided tumors are often annular and obstructing; right-sided lesions are more often exophytic/fungating. Ulceration, necrosis, proximal dilatation, and regional nodes may be seen.','Viva: Current staging is TNM; Dukes staging is historical. CEA is for baseline/prognosis and surveillance, not population screening. Curative surgery is oncological segmental colectomy with vascular and mesocolic resection and adequate nodal assessment (target at least 12 nodes).','Pearl: State that resectability and adjuvant therapy depend on TNM stage, margins, nodal status, molecular profile, and patient fitness.'),
('2. Trichobezoar','Identification: A dark, matted hair mass molded to the stomach, consistent with trichobezoar.','Gross: Black-brown, foul-smelling, firm gastric cast. A tail extending beyond the pylorus into small bowel is Rapunzel syndrome. Pressure ulceration may occur.','Viva: Associated with trichotillomania and trichophagia. CT defines extent. Small lesions may sometimes be treated endoscopically; large trichobezoars and Rapunzel syndrome usually require operative removal. Psychiatric assessment prevents recurrence.','Pearl: Do not say all cases need gastrotomy. Say large or extensive lesions usually need surgical removal.'),
('3. Tuberculous lymph node','Identification: Multiple matted cervical nodes with yellow-white caseation, suggestive of tuberculous lymphadenitis.','Gross: Firm or rubbery nodes, matting, caseous necrosis, possible calcification, cold abscess or sinus.','Viva: FNAC/cytology may show granulomas, Langhans-type giant cells and caseation; obtain material for mycobacterial testing when feasible. Follow current national TB guidance and drug-susceptibility results for treatment. Excision biopsy is useful if diagnosis remains uncertain.','Pearl: Collar-stud abscess is characteristic, not pathognomonic.'),
('4. Hodgkin lymphoma','Identification: Enlarged lymph node with a homogeneous grey-white “fish-flesh” cut surface, suggestive of lymphoma.','Gross: Usually painless cervical, mediastinal or axillary nodal enlargement. Caseation is not typical and favors TB, although necrosis can occur.','Viva: Diagnosis and classification require architecture, so excision biopsy is preferred. Classical Hodgkin lymphoma has Reed-Sternberg cells in an appropriate inflammatory background, typically CD30 positive and often CD15 positive. Staging is by Lugano/Ann Arbor-based system and PET-CT.','Pearl: Spread is often contiguous. ABVD-based treatment is stage and risk adapted.'),
('5. Gallbladder stones','Identification: Opened gallbladder containing calculi, consistent with cholelithiasis.','Gross: Cholesterol stones are often pale and solitary; pigment stones are dark and often multiple; mixed stones are common and may be faceted. Chronic cholecystitis may thicken the wall.','Viva: Ultrasound is first-line. Symptomatic stones are treated by laparoscopic cholecystectomy. Mirizzi syndrome is extrinsic common hepatic duct compression by an impacted cystic duct/Hartmann pouch stone. Gallstone ileus commonly impacts near the ileocaecal valve.','Pearl: The 5 Fs are a traditional mnemonic, not diagnostic criteria. Porcelain gallbladder cancer risk is lower than older estimates suggested and management is individualized.'),
('6. Acute appendicitis','Identification: Appendix that is congested, swollen and coated with fibrinopurulent exudate, consistent with acute appendicitis.','Gross: Thickened wall, luminal pus, serosal fibrin; gangrene appears green-black and perforation may be sealed by omentum.','Viva: Retrocaecal is the commonest anatomical position. McBurney point is at the junction of the lateral one-third and medial two-thirds of the umbilicus-right ASIS line. Use clinical assessment plus inflammatory markers and imaging when needed.','Pearl: Appendicular mass or abscess can be managed non-operatively in selected stable patients; interval appendicectomy is selective, not mandatory for every patient.'),
('7. Hepatic metastases','Identification: Liver with multiple pale, firm nodules, often umbilicated from central necrosis, consistent with metastatic deposits.','Gross: Multiple “cannonball” lesions, irregular surface, pale cut surface and normal parenchyma between deposits. Colorectal metastases commonly reach liver via portal circulation.','Viva: The liver is a common site of hematogenous spread, especially from GI primaries. CT/MRI defines burden and anatomy. Resectability requires the ability to clear all disease while preserving adequate future liver remnant; it is not determined simply by number of segments.','Pearl: Carcinoid syndrome classically becomes evident after hepatic metastases bypass first-pass hepatic metabolism.'),
('8. Intestinal worms','Identification: Bowel containing long cylindrical cream-colored worms, consistent with Ascaris lumbricoides infestation.','Gross: Worm bolus may cause small-bowel obstruction; worms can migrate into biliary tree or appendix.','Viva: Treat uncomplicated intestinal ascariasis medically. In obstruction, resuscitate and observe carefully; surgery is for failed conservative management, ischemia, perforation, gangrene or peritonitis. At operation, gentle milking into colon may be attempted when bowel is viable.','Pearl: Avoid colloquial phrases such as “milk worms out” as the main management answer; always state the indication for surgery.'),
('9. Meckel diverticulum','Identification: A true blind diverticulum on the antimesenteric ileal border, consistent with Meckel diverticulum.','Gross: Usually within about 60 cm of the ileocaecal valve, may contain ectopic gastric or pancreatic mucosa and may have a mesodiverticular band.','Viva: Technetium-99m pertechnetate detects ectopic gastric mucosa. Important complications are bleeding, obstruction, diverticulitis and intussusception. Littre hernia is a Meckel diverticulum in a hernial sac.','Pearl: The rule of 2s is a teaching mnemonic. Incidental diverticula are resected selectively, not automatically.'),
('10. Intestinal tuberculosis','Identification: Ileocecal bowel with mural thickening, strictures, transverse ulcers and caseating mesenteric nodes, consistent with intestinal TB.','Gross: Ileocecal involvement is common. Hyperplastic disease produces a mass/stricture; ulcerative disease has transverse or circumferential ulcers, with serosal tubercles and nodal caseation.','Viva: Differentiate from Crohn disease and malignancy. Tissue diagnosis and microbiological testing are important. Antitubercular therapy is the main treatment; surgery is reserved for obstruction, perforation, fistula, hemorrhage, or unresolved diagnostic uncertainty.','Pearl: Transverse ulcers favor TB, whereas longitudinal ulcers and cobblestoning favor Crohn disease.'),
('11. Hydatid cyst','Identification: Cyst with daughter cysts and hydatid sand, consistent with echinococcal hydatid disease.','Gross: Host pericyst, laminated ectocyst and germinal endocyst; daughter cysts and scolices may be present. Liver is the commonest site.','Viva: Ultrasound/CT classify cyst morphology; serology supports diagnosis. Avoid unplanned aspiration because spillage can cause anaphylaxis and dissemination. PAIR is selected for suitable cysts in experienced units with imaging guidance and antiparasitic therapy.','Pearl: Do not give a fixed albendazole duration for all cases. State that regimen and duration follow cyst type and institutional protocol.'),
('12. Carcinoma stomach','Identification: Opened stomach with an indurated ulcer or infiltrative mass, consistent with gastric adenocarcinoma.','Gross: Malignant ulcer has heaped/everted indurated edges and irregular base. Diffuse carcinoma may cause linitis plastica. Borrmann classification describes advanced tumors.','Viva: Endoscopic biopsy establishes diagnosis; staging CT and, in selected patients, staging laparoscopy guide treatment. Curative treatment is gastrectomy with appropriate lymphadenectomy in fit resectable patients, often with perioperative systemic therapy.','Pearl: HER2-directed therapy applies to selected HER2-positive advanced/metastatic disease, not every gastric cancer.'),
('13. Amoebic liver abscess','Identification: Solitary right-lobe liver abscess with odorless chocolate-brown “anchovy sauce” material, consistent with amoebic liver abscess.','Gross: Usually a solitary cavity in right lobe; ragged wall, liquefied necrotic liver and no well-formed pyogenic capsule.','Viva: Diagnose by imaging plus clinical and serological correlation. Treat with a tissue-active amoebicide, followed by a luminal agent to eradicate intestinal colonization. Drainage is selective, for diagnostic doubt, failure to improve, high rupture risk, or selected large/left-lobe lesions.','Pearl: Anchovy-sauce material results from liquefied necrotic hepatocytes and blood; it is usually odorless.'),
('14. Polycystic kidney','Identification: Massively enlarged kidney replaced by numerous cysts of variable size, consistent with autosomal dominant polycystic kidney disease.','Gross: Bilateral large kidneys, cysts with clear, turbid or hemorrhagic contents, and compressed residual parenchyma.','Viva: Most cases involve PKD1 or PKD2. Important associations include liver cysts, intracranial aneurysm, valvular disease and colonic diverticulosis. Management addresses BP, renal protection, infection/stones and renal replacement planning.','Pearl: Use the name ADPKD. It is inherited, not simply described as “congenital.”'),
('15. Seminoma','Identification: Enlarged testis with a homogeneous, pale grey-white lobulated cut surface, suggestive of seminoma.','Gross: Homogeneous fleshy tumor with fibrous septa; hemorrhage and necrosis are less prominent than in many nonseminomatous tumors.','Viva: Pure seminoma has normal AFP. Beta-hCG may be mildly elevated. Staging uses serum markers and CT. Initial management is radical inguinal orchidectomy, followed by stage-adapted surveillance, chemotherapy or radiotherapy.','Pearl: Raised AFP excludes pure seminoma and indicates a nonseminomatous component until proved otherwise. Never perform transscrotal biopsy.'),
('16. Teratoma','Identification: Heterogeneous testicular germ-cell tumor with cystic and solid elements, cartilage/bone or mucinous material, consistent with teratoma.','Gross: Variable mature tissues from more than one germ layer, often with hemorrhage or necrosis in mixed nonseminomatous tumors.','Viva: Pure teratoma does not necessarily elevate AFP. Raised AFP indicates an associated nonseminomatous component, particularly yolk-sac tumor. Initial management of a suspected testicular germ-cell tumor is radical inguinal orchidectomy. Adult teratoma is relatively resistant to chemotherapy and radiotherapy; residual masses may need resection.','Pearl: Do not say “teratoma equals AFP positive” or “all teratoma needs BEP.”'),
('17. Carcinoma breast','Identification: Mastectomy or wide local excision with a hard grey-white irregular stellate mass, consistent with invasive carcinoma of no special type.','Gross: Spiculated lesion due to desmoplasia, skin tethering/peau d’orange, and nipple retraction when subareolar.','Viva: ER, PR and HER2 status guide systemic treatment. Sentinel node biopsy is standard for clinically node-negative early breast cancer. Breast-conserving surgery plus radiotherapy and mastectomy have selected indications.','Pearl: Peau d’orange reflects dermal lymphatic obstruction, not necessarily direct skin invasion. Triple-negative cancers are biologically aggressive, but stage remains central to prognosis.'),
('18. Thyroid swelling','Identification: Thyroid specimen showing diffuse or multinodular enlargement, or a suspicious firm nodule. Diagnosis requires histology and clinical correlation.','Gross: Multinodular goitre has irregular nodules and cystic/hemorrhagic change. Papillary carcinoma is often firm and pale; follicular carcinoma may be encapsulated; medullary carcinoma can contain amyloid.','Viva: FNAC diagnoses many lesions but cannot distinguish follicular adenoma from carcinoma because capsular/vascular invasion is histological. Papillary carcinoma often spreads to nodes; follicular carcinoma tends to spread hematogenously.','Pearl: Total thyroidectomy and radioactive iodine are risk-adapted, not mandatory for all differentiated thyroid cancers; lobectomy is appropriate in selected low-risk tumors.'),
('19. Renal cell carcinoma','Identification: Renal mass with a golden-yellow variegated cut surface, hemorrhage and necrosis, suggestive of clear-cell renal cell carcinoma.','Gross: Often cortical, well-circumscribed with a pseudocapsule; extension into renal vein and IVC may occur.','Viva: The classic triad of hematuria, flank pain and mass is late and uncommon. VHL alteration is characteristic of clear-cell RCC. CT stages the primary, nodes, veins and metastases. Partial nephrectomy is preferred for many suitable T1 tumors; radical nephrectomy is used when necessary.','Pearl: IVC thrombus does not automatically preclude surgery but needs specialist multidisciplinary planning. Metastatic therapy commonly includes immune checkpoint inhibitor-based combinations.'),
('20. Wilms tumor','Identification: Large, well-circumscribed renal mass in a child, consistent with Wilms tumor (nephroblastoma).','Gross: Large soft tan-grey tumor with hemorrhage, necrosis and distortion of renal parenchyma; may extend into renal vein/IVC.','Viva: Typical histology is triphasic: blastemal, epithelial and stromal elements. Assess both kidneys and stage with cross-sectional imaging. Treatment combines nephrectomy and chemotherapy, with radiotherapy in selected higher-risk disease; protocols vary by cooperative group.','Pearl: Differentiate from neuroblastoma: Wilms usually arises from kidney and tends to displace rather than encase vessels.'),
]
def footer(c, doc):
c.saveState(); c.setStrokeColor(colors.HexColor('#79A7C4')); c.line(1.5*cm,1.25*cm,19.5*cm,1.25*cm)
c.setFont('Helvetica',8); c.setFillColor(colors.HexColor('#4B5964'))
c.drawString(1.5*cm,.82*cm,'Updated MS Surgery Specimen Viva Handbook | Educational use')
c.drawRightString(19.5*cm,.82*cm,f'Page {doc.page}')
c.restoreState()
doc=SimpleDocTemplate(out,pagesize=A4,rightMargin=1.45*cm,leftMargin=1.45*cm,topMargin=1.35*cm,bottomMargin=1.65*cm,title='Updated Surgical Specimens MS Viva Handbook',author='Orris')
story=[]
story += [Spacer(1,3.2*cm),Paragraph('UPDATED SURGICAL SPECIMENS',styles['CoverTitle']),Paragraph('MS Surgery Practical - Specimen Viva Handbook',styles['CoverTitle']),Spacer(1,.4*cm),Paragraph('Corrected and exam-focused notes for the 20 listed specimens',styles['CoverSub']),Spacer(1,.9*cm),Paragraph('How to answer: identify the organ and lesion, state two supporting gross features, offer a differential if relevant, then discuss investigation, complication/spread, and current treatment principle.',styles['CoverSub']),Spacer(1,1.1*cm),Paragraph('<b>Important:</b> This is a viva revision guide, not a patient-specific treatment protocol. Exact treatment is stage-, pathology-, patient-, and guideline-dependent.',styles['Pearl']),PageBreak()]
story += [Paragraph('Universal specimen-viva sequence',styles['H1b']),Paragraph('<b>1. Identify</b> the organ and specimen type. <b>2. Describe</b> site, number, size, surface, cut surface, capsule, nodes and margins. <b>3. Diagnose</b> using 1-2 discriminating findings. <b>4. Discuss</b> differential diagnosis, confirmation, staging/complications and treatment principle. Avoid absolute management statements unless they are truly universal.',styles['Bodyx']),Paragraph('Use cautious language: “suggestive of”, “requires histological confirmation”, “management is stage- and risk-adapted”, and “follow current national/institutional guidance”.',styles['Pearl'])]
for title, ident, gross, viva, pearl in specimens:
block=[Paragraph(title,styles['H1b']),Paragraph('<b>'+ident.split(':')[0]+':</b>'+ident.split(':',1)[1],styles['Bodyx']),Paragraph('<b>Gross features:</b> '+gross.replace('Gross: ',''),styles['Bodyx']),Paragraph('<b>Discussion:</b> '+viva.replace('Viva: ',''),styles['Bodyx']),Paragraph('<b>Viva pearl:</b> '+pearl.replace('Pearl: ',''),styles['Pearl'])]
story.append(KeepTogether(block))
story.append(Spacer(1,3))
story += [PageBreak(),Paragraph('Corrections applied to the original slides',styles['H1b']),Paragraph('Key updates include: TNM over historical Dukes staging; no fixed bowel-margin or liver-segment rule for cancer surgery; careful, selected use of interval appendicectomy and PAIR; no blanket total thyroidectomy/RAI; pure teratoma is not inherently AFP-positive; and partial nephrectomy is appropriate for many small renal masses. Several traditional statements have been retained only as viva mnemonics, with their limitations stated.',styles['Bodyx']),Paragraph('Suggested references: Bailey & Love’s Short Practice of Surgery, 28th ed.; Sabiston Textbook of Surgery; Robbins & Cotran Pathologic Basis of Disease; current national TB and oncology guidance. Contemporary cancer guidance is continually updated, as reflected by the current NCCN guideline catalogue.',styles['Small'])]
doc.build(story,onFirstPage=footer,onLaterPages=footer)
print(out)
python "/tmp/workspace/surgical-specimens-review/src/create_updated_handbook.py" && python -c "from pypdf import PdfReader; p='/tmp/workspace/surgical-specimens-review/output/Updated_Surgical_Specimens_MS_Viva_Handbook.pdf'; r=PdfReader(p); print('pages=',len(r.pages)); print('chars=',sum(len(x.extract_text() or '') for x in r.pages)); print((r.pages[0].extract_text() or '')[:250])"
Updated Surgical Specimens MS Viva Handbook
PDF Document · PDF
Also add figures from I have uploaded file
~/
surgical specimen gross pathology images educational colorectal carcinoma trichobezoar hydatid renal cell carcinoma
python -c "import zipfile, os, shutil; src='/tmp/workspace/attachments/cf57c144-570a-4c38-afd4-4a5d16068d2f/Surgical Specimens MS Exam-1.pptx'; dst='/tmp/workspace/surgical-specimens-review/assets/uploaded_figures'; os.makedirs(dst,exist_ok=True); z=zipfile.ZipFile(src); names=[n for n in z.namelist() if n.startswith('ppt/media/')]; print('media files',len(names)); [open(os.path.join(dst,os.path.basename(n)),'wb').write(z.read(n)) for n in names]; print('\n'.join(os.listdir(dst)))"
python -c "from pptx import Presentation; import os, hashlib; src='/tmp/workspace/attachments/cf57c144-570a-4c38-afd4-4a5d16068d2f/Surgical Specimens MS Exam-1.pptx'; out='/tmp/workspace/surgical-specimens-review/assets/uploaded_figures'; os.makedirs(out,exist_ok=True); p=Presentation(src); counts=[]; seen=set();\nfor si,sl in enumerate(p.slides,1):\n c=0\n for sh in sl.shapes:\n if sh.shape_type==13:\n blob=sh.image.blob; ext=sh.image.ext; h=hashlib.md5(blob).hexdigest()[:8]; fn=f'slide_{si:02d}_{c+1}_{h}.{ext}'; open(os.path.join(out,fn),'wb').write(blob); c+=1\n counts.append((si,c))\nprint('images per slide:',counts); print('files:',sorted(os.listdir(out)))"
~/surgical-specimens-review/src/extract_images.py
from pptx import Presentation
import os, hashlib
src='/tmp/workspace/attachments/cf57c144-570a-4c38-afd4-4a5d16068d2f/Surgical Specimens MS Exam-1.pptx'
out='/tmp/workspace/surgical-specimens-review/assets/uploaded_figures'
os.makedirs(out, exist_ok=True)
prs=Presentation(src)
counts=[]
for si, slide in enumerate(prs.slides, 1):
c=0
for shape in slide.shapes:
if shape.shape_type == 13: # picture
blob=shape.image.blob
ext=shape.image.ext
h=hashlib.md5(blob).hexdigest()[:8]
fn=f'slide_{si:02d}_{c+1}_{h}.{ext}'
with open(os.path.join(out,fn),'wb') as f:
f.write(blob)
c += 1
counts.append((si,c))
print('images per slide:', counts)
print('files:', sorted(os.listdir(out)))
python "/tmp/workspace/surgical-specimens-review/src/extract_images.py" && python -c "from PIL import Image,ImageDraw; import os,glob,math; d='/tmp/workspace/surgical-specimens-review/assets/uploaded_figures'; fs=sorted([p for p in glob.glob(d+'/*') if os.path.isfile(p)]); thumbs=[]; W,H=240,190; sheet=Image.new('RGB',(W*4,H*math.ceil(len(fs)/4)),'white'); draw=ImageDraw.Draw(sheet);\nfor i,p in enumerate(fs):\n im=Image.open(p).convert('RGB'); im.thumbnail((220,145)); x=(i%4)*W+(W-im.width)//2; y=(i//4)*H+3; sheet.paste(im,(x,y)); draw.text(((i%4)*W+4,(i//4)*H+152),os.path.basename(p)[:29],fill='black');\nsheet.save('/tmp/workspace/surgical-specimens-review/assets/figure_contact_sheet.jpg'); print(len(fs))"
~/surgical-specimens-review/src/contact_sheet.py
from PIL import Image, ImageDraw
import os, glob, math
d='/tmp/workspace/surgical-specimens-review/assets/uploaded_figures'
fs=sorted([p for p in glob.glob(d+'/*') if os.path.isfile(p)])
W,H=240,190
sheet=Image.new('RGB',(W*4,H*math.ceil(len(fs)/4)),'white')
draw=ImageDraw.Draw(sheet)
for i,p in enumerate(fs):
im=Image.open(p).convert('RGB')
im.thumbnail((220,145))
x=(i%4)*W+(W-im.width)//2
y=(i//4)*H+3
sheet.paste(im,(x,y))
draw.text(((i%4)*W+4,(i//4)*H+152),os.path.basename(p)[:29],fill='black')
sheet.save('/tmp/workspace/surgical-specimens-review/assets/figure_contact_sheet.jpg')
print(len(fs))
python "/tmp/workspace/surgical-specimens-review/src/contact_sheet.py"
~/surgical-specimens-review/src
~/surgical-specimens-review/src/create_updated_handbook.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/surgical-specimens-review/src/create_updated_handbook.py'
~/surgical-specimens-review/src/create_updated_handbook.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/surgical-specimens-review/src/create_updated_handbook.py'
python "/tmp/workspace/surgical-specimens-review/src/create_updated_handbook.py" && python -c "from pypdf import PdfReader; p='/tmp/workspace/surgical-specimens-review/output/Updated_Surgical_Specimens_MS_Viva_Handbook_Illustrated.pdf' if False else '/tmp/workspace/surgical-specimens-review/output/Updated_Surgical_Specimens_MS_Viva_Handbook.pdf'; r=PdfReader(p); print('pages=',len(r.pages)); print('chars=',sum(len(pg.extract_text() or '') for pg in r.pages)); print('size=',__import__('os').path.getsize(p))"
cp "/tmp/workspace/surgical-specimens-review/output/Updated_Surgical_Specimens_MS_Viva_Handbook.pdf" "/tmp/workspace/surgical-specimens-review/output/Updated_Surgical_Specimens_MS_Viva_Handbook_Illustrated.pdf" && python -c "from pypdf import PdfReader; p='/tmp/workspace/surgical-specimens-review/output/Updated_Surgical_Specimens_MS_Viva_Handbook_Illustrated.pdf'; r=PdfReader(p); imgs=sum(len((pg.get('/Resources',{}).get('/XObject',{})).get_object()) for pg in r.pages); print('verified pages:',len(r.pages),'approx XObjects:',imgs,'bytes:',__import__('os').path.getsize(p))"
Updated Surgical Specimens MS Viva Handbook Illustrated
PDF Document · PDF