Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 4 additions & 3 deletions papers/mfd_platform/figure_restoration/delivery_checks.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,23 @@
],
"design_table_rows_in_S6": 12,
"original_workbook_cells_and_styles_byte_identical": true,
"sheet1_provenance_note_updated_from_main_figure_3g": true,
"fabrication_comparison_approaches": 11,
"pdfs": [
{
"file": "MFD_original_figures_revised.pdf",
"pages": 18,
"sha256": "e525ff4bc01f8d80d3ede6fdf719a52a9ef9de486a5e7e21cededeeac1360cf4"
"sha256": "acae3ee84ca222ad65bb80cf593b913f0c40bc93e55a15a57d79abb950fd35c8"
},
{
"file": "Supplementary_Protocol_1_original_figures_revised.pdf",
"pages": 6,
"sha256": "53c58fe24c6d9170bb802a01471cde68a7db5fb05a414cd3fae53b5c6731bab9"
"sha256": "887748a23a67fc40a77a3a1aabd9ff4f15edb750dd6b3f7fe20c7e547d1df33d"
},
{
"file": "Supplementary_Protocol_2_original_figures_revised.pdf",
"pages": 5,
"sha256": "68ae62f76e23b4c153e62c883fadb3c9de4fcc3e4dd02c4a850591b102893859"
"sha256": "855f43c7ccb6a392e5505d99d301345767985128a51e3d6a32aa0b59893a93bb"
}
]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,34 @@
"scope": "Prose-only redline. Tristan original figures are fixed in both views. Full earlier comparison preserved.",
"original_text_unchanged_in_comparison_baseline": true,
"references_preserved": true,
"non_picture_revisions_identical_to_full_comparison": true,
"native_accept_all": "Final reading text and five final figures",
"native_reject_all": "Original Alyson prose and the SAME five final figures; artwork is intentionally not redlined",
"drawings": 5,
"image_revisions": 0,
"insertions": 59,
"deletions": 84,
"retained_inputs": {
"/home/ts/wt/mfd--81533fcd85c44f248fd19b12c53dec11--mfd/papers/mfd_platform/v14_tracked/MFD_V14_original.docx": "e7b757e2f11883a87656425e8302741626588430d36da79c8ee4f1489914790e",
"/home/ts/wt/mfd--81533fcd85c44f248fd19b12c53dec11--mfd/papers/mfd_platform/figure_restoration/MFD_original_figures_revised.docx": "d39abaa6671b6afec9861154312cc18687a555fcfce44d8023b35f1dfe0794e7",
"/home/ts/wt/mfd--81533fcd85c44f248fd19b12c53dec11--mfd/papers/mfd_platform/figure_restoration/MFD_original_figures_tracked.docx": "1a20de9b0da6e504e53da94f3a0444df5394b442eeb3dc36e439542a17e0e810",
"/home/ts/wt/mfd--81533fcd85c44f248fd19b12c53dec11--mfd/papers/mfd_platform/figure_restoration/MFD_original_figures_revised.pdf": "e525ff4bc01f8d80d3ede6fdf719a52a9ef9de486a5e7e21cededeeac1360cf4"
"/run/media/ts/nvme2/alyson-delivery-20261123/_work/OpenMFD/papers/mfd_platform/v14_tracked/MFD_V14_original.docx": "e7b757e2f11883a87656425e8302741626588430d36da79c8ee4f1489914790e",
"/run/media/ts/nvme2/alyson-delivery-20261123/_work/OpenMFD/papers/mfd_platform/figure_restoration/MFD_original_figures_revised.docx": "24fae97dd3861c27da6138cb82a7e0311d3e2deccc50635251b2f7165bbc38ee",
"/run/media/ts/nvme2/alyson-delivery-20261123/_work/OpenMFD/papers/mfd_platform/figure_restoration/MFD_original_figures_tracked.docx": "ce427689232ce164c8ff67195253dd7d75f2da4441df6839d82fde645dd71071",
"/run/media/ts/nvme2/alyson-delivery-20261123/_work/OpenMFD/papers/mfd_platform/figure_restoration/MFD_original_figures_revised.pdf": "acae3ee84ca222ad65bb80cf593b913f0c40bc93e55a15a57d79abb950fd35c8"
},
"files": [
{
"name": "MFD_for_Alyson_reading.docx",
"bytes": 11978755,
"sha256": "d39abaa6671b6afec9861154312cc18687a555fcfce44d8023b35f1dfe0794e7"
"bytes": 11978773,
"sha256": "24fae97dd3861c27da6138cb82a7e0311d3e2deccc50635251b2f7165bbc38ee"
},
{
"name": "MFD_for_Alyson_reading.pdf",
"bytes": 12579929,
"sha256": "e525ff4bc01f8d80d3ede6fdf719a52a9ef9de486a5e7e21cededeeac1360cf4"
"bytes": 8297633,
"sha256": "acae3ee84ca222ad65bb80cf593b913f0c40bc93e55a15a57d79abb950fd35c8"
},
{
"name": "MFD_for_Alyson_prose_redline.docx",
"bytes": 11776460,
"sha256": "2cba8be200829bae1e9af546db4168ffb6cc1041842412289a910551523bcb88"
"bytes": 11776459,
"sha256": "02375ce05dfcabfeaa285f516cca27de6d40d329aaa9a336b7c676b11437d96d"
}
],
"non_picture_revisions_identical_to_full_comparison": true,
"all_comment_texts_unchanged": 5
]
}
55 changes: 44 additions & 11 deletions papers/mfd_platform/figure_restoration/recipe/restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def change(self, anchor: str, old: str, new: str) -> None:
text = self.paragraph_text(paragraph)
if old not in text:
raise ValueError((anchor, old))
self.replace(text, text.replace(old, new), 'Match restored figure/table content')
# Replace only the changed words: replacing the whole paragraph text would
# pour it all into the first run, turning a bold run-in heading into a bold paragraph.
# Last occurrence first, so earlier positions stay valid.
for index in reversed(range(text.count(old))):
self.replace(old, new, 'Match restored figure/table content', paragraph=paragraph, occurrence=index)

