ye mera thesis ka naalysis chp ha is me b mujy mazeed graph or tables add krny mujy sequence smj ni arrha mery pass graph or tables file bni pri ha zip file form me wo me tmhy kesy share kro
cd /home/daytona/workspace/attachments/e1ed21b1-9df5-4ebe-ba40-ce1247598cb8/ && β¦
ye lijye ye ha
cd /home/daytona/workspace/attachments/e1ed21b1-9df5-4ebe-ba40-ce1247598cb8/ && β¦
ls -lh /home/daytona/workspace/attachments/e1ed21b1-9df5-4ebe-ba40-ce1247598cb8/β¦
mkdir -p /home/daytona/workspace/AKI_Results && unzip -o /home/daytona/workspaceβ¦
sleep 15 && ls /home/daytona/workspace/AKI_Results/ 2>&1
find /home/daytona/workspace/AKI_Results/ -type f | sort
echo "=== Table 2: Primary AKI Outcome ===" && cat /home/daytona/workspace/AKI_Rβ¦
echo "=== Table 5: Categorical Renal ===" && cat /home/daytona/workspace/AKI_Resβ¦
ls /home/daytona/skills/docx/scripts/office/ && echo "---" && ls /home/daytona/sβ¦
mkdir -p /home/daytona/workspace/chapter4_unpacked && python /home/daytona/skillβ¦
ls /home/daytona/workspace/chapter4_unpacked/word/ && ls /home/daytona/workspaceβ¦
python3 -c "import docx; print('python-docx ok'); import PIL; print('PIL ok')" 2β¦
pip install --user python-docx --quiet 2>&1 | tail -3
~/build_chapter4.py
"""
Build complete Chapter 4 by appending new sections to existing docx.
"""
import sys
sys.path.insert(0, '/home/daytona/.local/lib/python3.11/site-packages')
from docx import Document
from docx.shared import Inches, Pt, RGBColor, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT, WD_ALIGN_VERTICAL
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import copy
FIGURES_DIR = "/home/daytona/workspace/AKI_Results/01_Figures/Descriptive/"
SRC_DOCX = "/home/daytona/workspace/attachments/e1ed21b1-9df5-4ebe-ba40-ce1247598cb8/correct chapter 4.docx"
OUT_DOCX = "/home/daytona/workspace/Chapter4_Complete.docx"
doc = Document(SRC_DOCX)
# βββ Helper functions βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def add_heading2(doc, text):
"""Add a bold heading paragraph (Heading 2 style or bold normal)."""
p = doc.add_paragraph()
p.style = doc.styles['Heading 2'] if 'Heading 2' in [s.name for s in doc.styles] else doc.styles['Normal']
run = p.add_run(text)
run.bold = True
run.font.size = Pt(12)
return p
def add_bold_para(doc, text):
p = doc.add_paragraph()
run = p.add_run(text)
run.bold = True
run.font.size = Pt(11)
return p
def add_normal_para(doc, text):
p = doc.add_paragraph(text)
p.style = doc.styles['Normal']
p.runs[0].font.size = Pt(11) if p.runs else None
return p
def add_note_para(doc, text):
p = doc.add_paragraph()
run1 = p.add_run("Note: ")
run1.bold = True
run1.font.size = Pt(10)
run2 = p.add_run(text)
run2.font.size = Pt(10)
return p
def add_figure(doc, img_path, caption_num, caption_text, note_text=None, width=5.5):
p_img = doc.add_paragraph()
p_img.alignment = WD_ALIGN_PARAGRAPH.CENTER
run = p_img.add_run()
run.add_picture(img_path, width=Inches(width))
p_cap = doc.add_paragraph()
p_cap.alignment = WD_ALIGN_PARAGRAPH.CENTER
run_cap = p_cap.add_run(f"Figure {caption_num} {caption_text}")
run_cap.italic = True
run_cap.font.size = Pt(10)
if note_text:
add_note_para(doc, note_text)
def shade_row(row, hex_color="D9D9D9"):
for cell in row.cells:
tc = cell._tc
tcPr = tc.get_or_add_tcPr()
shd = OxmlElement('w:shd')
shd.set(qn('w:val'), 'clear')
shd.set(qn('w:color'), 'auto')
shd.set(qn('w:fill'), hex_color)
tcPr.append(shd)
def set_cell_text(cell, text, bold=False, size=10, align=WD_ALIGN_PARAGRAPH.LEFT):
cell.text = ""
p = cell.paragraphs[0]
p.alignment = align
run = p.add_run(text)
run.bold = bold
run.font.size = Pt(size)
def add_table_caption(doc, num, text):
p = doc.add_paragraph()
run = p.add_run(f"Table {num} {text}")
run.bold = True
run.font.size = Pt(11)
# βββ Page break before new sections ββββββββββββββββββββββββββββββββββββββββββ
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 2: POSTOPERATIVE RENAL PARAMETERS (Descriptive)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
add_heading2(doc, "Postoperative Renal Function Parameters")
add_normal_para(doc,
"Serial postoperative serum creatinine measurements were recorded at 24, 48, and 72 hours "
"following surgery for all 150 patients. Additionally, urine output, blood urea nitrogen (BUN), "
"serum urea, and estimated glomerular filtration rate (eGFR) at 48 hours were assessed to monitor "
"renal function trajectory in both groups.")
# Figure 4.14 - Creatinine 24h
add_figure(doc,
FIGURES_DIR + "DESC_Q14_Creatinine_24h_Histogram.png",
"4.14", "Postoperative Serum Creatinine at 24 Hours Distribution (N = 150).",
"The mean serum creatinine at 24 hours postoperatively was 1.25 mg/dL (SD = 0.38). "
"The Minimally Invasive group demonstrated lower creatinine values compared to the Conventional Sternotomy group, "
"suggesting less early renal stress following MICS-CABG.",
width=5.5)
# Figure 4.15 - Creatinine 48h
add_figure(doc,
FIGURES_DIR + "DESC_Q15_Creatinine_48h_Histogram.png",
"4.15", "Postoperative Serum Creatinine at 48 Hours Distribution (N = 150).",
"The mean serum creatinine at 48 hours was 1.59 mg/dL (SD = 0.96). "
"A clear separation between groups is evident at this time point, with the Minimally Invasive group "
"mean of 1.26 mg/dL (SD = 0.58) being significantly lower than the Conventional group mean of 1.92 mg/dL (SD = 1.15).",
width=5.5)
# Figure 4.16 - Creatinine 72h
add_figure(doc,
FIGURES_DIR + "DESC_Q16_Creatinine_72h_Histogram.png",
"4.16", "Postoperative Serum Creatinine at 72 Hours Distribution (N = 150).",
"At 72 hours postoperatively, the mean serum creatinine was 1.52 mg/dL (SD = 0.88). "
"The Minimally Invasive group showed a mean of 1.21 mg/dL (SD = 0.56) compared to 1.83 mg/dL (SD = 1.07) "
"in the Conventional Sternotomy group, indicating sustained renal protection with the minimally invasive approach.",
width=5.5)
# Figure 4.17 - Low Urine Output
add_figure(doc,
FIGURES_DIR + "DESC_Q17_Low_Urine_Output.png",
"4.17", "Distribution of Low Urine Output in Study Population (N = 150).",
"Low urine output (defined as <0.5 mL/kg/hr for >6 hours) was observed in 16.0% of patients in the "
"Minimally Invasive group and 24.0% in the Conventional Sternotomy group. "
"Overall, 20.0% of the total study population experienced low urine output postoperatively.",
width=4.0)
# Figure 4.18 - BUN 48h
add_figure(doc,
FIGURES_DIR + "DESC_Q19_BUN_48h_Histogram.png",
"4.18", "Blood Urea Nitrogen (BUN) at 48 Hours Distribution (N = 150).",
"The mean BUN at 48 hours postoperatively was 21.66 mg/dL (SD = 7.17). "
"The Minimally Invasive group had a lower mean BUN of 20.21 mg/dL (SD = 6.41) compared to "
"23.10 mg/dL (SD = 7.72) in the Conventional Sternotomy group (p = 0.014).",
width=5.5)
# Figure 4.19 - BUN Category
add_figure(doc,
FIGURES_DIR + "DESC_Q19_BUN_Category.png",
"4.19", "Distribution of BUN Categories at 48 Hours (N = 150).",
"The majority of patients (63.3%) had BUN levels within the normal range (<24 mg/dL). "
"The proportion of patients with elevated BUN (24-40 mg/dL) was higher in the Conventional group (45.3%) "
"compared to the Minimally Invasive group (25.3%), with a statistically significant difference (p = 0.019).",
width=4.0)
# Figure 4.20 - Urea 48h
add_figure(doc,
FIGURES_DIR + "DESC_Q20_Urea_48h_Histogram.png",
"4.20", "Serum Urea at 48 Hours Distribution (N = 150).",
"The mean serum urea at 48 hours was 46.34 mg/dL (SD = 15.36). "
"The Minimally Invasive group had a mean of 43.25 mg/dL (SD = 13.72), significantly lower than "
"49.43 mg/dL (SD = 16.51) in the Conventional group (p = 0.014).",
width=5.5)
# Figure 4.21 - Urea Category
add_figure(doc,
FIGURES_DIR + "DESC_Q20_Urea_Category.png",
"4.21", "Distribution of Urea Categories at 48 Hours (N = 150).",
"A higher proportion of Conventional Sternotomy patients had urea levels >60 mg/dL (25.3%) "
"compared to the Minimally Invasive group (13.3%), indicating greater renal nitrogen retention "
"in the conventional approach (p = 0.017).",
width=4.0)
# Figure 4.22 - eGFR 48h
add_figure(doc,
FIGURES_DIR + "DESC_Q21_eGFR_48h_Histogram.png",
"4.22", "Estimated GFR at 48 Hours Distribution (N = 150).",
"The mean eGFR at 48 hours postoperatively was 58.13 mL/min/1.73mΒ² (SD = 24.47). "
"The Minimally Invasive group had a significantly higher mean eGFR of 67.67 mL/min/1.73mΒ² (SD = 22.68) "
"compared to 48.59 mL/min/1.73mΒ² (SD = 24.14) in the Conventional group (p < 0.001).",
width=5.5)
# Figure 4.23 - eGFR Category
add_figure(doc,
FIGURES_DIR + "DESC_Q21_eGFR_Category.png",
"4.23", "Distribution of eGFR Categories at 48 Hours (N = 150).",
"At 48 hours, 44.0% of Minimally Invasive patients maintained eGFR β₯60 mL/min/1.73mΒ², "
"compared to only 17.3% in the Conventional group. Conversely, 74.7% of Conventional patients "
"had eGFR <60 mL/min/1.73mΒ² versus 40.0% in the Minimally Invasive group (p < 0.001).",
width=4.0)
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 3: PRIMARY OUTCOME - AKI INCIDENCE
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
add_heading2(doc, "Primary Outcome: Incidence of Acute Kidney Injury")
add_normal_para(doc,
"The primary outcome of this study was the incidence of early acute kidney injury (AKI), "
"defined according to KDIGO criteria (serum creatinine rise β₯0.3 mg/dL within 48 hours or "
"β₯1.5x baseline within 48-72 hours, or urine output <0.5 mL/kg/hr for β₯6 hours). "
"AKI was detected in 46 out of 150 patients (30.7%) overall.")
# Table 4.2
add_table_caption(doc, "4.2", "Comparison of AKI Incidence Between Surgical Groups")
t2 = doc.add_table(rows=4, cols=6)
t2.style = 'Table Grid'
t2.alignment = WD_TABLE_ALIGNMENT.CENTER
headers = ["Group", "AKI Yes n(%)", "AKI No n(%)", "Statistical Test", "p-value", "Significance"]
shade_row(t2.rows[0], "1F4E79")
for i, h in enumerate(headers):
c = t2.rows[0].cells[i]
set_cell_text(c, h, bold=True, size=10, align=WD_ALIGN_PARAGRAPH.CENTER)
c.paragraphs[0].runs[0].font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
data2 = [
["Minimally Invasive (n=75)", "10 (13.3%)", "65 (86.7%)", "Chi-square", "< 0.001", "Yes"],
["Conventional (n=75)", "36 (48.0%)", "39 (52.0%)", "", "", ""],
["Total (n=150)", "46 (30.7%)", "104 (69.3%)", "", "", ""],
]
for ri, row_data in enumerate(data2):
row = t2.rows[ri + 1]
if ri % 2 == 1:
shade_row(row, "D6E4F0")
for ci, val in enumerate(row_data):
align = WD_ALIGN_PARAGRAPH.CENTER if ci > 0 else WD_ALIGN_PARAGRAPH.LEFT
set_cell_text(row.cells[ci], val, size=10, align=align)
add_note_para(doc,
"A statistically significant difference in AKI incidence was observed between the two groups "
"(Chi-square = 19.597, p < 0.001). AKI occurred in 13.3% of Minimally Invasive patients compared "
"to 48.0% of Conventional Sternotomy patients, representing a 3.6-fold higher risk in the conventional approach.")
# Figure 4.24 - Early AKI
add_figure(doc,
FIGURES_DIR + "DESC_Q22_Early_AKI.png",
"4.24", "Comparison of Early AKI Incidence Between Surgical Groups.",
"The bar chart illustrates the stark difference in AKI incidence between groups. "
"The Conventional Sternotomy group had a significantly higher proportion of AKI cases (48.0%) "
"compared to the Minimally Invasive group (13.3%), confirming the primary hypothesis of this study.",
width=4.5)
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 4: AKI STAGE DISTRIBUTION
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
add_heading2(doc, "AKI Stage Distribution")
add_normal_para(doc,
"Among patients who developed AKI (n=46), the severity was classified according to KDIGO staging criteria "
"(Stage 1: creatinine β₯1.5-1.9x baseline or β₯0.3 mg/dL increase; Stage 2: creatinine β₯2.0-2.9x baseline; "
"Stage 3: creatinine β₯3.0x baseline or initiation of renal replacement therapy). "
"Table 4.3 and Figure 4.25 present the AKI stage distribution across the two surgical groups.")
# Table 4.3
add_table_caption(doc, "4.3", "AKI Stage Distribution by Surgical Group")
t3 = doc.add_table(rows=6, cols=4)
t3.style = 'Table Grid'
t3.alignment = WD_TABLE_ALIGNMENT.CENTER
h3 = ["AKI Stage", "Minimally Invasive n (%)", "Conventional n (%)", "Total n (%)"]
shade_row(t3.rows[0], "1F4E79")
for i, h in enumerate(h3):
c = t3.rows[0].cells[i]
set_cell_text(c, h, bold=True, size=10, align=WD_ALIGN_PARAGRAPH.CENTER)
c.paragraphs[0].runs[0].font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
d3 = [
["No AKI", "65 (86.7%)", "39 (52.0%)", "104 (69.3%)"],
["Stage 1", "7 (9.3%)", "23 (30.7%)", "30 (20.0%)"],
["Stage 2", "1 (1.3%)", "7 (9.3%)", "8 (5.3%)"],
["Stage 3", "2 (2.7%)", "6 (8.0%)", "8 (5.3%)"],
["Chi-square = 21.533, p < 0.001", "", "", ""],
]
for ri, row_data in enumerate(d3):
row = t3.rows[ri + 1]
if ri % 2 == 1:
shade_row(row, "D6E4F0")
if ri == 4:
shade_row(row, "FFF2CC")
cell = row.cells[0]
row.cells[0].merge(row.cells[3])
set_cell_text(row.cells[0], row_data[0], bold=True, size=10, align=WD_ALIGN_PARAGRAPH.CENTER)
else:
for ci, val in enumerate(row_data):
align = WD_ALIGN_PARAGRAPH.CENTER if ci > 0 else WD_ALIGN_PARAGRAPH.LEFT
set_cell_text(row.cells[ci], val, size=10, align=align)
add_note_para(doc,
"There was a statistically significant difference in AKI stage distribution between the two groups "
"(Chi-square = 21.533, p < 0.001). Stage 1 AKI was the most common in both groups. "
"Severe AKI (Stage 2 and 3 combined) occurred in 10.7% of Conventional patients compared to 4.0% of "
"Minimally Invasive patients, indicating that not only was AKI less frequent in MICS-CABG, "
"but its severity was also lower.")
# Figure 4.25 - AKI Stage
add_figure(doc,
FIGURES_DIR + "DESC_Q23_AKI_Stage.png",
"4.25", "AKI Stage Distribution Between Surgical Groups.",
"The stacked/grouped bar chart shows the distribution of KDIGO AKI stages between the two groups. "
"The Conventional Sternotomy group had higher proportions of Stage 1 (30.7%), Stage 2 (9.3%), "
"and Stage 3 (8.0%) AKI compared to the Minimally Invasive group (9.3%, 1.3%, and 2.7%, respectively).",
width=4.5)
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 5: SERIAL RENAL PARAMETERS COMPARISON (Table 4.4)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
add_heading2(doc, "Comparison of Serial Postoperative Renal Parameters")
add_normal_para(doc,
"Table 4.4 presents the comparison of serial postoperative renal function parameters between the two surgical "
"groups. Mann-Whitney U test was used for non-normally distributed continuous variables (creatinine values), "
"while independent samples t-test was applied for normally distributed variables (eGFR, BUN, Urea at 48 hours), "
"as determined by Shapiro-Wilk normality tests.")
# Table 4.4
add_table_caption(doc, "4.4", "Comparison of Serial Postoperative Renal Parameters Between Groups")
t4 = doc.add_table(rows=9, cols=5)
t4.style = 'Table Grid'
t4.alignment = WD_TABLE_ALIGNMENT.CENTER
h4 = ["Variable", "Minimally Invasive\nMean (SD)", "Conventional\nMean (SD)", "p-value", "Significance"]
shade_row(t4.rows[0], "1F4E79")
for i, h in enumerate(h4):
c = t4.rows[0].cells[i]
set_cell_text(c, h, bold=True, size=10, align=WD_ALIGN_PARAGRAPH.CENTER)
c.paragraphs[0].runs[0].font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
d4 = [
["Creatinine 24h (mg/dL)", "1.12 (0.28)", "1.38 (0.42)", "< 0.001", "Yes *"],
["Creatinine 48h (mg/dL)", "1.26 (0.58)", "1.92 (1.15)", "< 0.001", "Yes *"],
["Creatinine 72h (mg/dL)", "1.21 (0.56)", "1.83 (1.07)", "< 0.001", "Yes *"],
["eGFR 48h (mL/min/1.73mΒ²)", "67.67 (22.68)","48.59 (24.14)","< 0.001", "Yes β "],
["Urea 48h (mg/dL)", "43.25 (13.72)","49.43 (16.51)","0.014", "Yes β "],
["BUN 48h (mg/dL)", "20.21 (6.41)", "23.10 (7.72)", "0.014", "Yes β "],
["Creatinine Change at 48h", "0.26 (0.52)", "0.76 (1.02)", "< 0.001", "Yes *"],
["Creatinine Ratio at 48h", "1.28 (0.55)", "1.69 (1.03)", "< 0.001", "Yes *"],
]
for ri, row_data in enumerate(d4):
row = t4.rows[ri + 1]
if ri % 2 == 1:
shade_row(row, "D6E4F0")
for ci, val in enumerate(row_data):
align = WD_ALIGN_PARAGRAPH.CENTER if ci > 0 else WD_ALIGN_PARAGRAPH.LEFT
bold_cell = (ci == 4 and "Yes" in val)
set_cell_text(row.cells[ci], val, bold=bold_cell, size=10, align=align)
add_note_para(doc,
"All serial renal parameters showed statistically significant differences between groups (all p < 0.05). "
"* Mann-Whitney U test (non-normal distribution). β Independent samples t-test (normal distribution). "
"The Minimally Invasive group consistently demonstrated lower creatinine values and higher eGFR at all "
"postoperative time points, indicating superior renal preservation with the MICS-CABG approach.")
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 6: CATEGORICAL RENAL PARAMETERS (Table 4.5)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
add_heading2(doc, "Comparison of Categorical Renal Parameters at 48 Hours")
add_normal_para(doc,
"Renal function parameters at 48 hours were further categorized into clinically meaningful ranges "
"and compared between the two groups using Chi-square tests. Table 4.5 summarizes these findings.")
# Table 4.5
add_table_caption(doc, "4.5", "Comparison of Categorical Renal Parameters at 48 Hours Between Groups")
t5 = doc.add_table(rows=12, cols=5)
t5.style = 'Table Grid'
t5.alignment = WD_TABLE_ALIGNMENT.CENTER
h5 = ["Variable", "Minimally Invasive n (%)", "Conventional n (%)", "p-value", "Significance"]
shade_row(t5.rows[0], "1F4E79")
for i, h in enumerate(h5):
c = t5.rows[0].cells[i]
set_cell_text(c, h, bold=True, size=10, align=WD_ALIGN_PARAGRAPH.CENTER)
c.paragraphs[0].runs[0].font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
d5 = [
["BUN < 24 mg/dL", "56 (74.7%)", "40 (53.3%)", "0.019", "Yes"],
["BUN 24-40 mg/dL", "19 (25.3%)", "34 (45.3%)", "0.019", "Yes"],
["BUN > 40 mg/dL", "0 (0.0%)", "1 (1.3%)", "0.019", "Yes"],
["Urea 40-50 mg/dL", "55 (73.3%)", "38 (50.7%)", "0.017", "Yes"],
["Urea 50-60 mg/dL", "10 (13.3%)", "18 (24.0%)", "0.017", "Yes"],
["Urea > 60 mg/dL", "10 (13.3%)", "19 (25.3%)", "0.017", "Yes"],
["eGFR β₯ 90 mL/min", "0 (0.0%)", "0 (0.0%)", "< 0.001","Yes"],
["eGFR 60-89 mL/min", "33 (44.0%)", "13 (17.3%)", "< 0.001","Yes"],
["eGFR < 60 mL/min", "30 (40.0%)", "56 (74.7%)", "< 0.001","Yes"],
["Low Urine Output: Yes", "12 (16.0%)", "18 (24.0%)", "0.307", "No"],
["Low Urine Output: No", "63 (84.0%)", "57 (76.0%)", "0.307", "No"],
]
for ri, row_data in enumerate(d5):
row = t5.rows[ri + 1]
if ri % 2 == 1:
shade_row(row, "D6E4F0")
for ci, val in enumerate(row_data):
align = WD_ALIGN_PARAGRAPH.CENTER if ci > 0 else WD_ALIGN_PARAGRAPH.LEFT
set_cell_text(row.cells[ci], val, size=10, align=align)
add_note_para(doc,
"Significant differences were observed in BUN categories (p = 0.019), Urea categories (p = 0.017), "
"and eGFR categories (p < 0.001) between the two groups. Low urine output rates, while numerically "
"higher in the Conventional group (24.0% vs 16.0%), did not reach statistical significance (p = 0.307).")
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 7: RISK FACTORS FOR AKI (Table 4.6)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
add_heading2(doc, "Risk Factors Associated with Acute Kidney Injury")
add_normal_para(doc,
"To identify clinical risk factors associated with the development of AKI, potential predictors were "
"analyzed using Chi-square tests and odds ratio estimation. Both preoperative comorbidities and "
"perioperative findings were evaluated. Table 4.6 presents the results of this risk factor analysis.")
# Table 4.6
add_table_caption(doc, "4.6", "Risk Factors Associated with AKI Development")
t6 = doc.add_table(rows=8, cols=6)
t6.style = 'Table Grid'
t6.alignment = WD_TABLE_ALIGNMENT.CENTER
h6 = ["Risk Factor", "AKI Yes\nn (%)", "AKI No\nn (%)", "Odds Ratio\n(95% CI)", "p-value", "Significance"]
shade_row(t6.rows[0], "1F4E79")
for i, h in enumerate(h6):
c = t6.rows[0].cells[i]
set_cell_text(c, h, bold=True, size=10, align=WD_ALIGN_PARAGRAPH.CENTER)
c.paragraphs[0].runs[0].font.color.rgb = RGBColor(0xFF, 0xFF, 0xFF)
d6 = [
["Low Urine Output", "22 (47.8%)", "8 (7.7%)", "11.0", "< 0.001", "Yes"],
["Diabetes Mellitus", "14 (30.4%)", "29 (27.9%)", "1.13", "0.902", "No"],
["Hypertension", "44 (95.7%)", "104 (100.0%)","0.0", "0.171", "No"],
["Chronic Kidney Disease","4 (8.7%)", "10 (9.6%)", "0.90", "1.000", "No"],
["Smoking", "14 (30.4%)", "26 (25.0%)", "1.31", "0.621", "No"],
["Male Gender", "40 (87.0%)", "93 (89.4%)", "0.79", "0.873", "No"],
["Conventional Surgery","36 (78.3%)", "39 (37.5%)", "5.88", "< 0.001", "Yes"],
]
for ri, row_data in enumerate(d6):
row = t6.rows[ri + 1]
if ri % 2 == 1:
shade_row(row, "D6E4F0")
for ci, val in enumerate(row_data):
align = WD_ALIGN_PARAGRAPH.CENTER if ci > 0 else WD_ALIGN_PARAGRAPH.LEFT
bold_cell = (ri in [0, 6] and ci == 5)
set_cell_text(row.cells[ci], val, bold=bold_cell, size=10, align=align)
add_note_para(doc,
"Among all evaluated risk factors, only low urine output (OR = 11.0, p < 0.001) and conventional sternotomy "
"approach (OR = 5.88, p < 0.001) were found to be statistically significant risk factors for AKI development. "
"Traditional comorbidities such as diabetes mellitus, hypertension, chronic kidney disease, smoking, "
"and male gender were not independently associated with AKI in this study population.")
# βββ Save ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
doc.save(OUT_DOCX)
print(f"Saved: {OUT_DOCX}")
cd /home/daytona/workspace && python3 build_chapter4.py 2>&1
python3 -c " import sys; sys.path.insert(0, '/home/daytona/.local/lib/python3.11β¦
sed -i "s/t2\.style = 'Table Grid'/t2.style = 'Normal Table'/g; s/t3\.style = 'Tβ¦
python3 -c " content = open('/home/daytona/workspace/build_chapter4.py').read() β¦
| Section | Content | Figures/Tables |
|---|---|---|
| 4.1 (done) | Baseline Demographics | Table 4.1, Fig 4.1-4.13 |
| 4.2 (add) | Postop Renal Parameters | Fig 4.14-4.17 (Cr 24/48/72h, Urine) |
| 4.3 (add) | BUN/Urea/eGFR 48h | Fig 4.18-4.23 |
| 4.4 (add) | Primary Outcome: AKI Incidence | Table 4.2 + Fig 4.24 |
| 4.5 (add) | AKI Stage Distribution | Table 4.3 + Fig 4.25 |
| 4.6 (add) | Serial Renal Comparison | Table 4.4 |
| 4.7 (add) | Categorical Renal Parameters | Table 4.5 |
| 4.8 (add) | Risk Factors for AKI | Table 4.6 |
.docx file download link ke saath provide kar sakta hun. Script ready hai, bas output path fix karna hai.Generate a Word document with all tables and figures in proper sequence
ls /home/daytona/workspace/ && echo "---" && python3 -c " import sys, io sys.patβ¦
~/build_ch4_final.py
"""
Complete Chapter 4 builder - saves via BytesIO buffer to avoid zipfile seek issue.
Appends new sections to existing chapter 4 docx.
"""
import sys, io
sys.path.insert(0, '/home/daytona/.local/lib/python3.14/site-packages')
from docx import Document
from docx.shared import Inches, Pt, RGBColor, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
FIGURES = "/home/daytona/workspace/AKI_Results/01_Figures/Descriptive/"
SRC = "/home/daytona/workspace/attachments/e1ed21b1-9df5-4ebe-ba40-ce1247598cb8/correct chapter 4.docx"
OUT = "/home/daytona/workspace/Chapter4_Complete.docx"
doc = Document(SRC)
# ββ helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def cell_borders(table):
"""Add visible borders to every cell in the table via XML."""
tbl = table._tbl
for tc in tbl.iter_tags(qn('w:tc')):
tcPr = tc.get_or_add_tcPr()
tcBorders = OxmlElement('w:tcBorders')
for side in ('top','left','bottom','right','insideH','insideV'):
b = OxmlElement(f'w:{side}')
b.set(qn('w:val'), 'single')
b.set(qn('w:sz'), '4')
b.set(qn('w:space'), '0')
b.set(qn('w:color'), '000000')
tcBorders.append(b)
tcPr.append(tcBorders)
def shade_row(row, hex_color):
for cell in row.cells:
tc = cell._tc
tcPr = tc.get_or_add_tcPr()
shd = OxmlElement('w:shd')
shd.set(qn('w:val'), 'clear')
shd.set(qn('w:color'), 'auto')
shd.set(qn('w:fill'), hex_color)
tcPr.append(shd)
def set_cell(cell, text, bold=False, size=10,
align=WD_ALIGN_PARAGRAPH.CENTER, color=None):
cell.text = ""
p = cell.paragraphs[0]
p.alignment = align
r = p.add_run(str(text))
r.bold = bold
r.font.size = Pt(size)
if color:
r.font.color.rgb = RGBColor(*color)
def heading(doc, text):
p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(12)
p.paragraph_format.space_after = Pt(6)
r = p.add_run(text)
r.bold = True
r.font.size = Pt(13)
def body(doc, text):
p = doc.add_paragraph(text)
p.paragraph_format.space_after = Pt(6)
for r in p.runs:
r.font.size = Pt(11)
def note(doc, text):
p = doc.add_paragraph()
p.paragraph_format.space_after = Pt(6)
r1 = p.add_run("Note: ")
r1.bold = True; r1.font.size = Pt(10)
r2 = p.add_run(text)
r2.font.size = Pt(10)
def fig(doc, path, num, caption, note_text=None, w=5.5):
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
p.add_run().add_picture(path, width=Inches(w))
pc = doc.add_paragraph()
pc.alignment = WD_ALIGN_PARAGRAPH.CENTER
rc = pc.add_run(f"Figure {num} {caption}")
rc.italic = True; rc.font.size = Pt(10)
if note_text:
note(doc, note_text)
def tbl_caption(doc, num, text):
p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(10)
r = p.add_run(f"Table {num} {text}")
r.bold = True; r.font.size = Pt(11)
def build_table(doc, headers, rows, alt_color="D6E4F0", hdr_color="1F4E79"):
n_cols = len(headers)
n_rows = len(rows) + 1
t = doc.add_table(rows=n_rows, cols=n_cols)
t.alignment = WD_TABLE_ALIGNMENT.CENTER
# header row
shade_row(t.rows[0], hdr_color)
for i, h in enumerate(headers):
set_cell(t.rows[0].cells[i], h, bold=True, size=10,
align=WD_ALIGN_PARAGRAPH.CENTER, color=(255,255,255))
# data rows
for ri, row_data in enumerate(rows):
row = t.rows[ri+1]
if ri % 2 == 1:
shade_row(row, alt_color)
for ci, val in enumerate(row_data):
al = WD_ALIGN_PARAGRAPH.LEFT if ci == 0 else WD_ALIGN_PARAGRAPH.CENTER
set_cell(row.cells[ci], val, size=10, align=al)
cell_borders(t)
doc.add_paragraph() # spacing after table
return t
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# PAGE BREAK before new content
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 2 β Postoperative Renal Function Parameters
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Postoperative Renal Function Parameters")
body(doc,
"Serial postoperative serum creatinine measurements were recorded at 24, 48, and 72 hours "
"following surgery for all 150 patients. Urine output, blood urea nitrogen (BUN), serum urea, "
"and estimated glomerular filtration rate (eGFR) at 48 hours were additionally assessed to monitor "
"renal function trajectory in both surgical groups.")
fig(doc, FIGURES+"DESC_Q14_Creatinine_24h_Histogram.png",
"4.14", "Postoperative Serum Creatinine at 24 Hours Distribution (N = 150).",
"The mean serum creatinine at 24 hours postoperatively was 1.25 mg/dL (SD = 0.38). "
"The Minimally Invasive group demonstrated lower values compared to the Conventional Sternotomy group, "
"indicating less early renal stress following MICS-CABG.", w=5.5)
fig(doc, FIGURES+"DESC_Q15_Creatinine_48h_Histogram.png",
"4.15", "Postoperative Serum Creatinine at 48 Hours Distribution (N = 150).",
"The mean serum creatinine at 48 hours was 1.59 mg/dL (SD = 0.96). "
"A clear separation between groups is evident at this time point: Minimally Invasive mean = 1.26 mg/dL (SD = 0.58) "
"vs Conventional mean = 1.92 mg/dL (SD = 1.15), a statistically significant difference (p < 0.001).", w=5.5)
fig(doc, FIGURES+"DESC_Q16_Creatinine_72h_Histogram.png",
"4.16", "Postoperative Serum Creatinine at 72 Hours Distribution (N = 150).",
"At 72 hours, the Minimally Invasive group maintained lower creatinine values (mean = 1.21 mg/dL, SD = 0.56) "
"compared to the Conventional group (mean = 1.83 mg/dL, SD = 1.07), indicating sustained renal "
"protection with the MICS-CABG approach.", w=5.5)
fig(doc, FIGURES+"DESC_Q17_Low_Urine_Output.png",
"4.17", "Distribution of Low Urine Output in Study Population (N = 150).",
"Low urine output (<0.5 mL/kg/hr for >6 hours) was observed in 16.0% of Minimally Invasive patients "
"and 24.0% of Conventional Sternotomy patients. Overall, 20.0% of the total study population "
"experienced low urine output postoperatively.", w=4.0)
fig(doc, FIGURES+"DESC_Q19_BUN_48h_Histogram.png",
"4.18", "Blood Urea Nitrogen (BUN) at 48 Hours Distribution (N = 150).",
"The mean BUN at 48 hours was 21.66 mg/dL (SD = 7.17). The Minimally Invasive group had a lower "
"mean BUN of 20.21 mg/dL (SD = 6.41) compared to 23.10 mg/dL (SD = 7.72) in the Conventional group (p = 0.014).", w=5.5)
fig(doc, FIGURES+"DESC_Q19_BUN_Category.png",
"4.19", "Distribution of BUN Categories at 48 Hours (N = 150).",
"The majority of patients (63.3%) had BUN within the normal range (<24 mg/dL). "
"The proportion with elevated BUN (24-40 mg/dL) was higher in the Conventional group (45.3%) "
"vs Minimally Invasive group (25.3%), a statistically significant difference (p = 0.019).", w=4.0)
fig(doc, FIGURES+"DESC_Q20_Urea_48h_Histogram.png",
"4.20", "Serum Urea at 48 Hours Distribution (N = 150).",
"The mean serum urea at 48 hours was 46.34 mg/dL (SD = 15.36). "
"The Minimally Invasive group had a mean of 43.25 mg/dL (SD = 13.72), significantly lower than "
"49.43 mg/dL (SD = 16.51) in the Conventional group (p = 0.014).", w=5.5)
fig(doc, FIGURES+"DESC_Q20_Urea_Category.png",
"4.21", "Distribution of Urea Categories at 48 Hours (N = 150).",
"A higher proportion of Conventional Sternotomy patients had urea levels >60 mg/dL (25.3%) "
"compared to the Minimally Invasive group (13.3%), indicating greater renal nitrogen retention "
"in the conventional approach (p = 0.017).", w=4.0)
fig(doc, FIGURES+"DESC_Q21_eGFR_48h_Histogram.png",
"4.22", "Estimated GFR at 48 Hours Distribution (N = 150).",
"The mean eGFR at 48 hours was 58.13 mL/min/1.73m\u00b2 (SD = 24.47). "
"The Minimally Invasive group had a significantly higher mean eGFR of 67.67 mL/min/1.73m\u00b2 (SD = 22.68) "
"compared to 48.59 mL/min/1.73m\u00b2 (SD = 24.14) in the Conventional group (p < 0.001).", w=5.5)
fig(doc, FIGURES+"DESC_Q21_eGFR_Category.png",
"4.23", "Distribution of eGFR Categories at 48 Hours (N = 150).",
"At 48 hours, 44.0% of Minimally Invasive patients maintained eGFR \u226560 mL/min/1.73m\u00b2 vs "
"only 17.3% in the Conventional group. Conversely, 74.7% of Conventional patients had eGFR "
"<60 mL/min/1.73m\u00b2 vs 40.0% in the Minimally Invasive group (p < 0.001).", w=4.0)
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 3 β Primary Outcome: AKI Incidence
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Primary Outcome: Incidence of Acute Kidney Injury")
body(doc,
"The primary outcome was the incidence of early acute kidney injury (AKI), defined per KDIGO criteria "
"(serum creatinine rise \u22650.3 mg/dL within 48 hours, or \u22651.5\u00d7 baseline within 48-72 hours, "
"or urine output <0.5 mL/kg/hr for \u22656 hours). AKI developed in 46 of 150 patients (30.7%) overall.")
tbl_caption(doc, "4.2", "Comparison of AKI Incidence Between Surgical Groups")
build_table(doc,
["Group", "AKI Yes n (%)", "AKI No n (%)", "Statistical Test", "p-value", "Significance"],
[
["Minimally Invasive (n=75)", "10 (13.3%)", "65 (86.7%)", "Chi-square (df=1)", "< 0.001", "Yes"],
["Conventional (n=75)", "36 (48.0%)", "39 (52.0%)", "", "", ""],
["Total (n=150)", "46 (30.7%)", "104 (69.3%)","", "", ""],
]
)
note(doc,
"Chi-square = 19.597, df = 1, p < 0.001. AKI occurred in 13.3% of Minimally Invasive patients "
"compared to 48.0% of Conventional Sternotomy patients, representing a 3.6-fold higher risk "
"with the conventional approach.")
fig(doc, FIGURES+"DESC_Q22_Early_AKI.png",
"4.24", "Comparison of Early AKI Incidence Between Surgical Groups.",
"The bar chart illustrates the significant difference in AKI incidence. The Conventional Sternotomy "
"group had a substantially higher proportion of AKI cases (48.0%) compared to the Minimally Invasive "
"group (13.3%), confirming the primary hypothesis of this study.", w=4.5)
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 4 β AKI Stage Distribution
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "AKI Stage Distribution")
body(doc,
"Among patients who developed AKI (n=46), severity was classified per KDIGO staging: "
"Stage 1 (creatinine \u22651.5-1.9\u00d7 baseline or \u22650.3 mg/dL increase), "
"Stage 2 (creatinine \u22652.0-2.9\u00d7 baseline), and "
"Stage 3 (creatinine \u22653.0\u00d7 baseline or renal replacement therapy). "
"Table 4.3 and Figure 4.25 present the distribution across both groups.")
tbl_caption(doc, "4.3", "AKI Stage Distribution by Surgical Group")
build_table(doc,
["AKI Stage", "Minimally Invasive n (%)", "Conventional n (%)", "Total n (%)"],
[
["No AKI", "65 (86.7%)", "39 (52.0%)", "104 (69.3%)"],
["Stage 1", "7 (9.3%)", "23 (30.7%)", "30 (20.0%)"],
["Stage 2", "1 (1.3%)", "7 (9.3%)", "8 (5.3%)"],
["Stage 3", "2 (2.7%)", "6 (8.0%)", "8 (5.3%)"],
]
)
note(doc,
"Chi-square = 21.533, p < 0.001. Stage 1 AKI was most common in both groups. "
"Severe AKI (Stage 2+3 combined) occurred in 17.3% of Conventional patients vs 4.0% of "
"Minimally Invasive patients, indicating both lower frequency and lower severity with MICS-CABG.")
fig(doc, FIGURES+"DESC_Q23_AKI_Stage.png",
"4.25", "AKI Stage Distribution Between Surgical Groups.",
"The grouped bar chart shows KDIGO AKI stage distribution. The Conventional Sternotomy group had "
"markedly higher proportions of Stage 1 (30.7%), Stage 2 (9.3%), and Stage 3 (8.0%) AKI "
"compared to the Minimally Invasive group (9.3%, 1.3%, and 2.7%, respectively).", w=4.5)
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 5 β Serial Renal Parameters Comparison (Table 4.4)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Comparison of Serial Postoperative Renal Parameters")
body(doc,
"Table 4.4 presents the comparison of serial postoperative renal function parameters between the two "
"surgical groups. Mann-Whitney U test was applied for non-normally distributed variables (creatinine), "
"while independent samples t-test was used for normally distributed variables (eGFR, BUN, Urea at 48h), "
"as determined by Shapiro-Wilk normality testing.")
tbl_caption(doc, "4.4", "Comparison of Serial Postoperative Renal Parameters Between Surgical Groups")
build_table(doc,
["Variable", "Minimally Invasive\nMean (SD)", "Conventional\nMean (SD)",
"Statistical Test", "p-value", "Significance"],
[
["Creatinine 24h (mg/dL)", "1.12 (0.28)", "1.38 (0.42)", "Mann-Whitney U", "< 0.001", "Yes"],
["Creatinine 48h (mg/dL)", "1.26 (0.58)", "1.92 (1.15)", "Mann-Whitney U", "< 0.001", "Yes"],
["Creatinine 72h (mg/dL)", "1.21 (0.56)", "1.83 (1.07)", "Mann-Whitney U", "< 0.001", "Yes"],
["eGFR 48h (mL/min/1.73m\u00b2)", "67.67 (22.68)", "48.59 (24.14)", "Independent t", "< 0.001", "Yes"],
["Urea 48h (mg/dL)", "43.25 (13.72)", "49.43 (16.51)", "Independent t", "0.014", "Yes"],
["BUN 48h (mg/dL)", "20.21 (6.41)", "23.10 (7.72)", "Independent t", "0.014", "Yes"],
["Creatinine Change at 48h", "0.26 (0.52)", "0.76 (1.02)", "Mann-Whitney U", "< 0.001", "Yes"],
["Creatinine Ratio at 48h", "1.28 (0.55)", "1.69 (1.03)", "Mann-Whitney U", "< 0.001", "Yes"],
]
)
note(doc,
"All serial renal parameters showed statistically significant differences between groups (all p \u2264 0.014). "
"The Minimally Invasive group consistently demonstrated lower creatinine values and higher eGFR at all "
"postoperative time points, confirming superior renal preservation with MICS-CABG.")
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 6 β Categorical Renal Parameters (Table 4.5)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Comparison of Categorical Renal Parameters at 48 Hours")
body(doc,
"Renal function parameters at 48 hours were categorized into clinically meaningful ranges and "
"compared between the two groups using Chi-square tests. Table 4.5 summarizes these findings.")
tbl_caption(doc, "4.5", "Comparison of Categorical Renal Parameters at 48 Hours Between Groups")
build_table(doc,
["Variable", "Minimally Invasive n (%)", "Conventional n (%)", "p-value", "Significance"],
[
["BUN < 24 mg/dL", "56 (74.7%)", "40 (53.3%)", "0.019", "Yes"],
["BUN 24-40 mg/dL", "19 (25.3%)", "34 (45.3%)", "0.019", "Yes"],
["BUN > 40 mg/dL", "0 (0.0%)", "1 (1.3%)", "0.019", "Yes"],
["Urea 40-50 mg/dL", "55 (73.3%)", "38 (50.7%)", "0.017", "Yes"],
["Urea 50-60 mg/dL", "10 (13.3%)", "18 (24.0%)", "0.017", "Yes"],
["Urea > 60 mg/dL", "10 (13.3%)", "19 (25.3%)", "0.017", "Yes"],
["eGFR \u2265 90 mL/min", "0 (0.0%)", "0 (0.0%)", "< 0.001", "Yes"],
["eGFR 60-89 mL/min", "33 (44.0%)", "13 (17.3%)", "< 0.001", "Yes"],
["eGFR < 60 mL/min", "30 (40.0%)", "56 (74.7%)", "< 0.001", "Yes"],
["Low Urine Output: Yes", "12 (16.0%)", "18 (24.0%)", "0.307", "No"],
["Low Urine Output: No", "63 (84.0%)", "57 (76.0%)", "0.307", "No"],
]
)
note(doc,
"Significant differences were found for BUN categories (Chi-square = 7.912, p = 0.019), "
"Urea categories (Chi-square = 8.186, p = 0.017), and eGFR categories (Chi-square = 18.556, p < 0.001). "
"Low urine output was numerically higher in the Conventional group (24.0% vs 16.0%) but did not "
"reach statistical significance (p = 0.307).")
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 7 β Risk Factors for AKI (Table 4.6)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Risk Factors Associated with Acute Kidney Injury")
body(doc,
"To identify clinical risk factors associated with AKI development, potential predictors were analyzed "
"using Chi-square tests and odds ratio estimation. Both preoperative comorbidities and perioperative "
"findings were evaluated. Table 4.6 presents the risk factor analysis results.")
tbl_caption(doc, "4.6", "Risk Factors Associated with AKI Development")
build_table(doc,
["Risk Factor", "AKI Yes n (%)", "AKI No n (%)", "Odds Ratio", "p-value", "Significance"],
[
["Low Urine Output", "22 (47.8%)", "8 (7.7%)", "11.0", "< 0.001", "Yes"],
["Diabetes Mellitus", "14 (30.4%)", "29 (27.9%)", "1.13", "0.902", "No"],
["Hypertension", "44 (95.7%)", "104 (100.0%)","0.0", "0.171", "No"],
["Chronic Kidney Disease", "4 (8.7%)", "10 (9.6%)", "0.90", "1.000", "No"],
["Smoking", "14 (30.4%)", "26 (25.0%)", "1.31", "0.621", "No"],
["Male Gender", "40 (87.0%)", "93 (89.4%)", "0.79", "0.873", "No"],
]
)
note(doc,
"Among all evaluated risk factors, only low urine output (OR = 11.0, p < 0.001) was found to be a "
"statistically significant independent risk factor for AKI. Traditional comorbidities including "
"diabetes mellitus, hypertension, chronic kidney disease, smoking, and male gender were not "
"independently associated with AKI in this study population.")
# ββ Save via BytesIO buffer βββββββββββββββββββββββββββββββββββββββββββββββββββ
buf = io.BytesIO()
doc.save(buf)
buf.seek(0)
with open(OUT, 'wb') as f:
f.write(buf.read())
import os
size = os.path.getsize(OUT)
print(f"Saved: {OUT}")
print(f"Size: {size:,} bytes ({size/1024/1024:.1f} MB)")
cd /home/daytona/workspace && python3 build_ch4_final.py 2>&1
python3 -c " content = open('/home/daytona/workspace/build_ch4_final.py').read()β¦
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksβ¦
python3 -c " content = open('/home/daytona/workspace/build_ch4_final.py').read()β¦
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksβ¦
Chapter4 Complete
Word Document Β· DOCX
| # | Section | Content |
|---|---|---|
| Already existing | Baseline Characteristics | Table 4.1 + Figures 4.1-4.13 |
| 4.2 (NEW) | Postoperative Renal Parameters | Figures 4.14-4.23 (Creatinine 24/48/72h, BUN, Urea, eGFR, Urine Output) |
| 4.3 (NEW) | Primary Outcome: AKI Incidence | Table 4.2 + Figure 4.24 |
| 4.4 (NEW) | AKI Stage Distribution | Table 4.3 + Figure 4.25 |
| 4.5 (NEW) | Serial Renal Parameters | Table 4.4 (Mann-Whitney U + t-test results) |
| 4.6 (NEW) | Categorical Renal Parameters | Table 4.5 |
| 4.7 (NEW) | Risk Factors for AKI | Table 4.6 (OR = 11.0 for low urine output) |
Results summary table banao thesis ke conclusion ke liye
~/build_summary_table.py
"""
Build a professional Results Summary Table Word document for thesis conclusion.
"""
import sys, io
sys.path.insert(0, '/home/daytona/.local/lib/python3.14/site-packages')
from docx import Document
from docx.shared import Inches, Pt, RGBColor, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
OUT = "/home/daytona/workspace/Results_Summary_Table.docx"
doc = Document()
# ββ Page margins ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from docx.oxml import OxmlElement
section = doc.sections[0]
section.page_width = Cm(29.7)
section.page_height = Cm(21.0)
section.orientation = 1 # landscape
section.left_margin = Cm(2.0)
section.right_margin = Cm(2.0)
section.top_margin = Cm(2.0)
section.bottom_margin = Cm(2.0)
# ββ Helpers βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def qn(tag):
prefix, local = tag.split(':')
ns = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
return f"{{{ns[prefix]}}}{local}"
def shade_cell(cell, hex_color):
tc = cell._tc
tcPr = tc.get_or_add_tcPr()
for s in tcPr.findall(qn('w:shd')):
tcPr.remove(s)
shd = OxmlElement('w:shd')
shd.set(qn('w:val'), 'clear')
shd.set(qn('w:color'), 'auto')
shd.set(qn('w:fill'), hex_color)
tcPr.append(shd)
def set_cell(cell, text, bold=False, italic=False, size=10,
align=WD_ALIGN_PARAGRAPH.CENTER,
font_color=None, bg_color=None, wrap=True):
if bg_color:
shade_cell(cell, bg_color)
cell.text = ""
p = cell.paragraphs[0]
p.alignment = align
p.paragraph_format.space_before = Pt(2)
p.paragraph_format.space_after = Pt(2)
r = p.add_run(str(text))
r.bold = bold
r.italic = italic
r.font.size = Pt(size)
if font_color:
r.font.color.rgb = RGBColor(*font_color)
def add_cell_borders(table):
tbl = table._tbl
for tc in tbl.iter_tcs():
tcPr = tc.get_or_add_tcPr()
for ex in tcPr.findall(qn('w:tcBorders')):
tcPr.remove(ex)
tcBorders = OxmlElement('w:tcBorders')
for side in ('top','left','bottom','right','insideH','insideV'):
b = OxmlElement(f'w:{side}')
b.set(qn('w:val'), 'single')
b.set(qn('w:sz'), '6')
b.set(qn('w:space'), '0')
b.set(qn('w:color'), '2C5F8A')
tcBorders.append(b)
tcW_list = tcPr.findall(qn('w:tcW'))
if tcW_list:
idx = list(tcPr).index(tcW_list[-1]) + 1
tcPr.insert(idx, tcBorders)
else:
tcPr.insert(0, tcBorders)
def set_col_width(table, col_idx, width_cm):
for row in table.rows:
cell = row.cells[col_idx]
tc = cell._tc
tcPr = tc.get_or_add_tcPr()
for w in tcPr.findall(qn('w:tcW')):
tcPr.remove(w)
tcW = OxmlElement('w:tcW')
twips = int(width_cm * 567) # 1 cm = 567 twips
tcW.set(qn('w:w'), str(twips))
tcW.set(qn('w:type'), 'dxa')
tcPr.insert(0, tcW)
# ββ Title βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
title_p = doc.add_paragraph()
title_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
title_p.paragraph_format.space_after = Pt(4)
tr = title_p.add_run("Summary of Key Results")
tr.bold = True
tr.font.size = Pt(16)
tr.font.color.rgb = RGBColor(0x1F, 0x4E, 0x79)
sub_p = doc.add_paragraph()
sub_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
sub_p.paragraph_format.space_after = Pt(12)
sr = sub_p.add_run(
"MICS-CABG (Minimally Invasive) vs Conventional Median Sternotomy β "
"Acute Kidney Injury after On-Pump CABG (N = 150)"
)
sr.italic = True
sr.font.size = Pt(11)
sr.font.color.rgb = RGBColor(0x40, 0x40, 0x40)
# ββ MAIN TABLE ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Columns: Domain | Variable | MI (n=75) | Conv (n=75) | Stat Test | p-value | Sig | Interpretation
HDR_BG = "1F4E79"
HDR_FG = (255, 255, 255)
SEC_BG = "D6E4F0" # section header rows (light blue)
ALT_BG = "F2F8FF" # alternating rows
SIG_BG = "E2EFDA" # significant result highlight
NOSIG_BG = "FFFFFF"
rows_data = [
# (domain, variable, MI, Conv, test, pval, sig, interpretation, is_section_hdr)
# ββ SECTION: BASELINE ββββββββββββββββββββββββββββββββββββββββββββββββββββ
("BASELINE\nCHARACTERISTICS", None, None, None, None, None, None, None, True),
("", "Male Gender", "67 (89.3%)", "66 (88.0%)", "Chi-square", "1.000", "No", "Groups comparable", False),
("", "Age > 50 years", "59 (78.7%)", "60 (80.0%)", "Chi-square", "1.000", "No", "Groups comparable", False),
("", "Diabetes Mellitus", "23 (30.7%)", "20 (26.7%)", "Chi-square", "0.718", "No", "Groups comparable", False),
("", "Hypertension", "75 (100.0%)", "73 (97.3%)", "Chi-square", "0.476", "No", "Groups comparable", False),
("", "CKD", "5 (6.7%)", "9 (12.0%)", "Chi-square", "0.399", "No", "Groups comparable", False),
("", "Smoking", "18 (24.0%)", "22 (29.3%)", "Chi-square", "0.580", "No", "Groups comparable", False),
("", "Baseline Creatinine","1.05 (0.29)", "1.12 (0.34)", "β", "β", "β", "Similar renal baseline", False),
("", "Baseline eGFR", "76.9 (24.1)", "74.5 (22.7)", "β", "β", "β", "Similar renal baseline", False),
("", "LVEF (mean %)", "50.1 (9.1)", "50.1 (9.1)", "β", "β", "β", "Groups comparable", False),
# ββ SECTION: PRIMARY OUTCOME βββββββββββββββββββββββββββββββββββββββββββββ
("PRIMARY\nOUTCOME", None, None, None, None, None, None, None, True),
("", "AKI Incidence", "10 (13.3%)", "36 (48.0%)", "Chi-square", "< 0.001", "YES", "3.6Γ higher risk with conventional", False),
# ββ SECTION: AKI STAGING βββββββββββββββββββββββββββββββββββββββββββββββββ
("AKI STAGE\n(KDIGO)", None, None, None, None, None, None, None, True),
("", "Stage 1", "7 (9.3%)", "23 (30.7%)", "Chi-square", "< 0.001", "YES", "Conventional: 3.3Γ more Stage 1", False),
("", "Stage 2", "1 (1.3%)", "7 (9.3%)", "Chi-square", "< 0.001", "YES", "7Γ higher in conventional", False),
("", "Stage 3", "2 (2.7%)", "6 (8.0%)", "Chi-square", "< 0.001", "YES", "3Γ higher in conventional", False),
# ββ SECTION: SERIAL CREATININE βββββββββββββββββββββββββββββββββββββββββββ
("SERIAL RENAL\nPARAMETERS", None, None, None, None, None, None, None, True),
("", "Creatinine 24h (mg/dL)", "1.12 (0.28)", "1.38 (0.42)", "Mann-Whitney U", "< 0.001", "YES", "Lower renal stress in MICS", False),
("", "Creatinine 48h (mg/dL)", "1.26 (0.58)", "1.92 (1.15)", "Mann-Whitney U", "< 0.001", "YES", "Significant 0.66 mg/dL difference", False),
("", "Creatinine 72h (mg/dL)", "1.21 (0.56)", "1.83 (1.07)", "Mann-Whitney U", "< 0.001", "YES", "Sustained renal protection in MICS", False),
("", "Creatinine Change Ξ48h", "0.26 (0.52)", "0.76 (1.02)", "Mann-Whitney U", "< 0.001", "YES", "Less creatinine rise in MICS", False),
("", "Creatinine Ratio 48h", "1.28 (0.55)", "1.69 (1.03)", "Mann-Whitney U", "< 0.001", "YES", "Lower relative rise in MICS", False),
("", "eGFR 48h (mL/min)", "67.67 (22.68)","48.59 (24.14)","Independent t","< 0.001","YES", "Better GFR preservation in MICS", False),
("", "Urea 48h (mg/dL)", "43.25 (13.72)","49.43 (16.51)","Independent t","0.014", "YES", "Less nitrogen retention in MICS", False),
("", "BUN 48h (mg/dL)", "20.21 (6.41)", "23.10 (7.72)", "Independent t","0.014", "YES", "Less nitrogen retention in MICS", False),
# ββ SECTION: CATEGORICAL RENAL βββββββββββββββββββββββββββββββββββββββββββ
("CATEGORICAL\nRENAL\nPARAMETERS", None, None, None, None, None, None, None, True),
("", "eGFR 60-89 mL/min (normal-mild)", "33 (44.0%)", "13 (17.3%)", "Chi-square", "< 0.001","YES","2.5Γ more MICS patients in normal range", False),
("", "eGFR < 60 mL/min (reduced)", "30 (40.0%)", "56 (74.7%)", "Chi-square", "< 0.001","YES","1.9Γ more conventional patients with reduced GFR", False),
("", "BUN < 24 mg/dL (normal)", "56 (74.7%)", "40 (53.3%)", "Chi-square", "0.019", "YES","More MICS patients in normal BUN range", False),
("", "Urea > 60 mg/dL (elevated)", "10 (13.3%)", "19 (25.3%)", "Chi-square", "0.017", "YES","Higher elevation in conventional group", False),
("", "Low Urine Output", "12 (16.0%)", "18 (24.0%)", "Chi-square", "0.307", "No", "No significant difference", False),
# ββ SECTION: RISK FACTORS ββββββββββββββββββββββββββββββββββββββββββββββββ
("RISK FACTORS\nFOR AKI", None, None, None, None, None, None, None, True),
("", "Low Urine Output", "OR = 11.0", "β", "Chi-square", "< 0.001", "YES", "Strongest independent risk factor", False),
("", "Diabetes Mellitus", "OR = 1.13", "β", "Chi-square", "0.902", "No", "Not a significant risk factor", False),
("", "Hypertension", "OR = 0.0", "β", "Chi-square", "0.171", "No", "Not a significant risk factor", False),
("", "Chronic Kidney Disease","OR = 0.90","β","Chi-square", "1.000", "No", "Not a significant risk factor", False),
("", "Smoking", "OR = 1.31", "β", "Chi-square", "0.621", "No", "Not a significant risk factor", False),
("", "Male Gender", "OR = 0.79", "β", "Chi-square", "0.873", "No", "Not a significant risk factor", False),
]
n_data_rows = len(rows_data)
table = doc.add_table(rows=n_data_rows + 1, cols=8)
table.alignment = WD_TABLE_ALIGNMENT.CENTER
# ββ Header row ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
HEADERS = [
"Domain", "Variable / Outcome",
"MICS-CABG\n(n=75)\nMean(SD) or n(%)",
"Conventional\n(n=75)\nMean(SD) or n(%)",
"Statistical\nTest", "p-value",
"Significant?", "Clinical Interpretation"
]
for ci, h in enumerate(HEADERS):
set_cell(table.rows[0].cells[ci], h,
bold=True, size=10, align=WD_ALIGN_PARAGRAPH.CENTER,
bg_color=HDR_BG, font_color=HDR_FG)
# ββ Data rows βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
for ri, (domain, var, mi, conv, test, pval, sig, interp, is_sec) in enumerate(rows_data):
row = table.rows[ri + 1]
if is_sec:
# Section header spanning all columns
for ci in range(8):
shade_cell(row.cells[ci], SEC_BG)
# Merge cells 1-7 (keep domain separate or merge all)
row.cells[0].merge(row.cells[7])
set_cell(row.cells[0], domain,
bold=True, size=11, align=WD_ALIGN_PARAGRAPH.CENTER,
bg_color=SEC_BG)
row.cells[0].paragraphs[0].runs[0].font.color.rgb = RGBColor(0x1F, 0x4E, 0x79)
else:
row_bg = SIG_BG if sig == "YES" else (ALT_BG if ri % 2 == 0 else NOSIG_BG)
sig_bg = "70AD47" if sig == "YES" else ("FF0000" if sig == "No" else "FFFFFF")
sig_fg = (255,255,255) if sig in ("YES","No") else (0,0,0)
set_cell(row.cells[0], domain, size=9, align=WD_ALIGN_PARAGRAPH.CENTER, bg_color=row_bg)
set_cell(row.cells[1], var, size=10, align=WD_ALIGN_PARAGRAPH.LEFT, bg_color=row_bg, bold=False)
set_cell(row.cells[2], mi, size=10, align=WD_ALIGN_PARAGRAPH.CENTER,bg_color=row_bg)
set_cell(row.cells[3], conv, size=10, align=WD_ALIGN_PARAGRAPH.CENTER,bg_color=row_bg)
set_cell(row.cells[4], test, size=9, align=WD_ALIGN_PARAGRAPH.CENTER,bg_color=row_bg)
set_cell(row.cells[5], pval, size=10, bold=(sig=="YES"),
align=WD_ALIGN_PARAGRAPH.CENTER, bg_color=row_bg)
set_cell(row.cells[6], sig, size=10, bold=True,
align=WD_ALIGN_PARAGRAPH.CENTER,
bg_color=sig_bg if sig in ("YES","No") else row_bg,
font_color=sig_fg)
set_cell(row.cells[7], interp, size=9, italic=True,
align=WD_ALIGN_PARAGRAPH.LEFT, bg_color=row_bg)
add_cell_borders(table)
# ββ Column widths (landscape A4 = ~25 cm usable) βββββββββββββββββββββββββββββ
widths = [2.8, 5.5, 3.2, 3.2, 2.8, 2.0, 2.0, 4.5]
for ci, w in enumerate(widths):
set_col_width(table, ci, w)
# ββ Footer note βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
doc.add_paragraph()
fn = doc.add_paragraph()
fn.paragraph_format.space_before = Pt(8)
fn_r = fn.add_run(
"Notes: MICS-CABG = Minimally Invasive Cardiac Surgery - Coronary Artery Bypass Grafting; "
"Conv = Conventional Median Sternotomy; AKI = Acute Kidney Injury (KDIGO criteria); "
"eGFR = Estimated Glomerular Filtration Rate; BUN = Blood Urea Nitrogen; "
"OR = Odds Ratio; SD = Standard Deviation; n(%) = frequency (percentage). "
"Significance level set at p < 0.05. "
"Green cells = statistically significant findings. "
"Values for serial parameters represent postoperative measurements."
)
fn_r.font.size = Pt(8.5)
fn_r.italic = True
fn_r.font.color.rgb = RGBColor(0x60, 0x60, 0x60)
# ββ Save ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
import os
buf = io.BytesIO()
doc.save(buf)
buf.seek(0)
with open(OUT, 'wb') as f:
f.write(buf.read())
print(f"Saved: {OUT} ({os.path.getsize(OUT):,} bytes)")
cd /home/daytona/workspace && python3 build_summary_table.py 2>&1
python3 -c "import sys; print(sys.version); import site; print(site.getusersitepβ¦
python3 -c " import sys sys.path.insert(0, '/home/daytona/.local/lib/python3.14/β¦
ls /home/daytona/.local/lib/ && pip install --user python-docx --quiet 2>&1 | taβ¦
pip install --user python-docx 2>&1 | tail -5 && python3 -c "import docx; print(β¦
cd /home/daytona/workspace && python3 build_summary_table.py 2>&1
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksβ¦
python3 - << 'PYEOF' # Fix: unpack, patch XML, repack import sys, zipfile, shutiβ¦
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksβ¦
python3 - << 'PYEOF' """Post-process the docx: fix gridSpan/shd ordering + zoom β¦
# Unpack the generated docx, fix XML, then repack mkdir -p /home/daytona/workspβ¦
mkdir -p /home/daytona/workspace/summary_unpacked && python3 /home/daytona/skillβ¦
# Use Python's zipfile to manually extract (read mode works fine, only write modβ¦
python3 - << 'EOF' import sys, io sys.path.insert(0, '/home/daytona/.local/lib/pβ¦
Results Summary Table
Word Document Β· DOCX
| Section | Content |
|---|---|
| Section 1 | Baseline Characteristics (10 variables - sab NS, groups comparable) |
| Section 2 | Primary Outcome: AKI Incidence (13.3% vs 48.0%, p<0.001) |
| Section 3 | AKI KDIGO Staging (Stage 1/2/3 distribution) |
| Section 4 | Serial Renal Parameters (Cr 24/48/72h, eGFR, BUN, Urea) |
| Section 5 | Categorical Renal Parameters at 48h |
| Section 6 | Risk Factors with Odds Ratios |
yr tm ne x sheet jo ha is me unko to bnaya ni ha table me
~/build_summary_xlsx.py
"""
Build a professional Results Summary Table in Excel (.xlsx) for thesis conclusion.
Uses openpyxl with full formatting, color coding, borders.
"""
import openpyxl
from openpyxl import Workbook
from openpyxl.styles import (
PatternFill, Font, Alignment, Border, Side, GradientFill
)
from openpyxl.utils import get_column_letter
wb = Workbook()
ws = wb.active
ws.title = "Results Summary"
# ββ Color palette ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
C_HDR_BG = "1F4E79" # dark navy - header
C_HDR_FG = "FFFFFF"
C_SEC_BG = "BDD7EE" # light blue - section rows
C_SEC_FG = "1F4E79"
C_SIG_BG = "E2EFDA" # light green - significant rows
C_NSIG_BG = "FFFFFF" # white - non-significant
C_ALT_BG = "F5FAFF" # very light blue - alternating
C_YES_BG = "70AD47" # green - YES significance cell
C_YES_FG = "FFFFFF"
C_NO_BG = "F2F2F2" # light gray - No significance cell
C_BORDER = "2C5F8A"
def fill(hex_color):
return PatternFill("solid", fgColor=hex_color)
def border():
s = Side(style='thin', color=C_BORDER)
return Border(left=s, right=s, top=s, bottom=s)
def font(bold=False, italic=False, size=10, color="000000"):
return Font(name="Arial", bold=bold, italic=italic, size=size, color=color)
def align(h="center", v="center", wrap=True):
return Alignment(horizontal=h, vertical=v, wrap_text=wrap)
# ββ Title rows βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ws.append([])
ws.merge_cells("A1:H1")
ws["A1"] = "SUMMARY OF KEY RESULTS"
ws["A1"].font = Font(name="Arial", bold=True, size=18, color=C_HDR_BG)
ws["A1"].alignment = align("center", "center")
ws.row_dimensions[1].height = 30
ws.append([])
ws.merge_cells("A2:H2")
ws["A2"] = "MICS-CABG (Minimally Invasive) vs Conventional Median Sternotomy | Acute Kidney Injury after On-Pump CABG | N = 150"
ws["A2"].font = Font(name="Arial", italic=True, size=11, color="404040")
ws["A2"].alignment = align("center", "center")
ws.row_dimensions[2].height = 20
ws.append([]) # spacer row 3
# ββ Column headers (row 4) βββββββββββββββββββββββββββββββββββββββββββββββββββββ
HEADERS = [
"Domain",
"Variable / Outcome",
"MICS-CABG (n=75)\nMean (SD) or n (%)",
"Conventional (n=75)\nMean (SD) or n (%)",
"Statistical Test",
"p-value",
"Significant?",
"Clinical Interpretation"
]
ws.append(HEADERS)
hdr_row = 4
for ci, h in enumerate(HEADERS, 1):
cell = ws.cell(row=hdr_row, column=ci)
cell.fill = fill(C_HDR_BG)
cell.font = font(bold=True, size=10, color=C_HDR_FG)
cell.alignment = align("center", "center")
cell.border = border()
ws.row_dimensions[hdr_row].height = 36
# ββ Data: (is_section, domain, variable, MI, Conv, Test, p, Sig, Interpretation)
ROWS = [
# ββ SECTION 1 ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(True, "SECTION 1: BASELINE CHARACTERISTICS", "", "", "", "", "", ""),
(False, "", "Male Gender", "67 (89.3%)", "66 (88.0%)", "Chi-square", "1.000", "No", "Groups comparable β no significant difference"),
(False, "", "Age > 50 years", "59 (78.7%)", "60 (80.0%)", "Chi-square", "1.000", "No", "Groups comparable"),
(False, "", "Diabetes Mellitus", "23 (30.7%)", "20 (26.7%)", "Chi-square", "0.718", "No", "Groups comparable"),
(False, "", "Hypertension", "75 (100.0%)", "73 (97.3%)", "Chi-square", "0.476", "No", "Groups comparable"),
(False, "", "Chronic Kidney Disease", "5 (6.7%)", "9 (12.0%)", "Chi-square", "0.399", "No", "Groups comparable"),
(False, "", "Smoking", "18 (24.0%)", "22 (29.3%)", "Chi-square", "0.580", "No", "Groups comparable"),
(False, "", "BMI Overweight", "40 (53.3%)", "32 (42.7%)", "Chi-square", "0.253", "No", "Groups comparable"),
(False, "", "Baseline Creatinine", "1.05 mg/dL", "1.12 mg/dL", "β", "β", "β", "Similar renal function at baseline in both groups"),
(False, "", "Baseline eGFR", "76.9 mL/min", "74.5 mL/min", "β", "β", "β", "Similar renal function at baseline"),
(False, "", "Baseline LVEF (mean)", "50.1%", "50.1%", "β", "β", "β", "Similar cardiac function β groups well matched"),
# ββ SECTION 2 ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(True, "SECTION 2: PRIMARY OUTCOME β AKI INCIDENCE", "", "", "", "", "", ""),
(False, "", "AKI Incidence", "10 (13.3%)", "36 (48.0%)", "Chi-square (df=1)", "< 0.001", "YES", "Conventional: 3.6Γ higher AKI risk | ChiΒ² = 19.597"),
# ββ SECTION 3 ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(True, "SECTION 3: AKI SEVERITY β KDIGO STAGING", "", "", "", "", "", ""),
(False, "", "No AKI", "65 (86.7%)", "39 (52.0%)", "Chi-square", "< 0.001", "YES", "Significantly more AKI-free patients in MICS group"),
(False, "", "Stage 1 AKI", "7 (9.3%)", "23 (30.7%)", "Chi-square", "< 0.001", "YES", "3.3Γ more Stage 1 AKI in conventional group"),
(False, "", "Stage 2 AKI", "1 (1.3%)", "7 (9.3%)", "Chi-square", "< 0.001", "YES", "7Γ more Stage 2 in conventional group"),
(False, "", "Stage 3 AKI", "2 (2.7%)", "6 (8.0%)", "Chi-square", "< 0.001", "YES", "3Γ more Stage 3 in conventional group"),
# ββ SECTION 4 ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(True, "SECTION 4: SERIAL POSTOPERATIVE RENAL PARAMETERS", "", "", "", "", "", ""),
(False, "", "Creatinine 24h (mg/dL)", "1.12 (0.28)", "1.38 (0.42)", "Mann-Whitney U", "< 0.001", "YES", "Less early renal injury with MICS approach"),
(False, "", "Creatinine 48h (mg/dL)", "1.26 (0.58)", "1.92 (1.15)", "Mann-Whitney U", "< 0.001", "YES", "0.66 mg/dL lower in MICS β clinically significant"),
(False, "", "Creatinine 72h (mg/dL)", "1.21 (0.56)", "1.83 (1.07)", "Mann-Whitney U", "< 0.001", "YES", "Sustained renal protection maintained at 72 hours"),
(False, "", "Creatinine Change Ξ48h", "0.26 (0.52)", "0.76 (1.02)", "Mann-Whitney U", "< 0.001", "YES", "3Γ less creatinine rise in MICS group"),
(False, "", "Creatinine Ratio 48h", "1.28 (0.55)", "1.69 (1.03)", "Mann-Whitney U", "< 0.001", "YES", "Lower relative rise confirms better preservation"),
(False, "", "eGFR 48h (mL/min/1.73mΒ²)","67.67 (22.68)", "48.59 (24.14)", "Independent t-test", "< 0.001", "YES", "19.1 mL/min higher GFR in MICS group"),
(False, "", "Urea 48h (mg/dL)", "43.25 (13.72)", "49.43 (16.51)", "Independent t-test", "0.014", "YES", "Less nitrogen retention in MICS group"),
(False, "", "BUN 48h (mg/dL)", "20.21 (6.41)", "23.10 (7.72)", "Independent t-test", "0.014", "YES", "Lower BUN β reduced catabolic stress in MICS"),
# ββ SECTION 5 ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(True, "SECTION 5: CATEGORICAL RENAL PARAMETERS AT 48 HOURS", "", "", "", "", "", ""),
(False, "", "eGFR β₯ 60 mL/min (normal-mild)", "33 (44.0%)", "13 (17.3%)", "Chi-square", "< 0.001", "YES", "2.5Γ more MICS patients maintained normal GFR"),
(False, "", "eGFR < 60 mL/min (reduced)", "30 (40.0%)", "56 (74.7%)", "Chi-square", "< 0.001", "YES", "1.9Γ more conventional patients with reduced GFR"),
(False, "", "BUN < 24 mg/dL (normal range)", "56 (74.7%)", "40 (53.3%)", "Chi-square", "0.019", "YES", "More MICS patients remained in normal BUN range"),
(False, "", "Urea > 60 mg/dL (elevated)", "10 (13.3%)", "19 (25.3%)", "Chi-square", "0.017", "YES", "Higher urea elevation in conventional group"),
(False, "", "Low Urine Output", "12 (16.0%)", "18 (24.0%)", "Chi-square", "0.307", "No", "No significant difference between groups"),
# ββ SECTION 6 ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
(True, "SECTION 6: RISK FACTORS FOR AKI β ODDS RATIO ANALYSIS", "", "", "", "", "", ""),
(False, "", "Low Urine Output", "OR = 11.0", "Reference", "Chi-square", "< 0.001", "YES", "Strongest independent risk factor for AKI (OR=11.0)"),
(False, "", "Conventional Surgery", "OR = 5.88", "Reference", "Chi-square", "< 0.001", "YES", "Surgical approach is a significant risk factor"),
(False, "", "Diabetes Mellitus", "OR = 1.13", "Reference", "Chi-square", "0.902", "No", "Not an independent risk factor in this cohort"),
(False, "", "Hypertension", "OR = 0.0", "Reference", "Chi-square", "0.171", "No", "Not a significant risk factor"),
(False, "", "Chronic Kidney Disease", "OR = 0.90", "Reference", "Chi-square", "1.000", "No", "Not a significant risk factor"),
(False, "", "Smoking", "OR = 1.31", "Reference", "Chi-square", "0.621", "No", "Not a significant risk factor"),
(False, "", "Male Gender", "OR = 0.79", "Reference", "Chi-square", "0.873", "No", "Not a significant risk factor"),
]
current_row = 5
alt = False
for r in ROWS:
is_sec = r[0]
if is_sec:
sec_text = r[1]
ws.append([sec_text, "", "", "", "", "", "", ""])
ws.merge_cells(f"A{current_row}:H{current_row}")
c = ws.cell(row=current_row, column=1)
c.fill = fill(C_SEC_BG)
c.font = Font(name="Arial", bold=True, size=11, color=C_SEC_FG)
c.alignment = align("center", "center")
c.border = border()
ws.row_dimensions[current_row].height = 22
alt = False
else:
_, domain, var, mi, conv, test, p, sig, interp = r
row_bg = C_SIG_BG if sig == "YES" else (C_ALT_BG if alt else C_NSIG_BG)
alt = not alt
vals = [domain, var, mi, conv, test, p, sig, interp]
ws.append(vals)
for ci, val in enumerate(vals, 1):
cell = ws.cell(row=current_row, column=ci)
cell.border = border()
cell.fill = fill(row_bg)
cell.alignment = align(
"center" if ci != 2 and ci != 8 else "left",
"center"
)
if ci == 6: # p-value
cell.font = font(bold=(sig=="YES"), size=10,
color="C00000" if sig=="YES" else "000000")
elif ci == 7: # Significant?
if sig == "YES":
cell.fill = fill(C_YES_BG)
cell.font = font(bold=True, size=10, color=C_YES_FG)
elif sig == "No":
cell.fill = fill(C_NO_BG)
cell.font = font(size=10, color="595959")
else:
cell.font = font(size=10, color="808080")
elif ci == 8: # Interpretation
cell.font = font(italic=True, size=9, color="404040")
elif ci == 1: # Domain
cell.font = font(size=9, color="606060")
else:
cell.font = font(size=10)
ws.row_dimensions[current_row].height = 18
current_row += 1
# ββ Footer note ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ws.append([])
current_row += 1
ws.append(["Note: MICS-CABG = Minimally Invasive Cardiac Surgery-CABG; AKI = Acute Kidney Injury (KDIGO criteria); "
"eGFR = Estimated GFR; BUN = Blood Urea Nitrogen; OR = Odds Ratio; SD = Standard Deviation. "
"Significance level p < 0.05. Green rows = statistically significant results. "
"All postoperative parameters measured after surgery."])
ws.merge_cells(f"A{current_row+1}:H{current_row+1}")
note_cell = ws.cell(row=current_row+1, column=1)
note_cell.font = Font(name="Arial", italic=True, size=8.5, color="606060")
note_cell.alignment = Alignment(horizontal="left", vertical="center", wrap_text=True)
ws.row_dimensions[current_row+1].height = 28
# ββ Column widths ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
col_widths = {
"A": 14, # Domain
"B": 34, # Variable
"C": 22, # MICS
"D": 22, # Conv
"E": 20, # Test
"F": 12, # p-value
"G": 14, # Significant
"H": 42, # Interpretation
}
for col, w in col_widths.items():
ws.column_dimensions[col].width = w
# ββ Freeze panes at row 5 (below headers) ββββββββββββββββββββββββββββββββββββ
ws.freeze_panes = "A5"
# ββ Page setup for printing βββββββββββββββββββββββββββββββββββββββββββββββββββ
ws.page_setup.orientation = "landscape"
ws.page_setup.fitToPage = True
ws.page_setup.fitToWidth = 1
ws.page_setup.fitToHeight = 0
# ββ Save ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
OUT = "/home/daytona/workspace/Results_Summary_Table.xlsx"
wb.save(OUT)
import os
print(f"Saved: {OUT} ({os.path.getsize(OUT):,} bytes)")
cd /home/daytona/workspace && python3 build_summary_xlsx.py 2>&1
python3 -c " content = open('/home/daytona/workspace/build_summary_xlsx.py').reaβ¦
python3 -c " import openpyxl wb = openpyxl.load_workbook('/home/daytona/workspacβ¦
Results Summary Table
Spreadsheet Β· XLSX
| Column | Content |
|---|---|
| A | Domain |
| B | Variable / Outcome |
| C | MICS-CABG (n=75) |
| D | Conventional (n=75) |
| E | Statistical Test |
| F | p-value |
| G | Significant? |
| H | Clinical Interpretation |
jo ap ko me zip file di ha os me ap tables figures bnaye h wo pury ni ha un me se kam ni bni cheezien normality test or mean median wala to kuch b ni add kiya ap
echo "=== ALL FILES IN ZIP ===" && find /home/daytona/workspace/AKI_Results/ -tyβ¦
echo "=== Baseline Creatinine DescStats ===" && cat /home/daytona/workspace/AKI_β¦
echo "=== Creatinine 24h DescStats ===" && cat /home/daytona/workspace/AKI_Resulβ¦
echo "=== Creatinine 24h ByGroup ===" && cat /home/daytona/workspace/AKI_Resultsβ¦
~/build_complete_xlsx.py
"""
Complete multi-sheet Excel workbook from AKI thesis zip data.
Sheets:
1. Descriptive Statistics (Mean, Median, SD, Min, Max, Q1, Q3, Skewness, Kurtosis β Total + By Group)
2. Normality Tests (Shapiro-Wilk W, p-value, Normal?, Test Recommended)
3. Comparison Tables (Tables 2-6: AKI, Staging, Serial Renal, Categorical, Risk Factors)
4. Results Summary (one-page combined summary for conclusion)
"""
import io, os
import openpyxl
from openpyxl import Workbook
from openpyxl.styles import PatternFill, Font, Alignment, Border, Side
from openpyxl.utils import get_column_letter
wb = Workbook()
# βββ Shared style helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def fl(hex6):
return PatternFill("solid", fgColor=hex6)
def bd(color="2C5F8A"):
s = Side(style='thin', color=color)
return Border(left=s, right=s, top=s, bottom=s)
def fn(bold=False, italic=False, sz=10, color="000000"):
return Font(name="Arial", bold=bold, italic=italic, size=sz, color=color)
def al(h="center", v="center", wrap=True):
return Alignment(horizontal=h, vertical=v, wrap_text=wrap)
def write_title(ws, row, text, ncols, bg="1F4E79", fg="FFFFFF", sz=14, h=30):
ws.merge_cells(start_row=row, start_column=1, end_row=row, end_column=ncols)
c = ws.cell(row=row, column=1, value=text)
c.fill = fl(bg); c.font = fn(bold=True, sz=sz, color=fg)
c.alignment = al("center","center"); ws.row_dimensions[row].height = h
def write_subheading(ws, row, text, ncols, bg="BDD7EE", fg="1F4E79", sz=11, h=20):
ws.merge_cells(start_row=row, start_column=1, end_row=row, end_column=ncols)
c = ws.cell(row=row, column=1, value=text)
c.fill = fl(bg); c.font = fn(bold=True, sz=sz, color=fg)
c.alignment = al("center","center"); ws.row_dimensions[row].height = h
def write_header_row(ws, row, headers, bg="1F4E79", fg="FFFFFF", h=32):
for ci, hdr in enumerate(headers, 1):
c = ws.cell(row=row, column=ci, value=hdr)
c.fill = fl(bg); c.font = fn(bold=True, sz=10, color=fg)
c.alignment = al("center","center"); c.border = bd()
ws.row_dimensions[row].height = h
def write_data_row(ws, row, values, bg="FFFFFF", bold_cols=(), italic_cols=(), h=18):
for ci, val in enumerate(values, 1):
c = ws.cell(row=row, column=ci, value=val)
c.fill = fl(bg)
c.font = fn(bold=(ci in bold_cols), italic=(ci in italic_cols), sz=10)
c.alignment = al("left" if ci <= 2 else "center","center")
c.border = bd()
ws.row_dimensions[row].height = h
def set_col_widths(ws, widths_dict):
for col, w in widths_dict.items():
ws.column_dimensions[col].width = w
ALT1 = "F5FAFF"
ALT2 = "FFFFFF"
SIG = "E2EFDA"
NSIG = "FFF2CC"
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SHEET 1 β DESCRIPTIVE STATISTICS
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ws1 = wb.active
ws1.title = "1_Descriptive_Statistics"
ws1.freeze_panes = "A6"
write_title(ws1, 1,
"DESCRIPTIVE STATISTICS β Continuous Variables",
11, h=28)
ws1.merge_cells("A2:K2")
ws1.cell(2,1).value = (
"AKI After On-Pump CABG: MICS-CABG (n=75) vs Conventional Sternotomy (n=75) | N = 150 | "
"Shapiro-Wilk normality test applied; non-normal variables analysed with Mann-Whitney U")
ws1.cell(2,1).font = fn(italic=True, sz=10, color="404040")
ws1.cell(2,1).alignment = al("center","center")
ws1.row_dimensions[2].height = 18
# ββ Section A: Baseline ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
write_subheading(ws1, 3, "SECTION A: BASELINE CONTINUOUS VARIABLES", 11, h=22)
HDR = ["Variable","Group","N","Mean","SD","Minimum","Q1 (25th)","Median (50th)","Q3 (75th)","Maximum","Skewness"]
write_header_row(ws1, 4, HDR)
write_subheading(ws1, 5, "", 11, bg="FFFFFF", h=2) # spacer
baseline_rows = [
# variable, group, N, mean, sd, min, q1, median, q3, max, skew
("Baseline Creatinine (mg/dL)", "Total (N=150)", 150, 1.08, 0.322, 0.50, 0.83, 1.07, 1.26, 1.88, 0.295),
("", "MICS-CABG", 75, 0.999, 0.25, 0.50, 0.84, 0.99, 1.11, 1.63, "β"),
("", "Conventional", 75, 1.16, 0.365, 0.50, 0.93, 1.17, 1.37, 1.88, "β"),
("Baseline eGFR (mL/min/1.73mΒ²)","Total (N=150)", 150, 75.70, 23.34, 35.5, 59.05, 72.90, 92.88, 130.0, 0.217),
("", "MICS-CABG", 75, 80.37, 21.75, 36.8, 62.0, 79.90, 96.0, 130.0, "β"),
("", "Conventional", 75, 71.04, 24.08, 35.5, 51.1, 67.10, 88.5, 118.8, "β"),
("LVEF (%)", "Total (N=150)", 150, 50.09, 9.09, 28.2, 43.45, 50.25, 56.18, 75.0, 0.200),
("", "MICS-CABG", 75, 50.80, 9.70, 28.4, 43.20, 50.70, 59.40, 75.0, "β"),
("", "Conventional", 75, 49.39, 8.43, 28.2, 42.90, 50.00, 55.00, 67.6, "β"),
("Preop Haemoglobin (g/dL)", "Total (N=150)", 150, 13.35, 1.49, 9.4, 12.30, 13.40, 14.10, 16.9, 0.238),
("", "MICS-CABG", 75, 13.50, 1.46, 10.1, 12.50, 13.40, 14.50, 16.6, "β"),
("", "Conventional", 75, 13.19, 1.51, 9.4, 12.10, 13.00, 14.00, 16.9, "β"),
]
r = 6
for i, row in enumerate(baseline_rows):
bg = ALT1 if (i // 3) % 2 == 0 else ALT2
write_data_row(ws1, r, row, bg=bg, bold_cols=(1,) if row[1].startswith("Total") else ())
r += 1
# ββ Section B: Postoperative βββββββββββββββββββββββββββββββββββββββββββββββββββ
ws1.append([])
r += 1
write_subheading(ws1, r, "SECTION B: POSTOPERATIVE CONTINUOUS VARIABLES", 11, h=22)
r += 1
write_header_row(ws1, r, HDR)
r += 1
postop_rows = [
("Creatinine 24h (mg/dL)", "Total (N=150)", 150, 1.248, 0.377, 0.57, 1.00, 1.19, 1.50, 2.42, 0.652),
("", "MICS-CABG", 75, 1.115, 0.278, 0.58, 0.91, 1.08, 1.29, 2.07, "β"),
("", "Conventional", 75, 1.380, 0.416, 0.57, 1.10, 1.35, 1.58, 2.42, "β"),
("Creatinine 48h (mg/dL)", "Total (N=150)", 150, 1.589, 0.966, 0.64, 1.04, 1.315, 1.73, 6.54, 2.539),
("", "MICS-CABG", 75, 1.261, 0.579, 0.64, 0.97, 1.14, 1.30, 4.22, "β"),
("", "Conventional", 75, 1.917, 1.151, 0.65, 1.20, 1.56, 2.16, 6.54, "β"),
("Creatinine 72h (mg/dL)", "Total (N=150)", 150, 1.518, 0.908, 0.47, 0.98, 1.24, 1.68, 6.27, 2.394),
("", "MICS-CABG", 75, 1.207, 0.558, 0.47, 0.90, 1.10, 1.33, 3.76, "β"),
("", "Conventional", 75, 1.829, 1.073, 0.59, 1.17, 1.56, 2.06, 6.27, "β"),
("eGFR at 48h (mL/min/1.73mΒ²)", "Total (N=150)", 150, 58.13, 25.23, 8.4, 39.30, 57.60, 75.55, 118.9, 0.123),
("", "MICS-CABG", 75, 67.67, 22.68, 13.6, 51.90, 67.00, 84.20, 118.9, "β"),
("", "Conventional", 75, 48.59, 24.14, 8.4, 31.20, 46.90, 63.60, 112.4, "β"),
("BUN at 48h (mg/dL)", "Total (N=150)", 150, 21.65, 7.22, 9.3, 17.03, 21.25, 26.40, 43.4, 0.291),
("", "MICS-CABG", 75, 20.21, 6.41, 9.3, 15.80, 19.50, 24.40, 37.7, "β"),
("", "Conventional", 75, 23.10, 7.72, 9.3, 18.20, 23.30, 27.70, 43.4, "β"),
("Urea at 48h (mg/dL)", "Total (N=150)", 150, 46.34, 15.44, 20.0, 36.35, 45.45, 56.55, 92.9, 0.292),
("", "MICS-CABG", 75, 43.25, 13.72, 20.0, 33.85, 41.70, 52.30, 80.7, "β"),
("", "Conventional", 75, 49.43, 16.51, 20.0, 39.00, 49.90, 59.35, 92.9, "β"),
]
for i, row in enumerate(postop_rows):
bg = SIG if (i // 3) % 2 == 0 else ALT1
write_data_row(ws1, r, row, bg=bg, bold_cols=(1,) if row[1].startswith("Total") else ())
r += 1
set_col_widths(ws1, {"A":34,"B":18,"C":6,"D":8,"E":8,"F":9,"G":10,"H":12,"I":10,"J":9,"K":10})
ws1.page_setup.orientation = "landscape"; ws1.page_setup.fitToPage = True; ws1.page_setup.fitToWidth = 1
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SHEET 2 β NORMALITY TESTS
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ws2 = wb.create_sheet("2_Normality_Tests")
ws2.freeze_panes = "A5"
write_title(ws2, 1, "NORMALITY TESTING β Shapiro-Wilk Test Results", 9, h=28)
ws2.merge_cells("A2:I2")
ws2.cell(2,1).value = ("Shapiro-Wilk test applied to each continuous variable per group (n=75 each). "
"p < 0.05 = non-normal distribution β Mann-Whitney U used. p β₯ 0.05 = normal β Independent t-test used.")
ws2.cell(2,1).font = fn(italic=True, sz=10, color="404040")
ws2.cell(2,1).alignment = al("center","center")
ws2.row_dimensions[2].height = 20
write_header_row(ws2, 3, [
"Variable",
"MICS-CABG\nW-statistic","MICS-CABG\np-value","MICS-CABG\nNormal?",
"Conventional\nW-statistic","Conventional\np-value","Conventional\nNormal?",
"Statistical Test\nRecommended","Justification"
], h=38)
normality = [
("Baseline Creatinine (mg/dL)", 0.9854,"0.545","Yes", 0.9706,"0.078","Yes", "Independent t-test", "Both groups normal"),
("Baseline eGFR (mL/min/1.73mΒ²)", 0.9847,"0.502","Yes", 0.9466,"0.003","No", "Mann-Whitney U", "Conventional non-normal"),
("LVEF (%)", 0.9838,"0.456","Yes", 0.9933,"0.966","Yes", "Independent t-test", "Both groups normal"),
("Preop Haemoglobin (g/dL)", 0.9771,"0.191","Yes", 0.9894,"0.792","Yes", "Independent t-test", "Both groups normal"),
("Creatinine 24h (mg/dL)", 0.9589,"0.016","No", 0.9839,"0.461","Yes", "Mann-Whitney U", "MICS non-normal"),
("Creatinine 48h (mg/dL)", 0.6527,"<0.001","No", 0.7865,"<0.001","No", "Mann-Whitney U", "Both groups non-normal"),
("Creatinine 72h (mg/dL)", 0.6605,"<0.001","No", 0.8095,"<0.001","No", "Mann-Whitney U", "Both groups non-normal"),
("BUN 48h (mg/dL)", 0.9687,"0.060","Yes", 0.9774,"0.200","Yes", "Independent t-test", "Both groups normal"),
("Urea 48h (mg/dL)", 0.9686,"0.059","Yes", 0.9771,"0.192","Yes", "Independent t-test", "Both groups normal"),
("eGFR 48h (mL/min/1.73mΒ²)", 0.9918,"0.914","Yes", 0.9722,"0.098","Yes", "Independent t-test", "Both groups normal"),
("Creatinine Change Ξ48h", 0.4040,"<0.001","No", 0.6964,"<0.001","No", "Mann-Whitney U", "Both groups non-normal"),
("Creatinine Ratio 48h", 0.4118,"<0.001","No", 0.6082,"<0.001","No", "Mann-Whitney U", "Both groups non-normal"),
]
r2 = 4
for i, row in enumerate(normality):
var, mi_w, mi_p, mi_n, cv_w, cv_p, cv_n, test, just = row
bg = ALT1 if i % 2 == 0 else ALT2
# color code Normal? cells
row_vals = [var, mi_w, mi_p, mi_n, cv_w, cv_p, cv_n, test, just]
for ci, val in enumerate(row_vals, 1):
c = ws2.cell(row=r2, column=ci, value=val)
c.border = bd()
c.alignment = al("left" if ci in (1,8,9) else "center","center")
# Normal? columns get color
if ci == 4:
c.fill = fl("C6EFCE") if val=="Yes" else fl("FFC7CE")
c.font = fn(bold=True, sz=10, color="276221" if val=="Yes" else "9C0006")
elif ci == 7:
c.fill = fl("C6EFCE") if val=="Yes" else fl("FFC7CE")
c.font = fn(bold=True, sz=10, color="276221" if val=="Yes" else "9C0006")
elif ci == 8:
c.fill = fl("FFF2CC") if "Mann" in val else fl("EBF3FB")
c.font = fn(bold=True, sz=10, color="7F6000" if "Mann" in val else "1F4E79")
else:
c.fill = fl(bg)
c.font = fn(sz=10)
ws2.row_dimensions[r2].height = 18
r2 += 1
# Legend
r2 += 1
ws2.merge_cells(f"A{r2}:I{r2}")
ws2.cell(r2,1).value = ("Legend: Green = Normal distribution (p β₯ 0.05) | "
"Red = Non-normal distribution (p < 0.05) | "
"Yellow = Mann-Whitney U test used | Blue = Independent t-test used | "
"W-statistic close to 1.0 indicates normality")
ws2.cell(r2,1).font = fn(italic=True, sz=9, color="606060")
ws2.cell(r2,1).alignment = al("left","center",wrap=True)
ws2.row_dimensions[r2].height = 28
set_col_widths(ws2, {"A":36,"B":13,"C":12,"D":13,"E":15,"F":14,"G":15,"H":22,"I":28})
ws2.page_setup.orientation = "landscape"; ws2.page_setup.fitToPage = True; ws2.page_setup.fitToWidth = 1
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SHEET 3 β COMPARISON TABLES
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ws3 = wb.create_sheet("3_Comparison_Tables")
ws3.freeze_panes = "A4"
write_title(ws3, 1, "COMPARISON TABLES β MICS-CABG vs Conventional Sternotomy", 7, h=28)
ws3.row_dimensions[2].height = 6
r3 = 3
def comp_section(ws, r, title, headers, rows_data, ncols=7):
write_subheading(ws, r, title, ncols, h=22); r += 1
write_header_row(ws, r, headers, h=32); r += 1
for i, row in enumerate(rows_data):
sig = row[-1] if row else ""
bg = SIG if sig=="YES" else (NSIG if sig=="No" else ALT1)
if "Chi2=" in str(row[0]) or "Note" in str(row[0]):
bg = "FFF9C4"
write_data_row(ws, r, row, bg=bg, bold_cols=(1,) if sig=="YES" else ()); r += 1
ws.row_dimensions[r].height = 8; r += 2
return r
# Table 2: Primary Outcome
r3 = comp_section(ws3, r3, "TABLE 4.2 β Primary Outcome: AKI Incidence",
["Group","AKI Yes n (%)","AKI No n (%)","Chi-square","df","p-value","Significant?"],
[
["Minimally Invasive (n=75)","10 (13.3%)","65 (86.7%)","19.597","1","< 0.001","YES"],
["Conventional (n=75)", "36 (48.0%)","39 (52.0%)","","","",""],
["Total (n=150)", "46 (30.7%)","104 (69.3%)","","","",""],
["Note: 3.6Γ higher AKI risk in conventional group","","","","","",""],
])
# Table 3: AKI Staging
r3 = comp_section(ws3, r3, "TABLE 4.3 β AKI Stage Distribution (KDIGO Criteria)",
["AKI Stage","MICS-CABG n (%)","Conventional n (%)","Total n (%)","Chi-square","p-value","Significant?"],
[
["No AKI", "65 (86.7%)","39 (52.0%)","104 (69.3%)","21.533","< 0.001","YES"],
["Stage 1", "7 (9.3%)", "23 (30.7%)","30 (20.0%)", "","","YES"],
["Stage 2", "1 (1.3%)", "7 (9.3%)", "8 (5.3%)", "","","YES"],
["Stage 3", "2 (2.7%)", "6 (8.0%)", "8 (5.3%)", "","","YES"],
])
# Table 4: Serial Renal
r3 = comp_section(ws3, r3, "TABLE 4.4 β Serial Postoperative Renal Parameters",
["Variable","MICS-CABG Mean (SD)","Conventional Mean (SD)","Statistical Test","Test Statistic","p-value","Significant?"],
[
["Creatinine 24h (mg/dL)", "1.12 (0.28)", "1.38 (0.42)", "Mann-Whitney U", "U=1611.0","< 0.001","YES"],
["Creatinine 48h (mg/dL)", "1.26 (0.58)", "1.92 (1.15)", "Mann-Whitney U", "U=1452.5","< 0.001","YES"],
["Creatinine 72h (mg/dL)", "1.21 (0.56)", "1.83 (1.07)", "Mann-Whitney U", "U=1472.0","< 0.001","YES"],
["eGFR 48h (mL/min/1.73mΒ²)", "67.67 (22.68)","48.59 (24.14)","Independent t-test","t(148)=4.988","< 0.001","YES"],
["Urea 48h (mg/dL)", "43.25 (13.72)","49.43 (16.51)","Independent t-test","t(148)=-2.493","0.014","YES"],
["BUN 48h (mg/dL)", "20.21 (6.41)", "23.10 (7.72)", "Independent t-test","t(148)=-2.493","0.014","YES"],
["Creatinine Change Ξ48h", "0.26 (0.52)", "0.76 (1.02)", "Mann-Whitney U", "U=1570.0","< 0.001","YES"],
["Creatinine Ratio at 48h", "1.28 (0.55)", "1.69 (1.03)", "Mann-Whitney U", "U=1786.0","< 0.001","YES"],
])
# Table 5: Categorical
r3 = comp_section(ws3, r3, "TABLE 4.5 β Categorical Renal Parameters at 48 Hours",
["Variable","MICS-CABG n (%)","Conventional n (%)","Chi-square","df","p-value","Significant?"],
[
["BUN < 24 mg/dL", "56 (74.7%)","40 (53.3%)","7.912","2","0.019","YES"],
["BUN 24-40 mg/dL", "19 (25.3%)","34 (45.3%)","","","0.019","YES"],
["BUN > 40 mg/dL", "0 (0.0%)", "1 (1.3%)", "","","0.019","YES"],
["Urea 40-50 mg/dL", "55 (73.3%)","38 (50.7%)","8.186","2","0.017","YES"],
["Urea 50-60 mg/dL", "10 (13.3%)","18 (24.0%)","","","0.017","YES"],
["Urea > 60 mg/dL", "10 (13.3%)","19 (25.3%)","","","0.017","YES"],
["eGFR β₯ 90 mL/min", "0 (0.0%)", "0 (0.0%)", "18.556","2","< 0.001","YES"],
["eGFR 60-89 mL/min", "33 (44.0%)","13 (17.3%)","","","< 0.001","YES"],
["eGFR < 60 mL/min", "30 (40.0%)","56 (74.7%)","","","< 0.001","YES"],
["Low Urine Output: Yes", "12 (16.0%)","18 (24.0%)","1.042","1","0.307","No"],
["Low Urine Output: No", "63 (84.0%)","57 (76.0%)","","","0.307","No"],
])
# Table 6: Risk Factors
r3 = comp_section(ws3, r3, "TABLE 4.6 β Risk Factors for AKI (Odds Ratio Analysis)",
["Risk Factor","AKI Yes n (%)","AKI No n (%)","Odds Ratio","Chi-square","p-value","Significant?"],
[
["Low Urine Output", "22 (47.8%)", "8 (7.7%)", "11.0", "29.648","< 0.001","YES"],
["Conventional Surgery", "36 (78.3%)", "39 (37.5%)", "5.88", "19.597","< 0.001","YES"],
["Diabetes Mellitus", "14 (30.4%)", "29 (27.9%)", "1.13", "0.015", "0.902", "No"],
["Hypertension", "44 (95.7%)", "104 (100.0%)","0.0", "1.874", "0.171", "No"],
["Chronic Kidney Disease", "4 (8.7%)", "10 (9.6%)", "0.90", "0.0", "1.000", "No"],
["Smoking", "14 (30.4%)", "26 (25.0%)", "1.31", "0.244", "0.621", "No"],
["Male Gender", "40 (87.0%)", "93 (89.4%)", "0.79", "0.026", "0.873", "No"],
])
set_col_widths(ws3, {"A":36,"B":22,"C":22,"D":22,"E":18,"F":12,"G":14})
ws3.page_setup.orientation = "landscape"; ws3.page_setup.fitToPage = True; ws3.page_setup.fitToWidth = 1
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SHEET 4 β RESULTS SUMMARY (for Conclusion chapter)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ws4 = wb.create_sheet("4_Results_Summary")
ws4.freeze_panes = "A5"
write_title(ws4, 1, "RESULTS SUMMARY β For Thesis Conclusion", 8, h=28)
ws4.merge_cells("A2:H2")
ws4.cell(2,1).value = ("MICS-CABG vs Conventional Sternotomy | AKI After On-Pump CABG | "
"N=150 | MICS-CABG n=75 | Conventional n=75")
ws4.cell(2,1).font = fn(italic=True, sz=11, color="404040")
ws4.cell(2,1).alignment = al("center","center")
ws4.row_dimensions[2].height = 18
write_header_row(ws4, 3, [
"Domain","Variable / Outcome",
"MICS-CABG (n=75)\nMean(SD) or n(%)",
"Conventional (n=75)\nMean(SD) or n(%)",
"Statistical Test","p-value","Significant?","Key Finding"
], h=36)
summary_rows = [
(True, "SECTION 1: BASELINE β ALL COMPARABLE (p > 0.05 for all variables)","","","","","",""),
(False, "Baseline","Male Gender", "67 (89.3%)","66 (88.0%)", "Chi-square","1.000", "No", "Groups well-matched at baseline"),
(False, "","Age > 50 years", "59 (78.7%)","60 (80.0%)", "Chi-square","1.000", "No", "Groups well-matched"),
(False, "","Diabetes Mellitus", "23 (30.7%)","20 (26.7%)", "Chi-square","0.718", "No", "Groups comparable"),
(False, "","Baseline Creatinine", "0.999 mg/dL","1.160 mg/dL","β", "β", "β", "Mean (SD): Total = 1.08 (0.32) | Median = 1.07"),
(False, "","Baseline eGFR", "80.4 mL/min","71.0 mL/min","β", "β", "β", "Mean (SD): Total = 75.70 (23.34) | Median = 72.9"),
(False, "","LVEF (mean)", "50.8%", "49.4%", "β", "β", "β", "Mean (SD): Total = 50.09 (9.09) | Median = 50.25"),
(False, "","Preop Haemoglobin", "13.50 g/dL", "13.19 g/dL", "β", "β", "β", "Mean (SD): Total = 13.35 (1.49) | Median = 13.4"),
(True, "SECTION 2: PRIMARY OUTCOME","","","","","",""),
(False, "AKI","AKI Incidence", "10 (13.3%)","36 (48.0%)", "Chi-square (df=1)","< 0.001","YES","3.6Γ higher AKI risk in conventional group | ChiΒ²=19.597"),
(True, "SECTION 3: AKI SEVERITY (KDIGO)","","","","","",""),
(False, "KDIGO","No AKI", "65 (86.7%)","39 (52.0%)", "Chi-square","< 0.001","YES","ChiΒ²=21.533 | Significantly more AKI-free in MICS"),
(False, "","Stage 1", "7 (9.3%)", "23 (30.7%)", "Chi-square","< 0.001","YES","3.3Γ higher Stage 1 in conventional group"),
(False, "","Stage 2", "1 (1.3%)", "7 (9.3%)", "Chi-square","< 0.001","YES","7Γ higher Stage 2 in conventional group"),
(False, "","Stage 3", "2 (2.7%)", "6 (8.0%)", "Chi-square","< 0.001","YES","3Γ higher Stage 3 in conventional group"),
(True, "SECTION 4: SERIAL RENAL PARAMETERS β ALL SIGNIFICANT","","","","","",""),
(False, "Renal","Creatinine 24h", "1.12 (0.28)","1.38 (0.42)","Mann-Whitney U","< 0.001","YES","Median: MICS=1.08 | Conv=1.35 | U=1611"),
(False, "","Creatinine 48h", "1.26 (0.58)","1.92 (1.15)","Mann-Whitney U","< 0.001","YES","Median: MICS=1.14 | Conv=1.56 | U=1452.5"),
(False, "","Creatinine 72h", "1.21 (0.56)","1.83 (1.07)","Mann-Whitney U","< 0.001","YES","Median: MICS=1.10 | Conv=1.56 | U=1472"),
(False, "","eGFR 48h", "67.67 (22.68)","48.59 (24.14)","Indep. t-test","< 0.001","YES","Median: MICS=67.0 | Conv=46.9 | t(148)=4.988"),
(False, "","Urea 48h", "43.25 (13.72)","49.43 (16.51)","Indep. t-test","0.014","YES","Median: MICS=41.7 | Conv=49.9 | t(148)=-2.493"),
(False, "","BUN 48h", "20.21 (6.41)","23.10 (7.72)","Indep. t-test","0.014","YES","Median: MICS=19.5 | Conv=23.3 | t(148)=-2.493"),
(False, "","Creatinine Change Ξ48h", "0.26 (0.52)","0.76 (1.02)","Mann-Whitney U","< 0.001","YES","3Γ less rise in MICS | U=1570"),
(False, "","Creatinine Ratio 48h", "1.28 (0.55)","1.69 (1.03)","Mann-Whitney U","< 0.001","YES","Lower relative rise in MICS | U=1786"),
(True, "SECTION 5: CATEGORICAL RENAL PARAMETERS AT 48H","","","","","",""),
(False, "Categorical","eGFR β₯ 60 mL/min", "33 (44.0%)","13 (17.3%)","Chi-square","< 0.001","YES","2.5Γ more MICS patients with normal GFR"),
(False, "","eGFR < 60 mL/min", "30 (40.0%)","56 (74.7%)","Chi-square","< 0.001","YES","1.9Γ more conventional with reduced GFR"),
(False, "","BUN < 24 mg/dL (normal)", "56 (74.7%)","40 (53.3%)","Chi-square","0.019", "YES","More MICS patients in normal BUN range"),
(False, "","Urea > 60 mg/dL (elevated)", "10 (13.3%)","19 (25.3%)","Chi-square","0.017", "YES","Higher elevation in conventional group"),
(False, "","Low Urine Output", "12 (16.0%)","18 (24.0%)","Chi-square","0.307", "No", "No significant group difference"),
(True, "SECTION 6: RISK FACTORS FOR AKI","","","","","",""),
(False, "Risk","Low Urine Output", "OR = 11.0", "β","Chi-square","< 0.001","YES","Strongest independent predictor of AKI"),
(False, "","Conventional Sternotomy", "OR = 5.88", "β","Chi-square","< 0.001","YES","Surgical approach is a significant risk factor"),
(False, "","Diabetes Mellitus", "OR = 1.13", "β","Chi-square","0.902", "No", "Not an independent risk factor"),
(False, "","Hypertension", "OR = 0.0", "β","Chi-square","0.171", "No", "Not an independent risk factor"),
(False, "","CKD", "OR = 0.90", "β","Chi-square","1.000", "No", "Not an independent risk factor"),
(False, "","Smoking", "OR = 1.31", "β","Chi-square","0.621", "No", "Not an independent risk factor"),
(False, "","Male Gender", "OR = 0.79", "β","Chi-square","0.873", "No", "Not an independent risk factor"),
]
r4 = 4
alt = False
for row in summary_rows:
is_sec = row[0]
if is_sec:
ws4.merge_cells(start_row=r4, start_column=1, end_row=r4, end_column=8)
c = ws4.cell(row=r4, column=1, value=row[1])
c.fill = fl("BDD7EE"); c.font = fn(bold=True, sz=11, color="1F4E79")
c.alignment = al("center","center"); c.border = bd()
ws4.row_dimensions[r4].height = 22
alt = False
else:
_, dom, var, mi, conv, test, p, sig, finding = row
row_bg = SIG if sig=="YES" else (ALT1 if alt else ALT2)
alt = not alt
vals = [dom, var, mi, conv, test, p, sig, finding]
for ci, val in enumerate(vals, 1):
c = ws4.cell(row=r4, column=ci, value=val)
c.border = bd()
c.alignment = al("left" if ci in (1,2,8) else "center","center")
if ci == 7:
if sig == "YES":
c.fill = fl("70AD47"); c.font = fn(bold=True, sz=10, color="FFFFFF")
else:
c.fill = fl("F2F2F2"); c.font = fn(sz=10, color="595959")
elif ci == 6:
c.fill = fl(row_bg); c.font = fn(bold=(sig=="YES"), sz=10,
color="C00000" if sig=="YES" else "000000")
elif ci == 8:
c.fill = fl(row_bg); c.font = fn(italic=True, sz=9, color="303030")
else:
c.fill = fl(row_bg); c.font = fn(sz=10)
ws4.row_dimensions[r4].height = 18
r4 += 1
set_col_widths(ws4, {"A":14,"B":30,"C":20,"D":20,"E":20,"F":12,"G":13,"H":48})
ws4.page_setup.orientation = "landscape"; ws4.page_setup.fitToPage = True; ws4.page_setup.fitToWidth = 1
# ββ Save via BytesIO ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
OUT = "/home/daytona/workspace/AKI_Complete_Results.xlsx"
buf = io.BytesIO()
wb.save(buf); buf.seek(0)
with open(OUT, 'wb') as f: f.write(buf.read())
print(f"Saved: {OUT} ({os.path.getsize(OUT):,} bytes)")
print(f"Sheets: {[s.title for s in wb.worksheets]}")
cd /home/daytona/workspace && python3 build_complete_xlsx.py 2>&1
python3 -c " import openpyxl wb = openpyxl.load_workbook('/home/daytona/workspacβ¦
AKI Complete Results
Spreadsheet Β· XLSX
word me hi eter krn tha an
~/build_ch4_word_final.py
"""
Append missing sections to Chapter 4 docx:
- Table 4.2 Descriptive Statistics (Mean, Median, SD, Min, Max, Q1, Q3, Skewness) β total + by group
- Table 4.3 Normality Tests (Shapiro-Wilk)
- Figures 4.14β4.25 (postop renal, BUN/Urea/eGFR, Early AKI, AKI Stage)
- Table 4.4 Primary Outcome AKI
- Table 4.5 AKI Stage Distribution
- Table 4.6 Serial Renal Parameters
- Table 4.7 Categorical Renal Parameters
- Table 4.8 Risk Factors
All appended AFTER the existing baseline section.
"""
import sys, io, os
sys.path.insert(0, '/home/daytona/.local/lib/python3.14/site-packages')
from docx import Document
from docx.shared import Inches, Pt, RGBColor, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
SRC = "/home/daytona/workspace/attachments/e1ed21b1-9df5-4ebe-ba40-ce1247598cb8/correct chapter 4.docx"
FIGS = "/home/daytona/workspace/AKI_Results/01_Figures/Descriptive/"
OUT = "/home/daytona/workspace/Chapter4_Final.docx"
doc = Document(SRC)
# ββ helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def _qn(tag):
prefix, local = tag.split(':')
ns = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
return f"{{{ns[prefix]}}}{local}"
def add_borders(table):
for tc in table._tbl.iter_tcs():
tcPr = tc.get_or_add_tcPr()
for ex in tcPr.findall(_qn('w:tcBorders')):
tcPr.remove(ex)
tcBorders = OxmlElement('w:tcBorders')
for side in ('top','left','bottom','right','insideH','insideV'):
b = OxmlElement(f'w:{side}')
b.set(_qn('w:val'), 'single')
b.set(_qn('w:sz'), '4')
b.set(_qn('w:space'), '0')
b.set(_qn('w:color'), '2C5F8A')
tcBorders.append(b)
tcW = tcPr.findall(_qn('w:tcW'))
idx = list(tcPr).index(tcW[-1]) + 1 if tcW else 0
tcPr.insert(idx, tcBorders)
def shade(cell, hex6):
tc = cell._tc; tcPr = tc.get_or_add_tcPr()
for s in tcPr.findall(_qn('w:shd')): tcPr.remove(s)
shd = OxmlElement('w:shd')
shd.set(_qn('w:val'), 'clear'); shd.set(_qn('w:color'), 'auto')
shd.set(_qn('w:fill'), hex6)
tcW = tcPr.findall(_qn('w:tcW'))
idx = list(tcPr).index(tcW[-1]) + 1 if tcW else 0
tcPr.insert(idx, shd)
def set_cell(cell, text, bold=False, italic=False, size=9,
align=WD_ALIGN_PARAGRAPH.CENTER, color=None):
cell.text = ""
p = cell.paragraphs[0]; p.alignment = align
p.paragraph_format.space_before = Pt(1)
p.paragraph_format.space_after = Pt(1)
r = p.add_run(str(text)); r.bold = bold; r.italic = italic
r.font.size = Pt(size)
if color: r.font.color.rgb = RGBColor(*color)
def heading(doc, text, level=2):
p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(12)
p.paragraph_format.space_after = Pt(4)
r = p.add_run(text); r.bold = True
r.font.size = Pt(13 if level == 1 else 12)
return p
def body(doc, text):
p = doc.add_paragraph(text)
for r in p.runs: r.font.size = Pt(11)
p.paragraph_format.space_after = Pt(6)
return p
def note(doc, text):
p = doc.add_paragraph()
p.paragraph_format.space_after = Pt(8)
r1 = p.add_run("Note: "); r1.bold = True; r1.font.size = Pt(10)
r2 = p.add_run(text); r2.font.size = Pt(10)
def tbl_cap(doc, num, text):
p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(8)
r = p.add_run(f"Table {num} {text}")
r.bold = True; r.font.size = Pt(11)
def fig(doc, path, num, caption, note_text=None, w=5.5):
p = doc.add_paragraph(); p.alignment = WD_ALIGN_PARAGRAPH.CENTER
p.add_run().add_picture(path, width=Inches(w))
pc = doc.add_paragraph(); pc.alignment = WD_ALIGN_PARAGRAPH.CENTER
rc = pc.add_run(f"Figure {num} {caption}")
rc.italic = True; rc.font.size = Pt(10)
if note_text: note(doc, note_text)
def build_table(doc, headers, rows,
hdr_bg="1F4E79", alt_bg="D6E4F0", sig_bg="E2EFDA"):
t = doc.add_table(rows=len(rows)+1, cols=len(headers))
t.alignment = WD_TABLE_ALIGNMENT.CENTER
# header
for ci, h in enumerate(headers):
shade(t.rows[0].cells[ci], hdr_bg)
set_cell(t.rows[0].cells[ci], h, bold=True, size=9,
align=WD_ALIGN_PARAGRAPH.CENTER, color=(255,255,255))
# data
for ri, row_data in enumerate(rows):
row = t.rows[ri+1]
sig = str(row_data[-1]) if row_data else ""
bg = sig_bg if sig == "YES" else (alt_bg if ri % 2 == 1 else "FFFFFF")
for ci, val in enumerate(row_data):
al = WD_ALIGN_PARAGRAPH.LEFT if ci == 0 else WD_ALIGN_PARAGRAPH.CENTER
shade(row.cells[ci], bg)
set_cell(row.cells[ci], val, size=9, align=al)
add_borders(t)
doc.add_paragraph() # spacing
return t
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 2 β Descriptive Statistics of Continuous Variables
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Descriptive Statistics of Continuous Variables")
body(doc,
"Table 4.2 presents the descriptive statistics of all continuous variables for the total sample "
"and stratified by surgical group. Measures include mean, standard deviation (SD), median, "
"interquartile range (Q1βQ3), minimum, maximum, and skewness.")
tbl_cap(doc, "4.2",
"Descriptive Statistics of Continuous Variables β Total Sample and by Surgical Group")
desc_headers = ["Variable", "Group", "N", "Mean", "SD",
"Min", "Q1 (25th)", "Median", "Q3 (75th)", "Max", "Skewness"]
desc_rows = [
# Baseline Creatinine
["Baseline Creatinine (mg/dL)", "Total (N=150)", "150", "1.08", "0.32", "0.50", "0.83", "1.07", "1.26", "1.88", "0.295"],
["", "MICS-CABG (n=75)", "75", "1.00", "0.25", "0.50", "0.84", "0.99", "1.11", "1.63", "β"],
["", "Conventional (n=75)", "75", "1.16", "0.37", "0.50", "0.93", "1.17", "1.37", "1.88", "β"],
# Baseline eGFR
["Baseline eGFR (mL/min/1.73mΒ²)", "Total (N=150)", "150", "75.70", "23.34", "35.5", "59.05", "72.90", "92.88", "130.0", "0.217"],
["", "MICS-CABG (n=75)", "75", "80.37", "21.75", "36.8", "62.00", "79.90", "96.00", "130.0", "β"],
["", "Conventional (n=75)", "75", "71.04", "24.08", "35.5", "51.10", "67.10", "88.50", "118.8", "β"],
# LVEF
["LVEF (%)", "Total (N=150)", "150", "50.09", "9.09", "28.2", "43.45", "50.25", "56.18", "75.0", "0.200"],
["", "MICS-CABG (n=75)", "75", "50.80", "9.70", "28.4", "43.20", "50.70", "59.40", "75.0", "β"],
["", "Conventional (n=75)", "75", "49.39", "8.43", "28.2", "42.90", "50.00", "55.00", "67.6", "β"],
# Haemoglobin
["Preop Haemoglobin (g/dL)", "Total (N=150)", "150", "13.35", "1.49", "9.4", "12.30", "13.40", "14.10", "16.9", "0.238"],
["", "MICS-CABG (n=75)", "75", "13.50", "1.46", "10.1", "12.50", "13.40", "14.50", "16.6", "β"],
["", "Conventional (n=75)", "75", "13.19", "1.51", "9.4", "12.10", "13.00", "14.00", "16.9", "β"],
# Creatinine 24h
["Creatinine 24h (mg/dL)", "Total (N=150)", "150", "1.248", "0.377", "0.57", "1.00", "1.19", "1.50", "2.42", "0.652"],
["", "MICS-CABG (n=75)", "75", "1.115", "0.278", "0.58", "0.91", "1.08", "1.29", "2.07", "β"],
["", "Conventional (n=75)", "75", "1.380", "0.416", "0.57", "1.10", "1.35", "1.58", "2.42", "β"],
# Creatinine 48h
["Creatinine 48h (mg/dL)", "Total (N=150)", "150", "1.589", "0.966", "0.64", "1.04", "1.315", "1.73", "6.54", "2.539"],
["", "MICS-CABG (n=75)", "75", "1.261", "0.579", "0.64", "0.97", "1.14", "1.30", "4.22", "β"],
["", "Conventional (n=75)", "75", "1.917", "1.151", "0.65", "1.20", "1.56", "2.16", "6.54", "β"],
# Creatinine 72h
["Creatinine 72h (mg/dL)", "Total (N=150)", "150", "1.518", "0.908", "0.47", "0.98", "1.24", "1.68", "6.27", "2.394"],
["", "MICS-CABG (n=75)", "75", "1.207", "0.558", "0.47", "0.90", "1.10", "1.33", "3.76", "β"],
["", "Conventional (n=75)", "75", "1.829", "1.073", "0.59", "1.17", "1.56", "2.06", "6.27", "β"],
# eGFR 48h
["eGFR 48h (mL/min/1.73m\u00b2)", "Total (N=150)", "150", "58.13", "25.23", "8.4", "39.30", "57.60", "75.55", "118.9", "0.123"],
["", "MICS-CABG (n=75)", "75", "67.67", "22.68", "13.6", "51.90", "67.00", "84.20", "118.9", "β"],
["", "Conventional (n=75)", "75", "48.59", "24.14", "8.4", "31.20", "46.90", "63.60", "112.4", "β"],
# BUN 48h
["BUN 48h (mg/dL)", "Total (N=150)", "150", "21.65", "7.22", "9.3", "17.03", "21.25", "26.40", "43.4", "0.291"],
["", "MICS-CABG (n=75)", "75", "20.21", "6.41", "9.3", "15.80", "19.50", "24.40", "37.7", "β"],
["", "Conventional (n=75)", "75", "23.10", "7.72", "9.3", "18.20", "23.30", "27.70", "43.4", "β"],
# Urea 48h
["Urea 48h (mg/dL)", "Total (N=150)", "150", "46.34", "15.44", "20.0", "36.35", "45.45", "56.55", "92.9", "0.292"],
["", "MICS-CABG (n=75)", "75", "43.25", "13.72", "20.0", "33.85", "41.70", "52.30", "80.7", "β"],
["", "Conventional (n=75)", "75", "49.43", "16.51", "20.0", "39.00", "49.90", "59.35", "92.9", "β"],
]
# Build the table with group-band shading
t = doc.add_table(rows=len(desc_rows)+1, cols=len(desc_headers))
t.alignment = WD_TABLE_ALIGNMENT.CENTER
for ci, h in enumerate(desc_headers):
shade(t.rows[0].cells[ci], "1F4E79")
set_cell(t.rows[0].cells[ci], h, bold=True, size=9,
align=WD_ALIGN_PARAGRAPH.CENTER, color=(255,255,255))
# Group every 3 rows in alternating colours
group_colors = ["F5FAFF", "E2EFDA"]
for ri, row_data in enumerate(desc_rows):
row = t.rows[ri+1]
group = ri // 3
bg = group_colors[group % 2]
is_total = "Total" in str(row_data[1])
for ci, val in enumerate(row_data):
al = WD_ALIGN_PARAGRAPH.LEFT if ci in (0,1) else WD_ALIGN_PARAGRAPH.CENTER
shade(row.cells[ci], bg)
set_cell(row.cells[ci], val, bold=is_total, size=9, align=al)
add_borders(t)
doc.add_paragraph()
note(doc,
"Values shown as Mean, SD, Median (50th percentile), Q1 (25th percentile), "
"Q3 (75th percentile). Skewness reported for total sample only. "
"MICS-CABG = Minimally Invasive Cardiac Surgery-CABG. "
"Bold rows = total sample statistics.")
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 3 β Normality Tests
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Assessment of Normality β Shapiro-Wilk Test")
body(doc,
"Prior to selecting parametric or non-parametric tests for group comparisons, "
"normality of continuous variables was assessed using the Shapiro-Wilk test for each group "
"separately (n=75 per group). A p-value < 0.05 indicated significant departure from normality, "
"warranting the use of Mann-Whitney U test. Variables meeting normality in both groups were "
"analysed using the independent samples t-test. Results are presented in Table 4.3.")
tbl_cap(doc, "4.3",
"Shapiro-Wilk Normality Test Results for Continuous Variables by Surgical Group")
build_table(doc,
["Variable",
"MICS-CABG\nW-stat", "MICS-CABG\np-value", "MICS-CABG\nNormal?",
"Conventional\nW-stat", "Conventional\np-value", "Conventional\nNormal?",
"Test Used"],
[
["Baseline Creatinine (mg/dL)", "0.985","0.545","Yes","0.971","0.078","Yes","Indep. t-test"],
["Baseline eGFR (mL/min/1.73m\u00b2)","0.985","0.502","Yes","0.947","0.003","No", "Mann-Whitney U"],
["LVEF (%)", "0.984","0.456","Yes","0.993","0.966","Yes","Indep. t-test"],
["Preop Haemoglobin (g/dL)", "0.977","0.191","Yes","0.989","0.792","Yes","Indep. t-test"],
["Creatinine 24h (mg/dL)", "0.959","0.016","No", "0.984","0.461","Yes","Mann-Whitney U"],
["Creatinine 48h (mg/dL)", "0.653","<0.001","No","0.787","<0.001","No","Mann-Whitney U"],
["Creatinine 72h (mg/dL)", "0.661","<0.001","No","0.810","<0.001","No","Mann-Whitney U"],
["BUN 48h (mg/dL)", "0.969","0.060","Yes","0.977","0.200","Yes","Indep. t-test"],
["Urea 48h (mg/dL)", "0.969","0.059","Yes","0.977","0.192","Yes","Indep. t-test"],
["eGFR 48h (mL/min/1.73m\u00b2)", "0.992","0.914","Yes","0.972","0.098","Yes","Indep. t-test"],
["Creatinine Change \u039448h", "0.404","<0.001","No","0.696","<0.001","No","Mann-Whitney U"],
["Creatinine Ratio 48h", "0.412","<0.001","No","0.608","<0.001","No","Mann-Whitney U"],
],
hdr_bg="1F4E79", alt_bg="D6E4F0", sig_bg="FFFFFF"
)
note(doc,
"Shapiro-Wilk test: p < 0.05 indicates non-normal distribution. "
"Normal? = Yes if p \u2265 0.05 (normal distribution). "
"Mann-Whitney U test was used when either group was non-normal. "
"Independent samples t-test was used when both groups were normally distributed.")
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 4 β Postoperative Renal Parameters (Figures)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Postoperative Renal Function Parameters")
body(doc,
"Serial postoperative serum creatinine was measured at 24, 48, and 72 hours for all 150 patients. "
"BUN, serum urea, and eGFR at 48 hours were also recorded. "
"Figures 4.14β4.23 show the distribution of these parameters for the total sample and by group.")
fig(doc, FIGS+"DESC_Q14_Creatinine_24h_Histogram.png",
"4.14", "Serum Creatinine Distribution at 24 Hours Postoperatively (N=150).",
"Mean = 1.248 mg/dL (SD=0.377). MICS-CABG: Mean=1.115, Median=1.08. "
"Conventional: Mean=1.380, Median=1.35. Mann-Whitney U, p < 0.001.", w=5.5)
fig(doc, FIGS+"DESC_Q15_Creatinine_48h_Histogram.png",
"4.15", "Serum Creatinine Distribution at 48 Hours Postoperatively (N=150).",
"Mean = 1.589 mg/dL (SD=0.966). MICS-CABG: Mean=1.261, Median=1.14. "
"Conventional: Mean=1.917, Median=1.56. Mann-Whitney U, p < 0.001.", w=5.5)
fig(doc, FIGS+"DESC_Q16_Creatinine_72h_Histogram.png",
"4.16", "Serum Creatinine Distribution at 72 Hours Postoperatively (N=150).",
"Mean = 1.518 mg/dL (SD=0.908). MICS-CABG: Mean=1.207, Median=1.10. "
"Conventional: Mean=1.829, Median=1.56. Mann-Whitney U, p < 0.001.", w=5.5)
fig(doc, FIGS+"DESC_Q17_Low_Urine_Output.png",
"4.17", "Low Urine Output Distribution in Study Population (N=150).",
"Low urine output observed in 16.0% MICS-CABG vs 24.0% Conventional patients. "
"Overall prevalence = 20.0%. Chi-square p = 0.307 (not significant).", w=4.0)
fig(doc, FIGS+"DESC_Q19_BUN_48h_Histogram.png",
"4.18", "BUN at 48 Hours Distribution (N=150).",
"Total Mean = 21.65 mg/dL (SD=7.22), Median=21.25. "
"MICS-CABG: Mean=20.21, Median=19.50. Conventional: Mean=23.10, Median=23.30. "
"Independent t-test, p = 0.014.", w=5.5)
fig(doc, FIGS+"DESC_Q19_BUN_Category.png",
"4.19", "BUN Category Distribution at 48 Hours (N=150).",
"74.7% of MICS-CABG vs 53.3% of Conventional patients had BUN < 24 mg/dL (normal). "
"Chi-square = 7.912, p = 0.019.", w=4.0)
fig(doc, FIGS+"DESC_Q20_Urea_48h_Histogram.png",
"4.20", "Serum Urea at 48 Hours Distribution (N=150).",
"Total Mean = 46.34 mg/dL (SD=15.44), Median=45.45. "
"MICS-CABG: Mean=43.25, Median=41.70. Conventional: Mean=49.43, Median=49.90. "
"Independent t-test, p = 0.014.", w=5.5)
fig(doc, FIGS+"DESC_Q20_Urea_Category.png",
"4.21", "Urea Category Distribution at 48 Hours (N=150).",
"25.3% of Conventional vs 13.3% of MICS-CABG patients had Urea > 60 mg/dL. "
"Chi-square = 8.186, p = 0.017.", w=4.0)
fig(doc, FIGS+"DESC_Q21_eGFR_48h_Histogram.png",
"4.22", "eGFR at 48 Hours Distribution (N=150).",
"Total Mean = 58.13 mL/min/1.73m\u00b2 (SD=25.23), Median=57.60. "
"MICS-CABG: Mean=67.67, Median=67.00. Conventional: Mean=48.59, Median=46.90. "
"Independent t-test, p < 0.001.", w=5.5)
fig(doc, FIGS+"DESC_Q21_eGFR_Category.png",
"4.23", "eGFR Category Distribution at 48 Hours (N=150).",
"44.0% MICS-CABG vs 17.3% Conventional maintained eGFR \u226560 mL/min/1.73m\u00b2. "
"74.7% Conventional vs 40.0% MICS-CABG had eGFR < 60. Chi-square = 18.556, p < 0.001.", w=4.0)
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 5 β Comparison of Serial Renal Parameters (Table 4.4)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Comparison of Serial Postoperative Renal Parameters Between Groups")
body(doc,
"Table 4.4 presents the inferential comparison of postoperative renal parameters between "
"the two surgical groups. Normality-based test selection was applied as determined by "
"Shapiro-Wilk results in Table 4.3.")
tbl_cap(doc, "4.4", "Comparison of Serial Postoperative Renal Parameters")
build_table(doc,
["Variable",
"MICS-CABG\nMean (SD)\nMedian",
"Conventional\nMean (SD)\nMedian",
"Statistical Test", "Test Statistic", "p-value", "Significant?"],
[
["Creatinine 24h (mg/dL)", "1.12 (0.28)\nMedian=1.08", "1.38 (0.42)\nMedian=1.35", "Mann-Whitney U", "U=1611.0", "< 0.001","YES"],
["Creatinine 48h (mg/dL)", "1.26 (0.58)\nMedian=1.14", "1.92 (1.15)\nMedian=1.56", "Mann-Whitney U", "U=1452.5", "< 0.001","YES"],
["Creatinine 72h (mg/dL)", "1.21 (0.56)\nMedian=1.10", "1.83 (1.07)\nMedian=1.56", "Mann-Whitney U", "U=1472.0", "< 0.001","YES"],
["eGFR 48h (mL/min/1.73m\u00b2)","67.67 (22.68)\nMedian=67.0","48.59 (24.14)\nMedian=46.9","Indep. t-test", "t(148)=4.988","< 0.001","YES"],
["Urea 48h (mg/dL)", "43.25 (13.72)\nMedian=41.7","49.43 (16.51)\nMedian=49.9","Indep. t-test", "t(148)=\u22122.493","0.014","YES"],
["BUN 48h (mg/dL)", "20.21 (6.41)\nMedian=19.5","23.10 (7.72)\nMedian=23.3","Indep. t-test", "t(148)=\u22122.493","0.014","YES"],
["Creatinine Change \u039448h", "0.26 (0.52)", "0.76 (1.02)", "Mann-Whitney U", "U=1570.0", "< 0.001","YES"],
["Creatinine Ratio 48h", "1.28 (0.55)", "1.69 (1.03)", "Mann-Whitney U", "U=1786.0", "< 0.001","YES"],
])
note(doc,
"All comparisons statistically significant (p \u2264 0.014). "
"Mann-Whitney U used for non-normally distributed variables (Creatinine 24/48/72h, "
"\u0394Creatinine, Creatinine Ratio). Independent t-test used for BUN, Urea, eGFR 48h "
"(normally distributed in both groups). "
"MICS-CABG consistently showed lower creatinine and higher eGFR across all time points.")
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 6 β Primary Outcome: AKI
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Primary Outcome: Incidence of Acute Kidney Injury")
body(doc,
"The primary outcome was early AKI incidence defined per KDIGO criteria. "
"AKI was identified in 46 of 150 patients (30.7%) overall. "
"Table 4.5 compares AKI incidence between groups.")
tbl_cap(doc, "4.5", "Comparison of AKI Incidence Between Surgical Groups")
build_table(doc,
["Group","AKI Yes n (%)","AKI No n (%)","Chi-square","df","p-value","Significant?"],
[
["MICS-CABG (n=75)", "10 (13.3%)","65 (86.7%)","19.597","1","< 0.001","YES"],
["Conventional (n=75)", "36 (48.0%)","39 (52.0%)","","","",""],
["Total (n=150)", "46 (30.7%)","104 (69.3%)","","","",""],
])
note(doc,
"Chi-square = 19.597, df = 1, p < 0.001. AKI occurred in 13.3% of MICS-CABG patients "
"vs 48.0% of Conventional Sternotomy patients β a 3.6-fold higher risk with conventional approach.")
fig(doc, FIGS+"DESC_Q22_Early_AKI.png",
"4.24", "Comparison of Early AKI Incidence Between Surgical Groups (N=150).",
"Bar chart showing 13.3% AKI incidence in MICS-CABG group vs 48.0% in Conventional group. "
"The difference is statistically significant (Chi-square=19.597, p < 0.001).", w=4.5)
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 7 β AKI Stage Distribution
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "AKI Stage Distribution (KDIGO Criteria)")
body(doc,
"Among all 150 patients, AKI severity was staged per KDIGO criteria. "
"Table 4.6 and Figure 4.25 show the distribution of AKI stages across both surgical groups.")
tbl_cap(doc, "4.6", "AKI Stage Distribution by Surgical Group")
build_table(doc,
["AKI Stage","MICS-CABG n (%)","Conventional n (%)","Total n (%)","Chi-square","p-value","Significant?"],
[
["No AKI", "65 (86.7%)","39 (52.0%)","104 (69.3%)","21.533","< 0.001","YES"],
["Stage 1", "7 (9.3%)", "23 (30.7%)","30 (20.0%)", "", "", "YES"],
["Stage 2", "1 (1.3%)", "7 (9.3%)", "8 (5.3%)", "", "", "YES"],
["Stage 3", "2 (2.7%)", "6 (8.0%)", "8 (5.3%)", "", "", "YES"],
])
note(doc,
"Chi-square = 21.533, p < 0.001. Stage 1 was the most common AKI stage in both groups. "
"Severe AKI (Stage 2+3) occurred in 17.3% of Conventional vs 4.0% of MICS-CABG patients.")
fig(doc, FIGS+"DESC_Q23_AKI_Stage.png",
"4.25", "AKI Stage Distribution Between Surgical Groups (N=150).",
"Conventional group had higher proportions of all AKI stages: Stage 1=30.7%, "
"Stage 2=9.3%, Stage 3=8.0% vs MICS-CABG: Stage 1=9.3%, Stage 2=1.3%, Stage 3=2.7%.", w=4.5)
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 8 β Categorical Renal Parameters (Table 4.7)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Comparison of Categorical Renal Parameters at 48 Hours")
body(doc,
"Renal function parameters at 48 hours were further classified into clinically defined "
"categories and compared between groups using Chi-square tests (Table 4.7).")
tbl_cap(doc, "4.7", "Comparison of Categorical Renal Parameters at 48 Hours")
build_table(doc,
["Variable","MICS-CABG n (%)","Conventional n (%)","Chi-square","df","p-value","Significant?"],
[
["BUN < 24 mg/dL (normal)", "56 (74.7%)","40 (53.3%)","7.912","2","0.019","YES"],
["BUN 24\u201340 mg/dL", "19 (25.3%)","34 (45.3%)","", "", "0.019","YES"],
["BUN > 40 mg/dL", "0 (0.0%)", "1 (1.3%)", "", "", "0.019","YES"],
["Urea 40\u201350 mg/dL", "55 (73.3%)","38 (50.7%)","8.186","2","0.017","YES"],
["Urea 50\u201360 mg/dL", "10 (13.3%)","18 (24.0%)","", "", "0.017","YES"],
["Urea > 60 mg/dL", "10 (13.3%)","19 (25.3%)","", "", "0.017","YES"],
["eGFR \u226590 mL/min", "0 (0.0%)", "0 (0.0%)", "18.556","2","< 0.001","YES"],
["eGFR 60\u201389 mL/min", "33 (44.0%)","13 (17.3%)","", "", "< 0.001","YES"],
["eGFR < 60 mL/min", "30 (40.0%)","56 (74.7%)","", "", "< 0.001","YES"],
["Low Urine Output: Yes", "12 (16.0%)","18 (24.0%)","1.042","1","0.307","No"],
["Low Urine Output: No", "63 (84.0%)","57 (76.0%)","", "", "0.307","No"],
])
note(doc,
"Significant group differences found for BUN (p=0.019), Urea (p=0.017), and eGFR (p<0.001) categories. "
"Low urine output showed no significant difference between groups (p=0.307).")
doc.add_page_break()
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# SECTION 9 β Risk Factors (Table 4.8)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
heading(doc, "Risk Factors Associated with Acute Kidney Injury")
body(doc,
"To identify independent risk factors for AKI, potential clinical predictors were "
"analysed using Chi-square tests and odds ratio estimation. Table 4.8 presents results "
"for all evaluated risk factors.")
tbl_cap(doc, "4.8", "Risk Factors Associated with AKI Development β Odds Ratio Analysis")
build_table(doc,
["Risk Factor","AKI Yes n (%)","AKI No n (%)","Odds Ratio","Chi-square","p-value","Significant?"],
[
["Low Urine Output", "22 (47.8%)","8 (7.7%)", "11.0","29.648","< 0.001","YES"],
["Conventional Surgery", "36 (78.3%)","39 (37.5%)", "5.88","19.597","< 0.001","YES"],
["Diabetes Mellitus", "14 (30.4%)","29 (27.9%)", "1.13","0.015", "0.902", "No"],
["Hypertension", "44 (95.7%)","104 (100.0%)","0.0", "1.874", "0.171", "No"],
["Chronic Kidney Disease", "4 (8.7%)", "10 (9.6%)", "0.90","0.0", "1.000", "No"],
["Smoking", "14 (30.4%)","26 (25.0%)", "1.31","0.244", "0.621", "No"],
["Male Gender", "40 (87.0%)","93 (89.4%)", "0.79","0.026", "0.873", "No"],
])
note(doc,
"Only two factors were statistically significant: low urine output (OR=11.0, p<0.001) "
"and conventional surgical approach (OR=5.88, p<0.001). "
"Traditional comorbidities including diabetes, hypertension, CKD, smoking, and male gender "
"were not independent predictors of AKI in this cohort.")
# ββ Save via buffer ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
buf = io.BytesIO()
doc.save(buf); buf.seek(0)
with open(OUT, 'wb') as f: f.write(buf.read())
print(f"Saved: {OUT} ({os.path.getsize(OUT):,} bytes)")
cd /home/daytona/workspace && python3 build_ch4_word_final.py 2>&1
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksβ¦
Chapter4 Final
Word Document Β· DOCX
| # | Table/Figure | Content |
|---|---|---|
| Existing | Table 4.1 + Fig 4.1β4.13 | Baseline Demographics |
| NEW | Table 4.2 | Descriptive Statistics - Mean, SD, Median, Q1, Q3, Min, Max, Skewness - Total + By Group |
| NEW | Table 4.3 | Shapiro-Wilk Normality Test - W-stat, p-value, Normal? for each variable per group |
| NEW | Fig 4.14β4.23 | Postop Creatinine 24/48/72h, Low Urine Output, BUN, Urea, eGFR histograms + category charts |
| NEW | Table 4.4 | Serial Renal Comparison - Mean(SD) + Median + Test Statistic + p-value |
| NEW | Table 4.5 | Primary Outcome - AKI Incidence |
| NEW | Fig 4.24 | Early AKI bar chart |
| NEW | Table 4.6 | AKI KDIGO Staging |
| NEW | Fig 4.25 | AKI Stage distribution chart |
| NEW | Table 4.7 | Categorical Renal Parameters |
| NEW | Table 4.8 | Risk Factors (Odds Ratios) |
mery zip mee se add kiye h na sary table
echo "=== ALL TABLES IN ZIP ===" && ls /home/daytona/workspace/AKI_Results/02_Taβ¦
python3 -c " import os tables = sorted(os.listdir('/home/daytona/workspace/AKI_Rβ¦
python3 -c " import csv, os BASE = '/home/daytona/workspace/AKI_Results/02_Tablβ¦
| Zip File | Status in Word |
|---|---|
| COMP_Table1 (Baseline - continuous vars with p-values) | β MISS - Existing docx mein partial tha, Creatinine p=0.002 aur eGFR p=0.013 significant hain - ye properly nahi tha |
| DESC_Q02-Q08, Q11b, Q13 (baseline figures) | β Already in original docx (Fig 4.1-4.13) |
| DESC DescStats + ByGroup tables | β Added as Table 4.2 |
| Table_Normality_Tests | β Added as Table 4.3 |
| DESC_Q14-Q17, Q19-Q21 figures | β Added Fig 4.14-4.23 |
| COMP_Table2-6 | β Added as Tables 4.4-4.8 |
| DESC_Q22-Q23 figures | β Added Fig 4.24-4.25 |
Replace Table 4.1 in Chapter 4 with corrected COMP_Table1 that shows p-values (including significant baseline Cr and eGFR)
python3 -c " import sys sys.path.insert(0, '/home/daytona/.local/lib/python3.14/β¦
python3 -c " import sys sys.path.insert(0, '/home/daytona/.local/lib/python3.14/β¦
python3 - << 'PYEOF' import sys, io, os sys.path.insert(0, '/home/daytona/.localβ¦
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksβ¦
python3 - << 'PYEOF' import zipfile, re, io, os src = "/home/daytona/workspace/β¦
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksβ¦
python3 - << 'PYEOF' import sys, io, os sys.path.insert(0, '/home/daytona/.localβ¦
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksβ¦
Chapter4 Final
Word Document Β· DOCX
| Section | Variables | Significant? |
|---|---|---|
| CATEGORICAL | Male Gender, DM, HTN, CKD, Smoking, Age groups, BMI categories, LVEF categories | All No |
| CONTINUOUS | Baseline Creatinine | YES - p=0.002 (t=-3.151) |
| Baseline eGFR | YES - p=0.013 (U=3476.5) | |
| LVEF % | No - p=0.344 | |
| Preop Haemoglobin | No - p=0.200 |
ap ne jo sd mean wgaira ki values di wo mmeri zip se exact match ni
python3 -c " import csv, os BASE = '/home/daytona/workspace/AKI_Results/02_Tableβ¦
python3 - << 'PYEOF' import sys, io, os sys.path.insert(0, '/home/daytona/.localβ¦
python3 /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/worksβ¦
Chapter4 Final
Word Document Β· DOCX
| Variable | Total Mean (SD) | MICS Median | Conv Median |
|---|---|---|---|
| Baseline Creatinine | 1.08 (0.322) | 0.99 | 1.17 |
| Baseline eGFR | 75.703 (23.341) | 79.9 | 67.1 |
| LVEF | 50.091 (9.085) | 50.7 | 50.0 |
| Haemoglobin | 13.348 (1.488) | 13.4 | 13.0 |
| Creatinine 24h | 1.248 (0.377) | 1.08 | 1.35 |
| Creatinine 48h | 1.589 (0.966) | 1.14 | 1.56 |
| Creatinine 72h | 1.518 (0.908) | 1.14 | 1.59 |
| eGFR 48h | 58.131 (25.228) | 67.0 | 46.9 |
| BUN 48h | 21.653 (7.217) | 19.5 | 23.3 |
| Urea 48h | 46.341 (15.439) | 41.7 | 49.9 |
1.208 (0.563) Cr 72h MICS aur 48.593 (24.143) eGFR Conv correct hain.ye dekhy surgical approach or descriptive ye ha or inhy lag se ni likhy gy
An error occurred (ValidationException) when calling the ConverseStream operation: The model returned the following errors: messages.20.content.2.image.source.base64.data: At least one of the image dimensions exceed max allowed size: 8000 pixels
We encountered an error while processing your request. Please try again or reach out to us for help.
ok
An error occurred (ValidationException) when calling the ConverseStream operation: The model returned the following errors: messages.20.content.2.image.source.base64.data: At least one of the image dimensions exceed max allowed size: 8000 pixels
We encountered an error while processing your request. Please try again or reach out to us for help.
ye dekhy meri zip file me ye saab pra howa jo ap abi tk add ni kiya
An error occurred (ValidationException) when calling the ConverseStream operation: The model returned the following errors: messages.20.content.1.image.source.base64.data: At least one of the image dimensions exceed max allowed size: 8000 pixels
We encountered an error while processing your request. Please try again or reach out to us for help.