def separate_images(self) -> None:
"""Use inline image paragraphs; floating anchors confuse native comparison."""
Expand All @@ -59,6 +63,13 @@ def separate_images(self) -> None:
def paragraph_node(self, text: str):
paragraph = self.document.createElementNS(W, 'w:p')
run = self.document.createElementNS(W, 'w:r')
# Match the document's Times New Roman; the theme default would substitute another face.
properties = self.document.createElementNS(W, 'w:rPr')
fonts = self.document.createElementNS(W, 'w:rFonts')
for key in ('ascii', 'hAnsi', 'cs'):
fonts.setAttributeNS(W, 'w:' + key, 'Times New Roman')
properties.appendChild(fonts)
run.appendChild(properties)
node = self.document.createElementNS(W, 'w:t')
node.appendChild(self.document.createTextNode(text))
run.appendChild(node)
Expand Down Expand Up @@ -132,9 +143,9 @@ def apply(self) -> None:
number = int(number)
caption = re.sub(r'^Figure \d+:', f'Fig. {number}.', caption).replace('**', '')
if number == 2:
for old, new in (('Kerman et al. (2015)', '(PMID: 26015546)'),
('Taylor et al. (2015)', '(PMID: 26000554)'),
('Coquinco et al. (2014)', '(PMID: 24662423)')):
for old, new in (('inspired by Kerman et al. (2015)', 'inspired by a published myelination assay (PMID: 26015546)'),
('inspired by Taylor et al. (2015)', 'inspired by a microfluidic gradient platform (PMID: 26000554)'),
('inspired by Coquinco et al. (2014)', 'inspired by a model of synaptic competition (PMID: 24662423)')):
caption = caption.replace(old, new)
if number == 4:
caption = caption.replace('(Protocol S1; mold fabrication in Protocol S2).',
Expand Down Expand Up @@ -164,6 +175,14 @@ def apply(self) -> None:
self.image_changes.append({'figure': number, 'asset': str(asset.relative_to(self.root)),
'sha256': sha(asset), 'part': name, 'width': width, 'height': height})
self.layout_figures()
# Word's auto-fit footer frame is 13.45pt wide (cx=170815), which LibreOffice wraps
# vertically for two-digit page numbers ("1\n5"). Widening to 36pt fixes both PDF and Word.
for name in list(self.entries):
if name.startswith('word/footer') and name.endswith('.xml'):
entry, data = self.entries[name]
if b'cx="170815"' in data:
data = data.replace(b'cx="170815"', b'cx="457200"').replace(b'width:13.45pt', b'width:36pt')
self.entries[name] = (entry, data)

def layout_figures(self) -> None:
"""Keep each restored composite and complete legend on one reading page."""
Expand Down Expand Up @@ -286,9 +305,8 @@ def apply(self) -> None:
spacing.setAttributeNS(W, 'w:after', '40'); spacing.setAttributeNS(W, 'w:line', '240')
properties.appendChild(spacing); paragraph.insertBefore(properties, paragraph.firstChild)
run = paragraph.getElementsByTagNameNS(W, 'r')[0]
properties = self.document.createElementNS(W, 'w:rPr')
properties = run.getElementsByTagNameNS(W, 'rPr')[0]
size = self.document.createElementNS(W, 'w:sz'); size.setAttributeNS(W, 'w:val', '18'); properties.appendChild(size)
run.insertBefore(properties, run.firstChild)
cell.appendChild(paragraph); row.appendChild(cell)
comparison.appendChild(row)
body.insertBefore(comparison, end)
Expand All @@ -315,9 +333,10 @@ def workbook(original: Path, output: Path, rows: list[list[str]]) -> None:
entries = {e.filename: (e, archive.read(e.filename)) for e in archive.infolist()}
book = minidom.parseString(entries['xl/workbook.xml'][1])
sheets = book.getElementsByTagNameNS(S, 'sheets')[0]
if any(n.getAttribute('name') == 'S6' for n in sheets.childNodes if n.nodeType == n.ELEMENT_NODE):
declared = [n for n in sheets.childNodes if n.nodeType == n.ELEMENT_NODE]
if any(n.getAttribute('name').startswith('S6') for n in declared):
raise ValueError('Source workbook already has S6')
identifiers = [int(n.getAttribute('sheetId')) for n in sheets.childNodes if n.nodeType == n.ELEMENT_NODE]
identifiers = [int(n.getAttribute('sheetId')) for n in declared]
identifier = max(identifiers) + 1
rels = minidom.parseString(entries['xl/_rels/workbook.xml.rels'][1])
rel = rels.createElementNS(rels.documentElement.namespaceURI, 'Relationship')
Expand All @@ -326,8 +345,11 @@ def workbook(original: Path, output: Path, rows: list[list[str]]) -> None:
rel.setAttribute('Type', R + '/worksheet')
rel.setAttribute('Target', f'worksheets/sheet{identifier}.xml')
rels.documentElement.appendChild(rel)
sheet = book.createElementNS(S, 'sheet')
sheet.setAttribute('name', 'S6'); sheet.setAttribute('sheetId', str(identifier))
# minidom writes names as given: the new entry copies its siblings' prefix
# and relationship-namespace declaration, or the workbook is not XML at all.
sheet = book.createElementNS(S, declared[0].tagName)
sheet.setAttribute('xmlns:r', R)
sheet.setAttribute('name', 'S6 Design specifications'); sheet.setAttribute('sheetId', str(identifier))
sheet.setAttributeNS(R, 'r:id', rid); sheets.appendChild(sheet)
xml = minidom.parseString(f'<worksheet xmlns="{S}"><sheetData/></worksheet>')
data = xml.getElementsByTagNameNS(S, 'sheetData')[0]
Expand Down Expand Up @@ -361,15 +383,26 @@ def workbook(original: Path, output: Path, rows: list[list[str]]) -> None:
types.documentElement.appendChild(content)
for name, document in [('xl/workbook.xml', book), ('xl/_rels/workbook.xml.rels', rels), ('[Content_Types].xml', types)]:
entries[name] = (entries[name][0], document.toxml(encoding='utf-8'))
minidom.parseString(entries[name][1])
name = f'xl/worksheets/sheet{identifier}.xml'
entries[name] = (name, xml.toxml(encoding='utf-8'))
# The main figures no longer include a panel 3G; point the provenance note at what exists.
heights = entries['xl/worksheets/sheet1.xml']
stale = b'<x:v>Main Figure 3G</x:v>'
assert heights[1].count(stale) == 1
entries['xl/worksheets/sheet1.xml'] = (heights[0], heights[1].replace(
stale, b'<x:v>Supplementary data only; not plotted in a main figure</x:v>'))
with ZipFile(output, 'w', compression=ZIP_DEFLATED) as archive:
for entry, payload in entries.values():
archive.writestr(entry, payload)
with ZipFile(original) as old, ZipFile(output) as new:
for name in old.namelist():
if name.startswith(('xl/worksheets/', 'xl/sharedStrings', 'xl/styles')):
assert old.read(name) == new.read(name), name
expected = old.read(name)
if name == 'xl/worksheets/sheet1.xml':
expected = expected.replace(b'<x:v>Main Figure 3G</x:v>',
b'<x:v>Supplementary data only; not plotted in a main figure</x:v>')
assert expected == new.read(name), name


def main() -> None:
Expand Down
7 changes: 6 additions & 1 deletion papers/mfd_platform/figure_restoration/recipe/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,17 @@ def main():
with ZipFile(root / 'v14_tracked/OpenMFD_Supplementary_Data_File_1.xlsx') as original, ZipFile(out / 'OpenMFD_Supplementary_Data_File_1.xlsx') as revised:
for name in original.namelist():
if name.startswith(('xl/worksheets/', 'xl/sharedStrings', 'xl/styles')):
assert original.read(name) == revised.read(name), name
expected = original.read(name)
if name == 'xl/worksheets/sheet1.xml':
expected = expected.replace(b'<x:v>Main Figure 3G</x:v>',
b'<x:v>Supplementary data only; not plotted in a main figure</x:v>')
assert expected == revised.read(name), name
sheet = ET.fromstring(revised.read('xl/worksheets/sheet6.xml'))
rows = [[ ''.join(c.itertext()) for c in row] for row in sheet.find(S + 'sheetData')]
assert rows == manifest['design_rows']
report['design_table_rows_in_S6'] = len(rows)
report['original_workbook_cells_and_styles_byte_identical'] = True
report['sheet1_provenance_note_updated_from_main_figure_3g'] = True
report['fabrication_comparison_approaches'] = len(actual) - 1

report['pdfs'] = []
Expand Down
Loading
Loading