forked from mackelab/sbi-for-connectomics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
54 lines (42 loc) · 1.43 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from pathlib import Path
from invoke import task
basepath = "/Users/janbolts/qode/sbi-for-connectomics"
overleaf = "/Users/janbolts/qode/connectomics-inference-manuscript"
open_cmd = "open"
fig_names = {
"1": "paper/fig1",
"2": "paper/fig2",
"3": "paper/fig3",
}
@task
def convertpngpdf(c, fig):
_convertsvg2pdf(c, fig)
_convertpdf2png(c, fig)
@task
def syncoverleaf(c, fig):
convertpngpdf(c, fig)
c.run(f"cp {basepath}/{fig_names[fig]}/fig/*.pdf {overleaf}/figs/")
c.run(f"cp {basepath}/{fig_names[fig]}/fig/*.png {overleaf}/figs/")
########################################################################################
# Helpers
########################################################################################
@task
def _convertsvg2pdf(c, fig):
if fig is None:
for f in range(len(fig_names)):
_convert_svg2pdf(c, str(f + 1))
return
pathlist = Path(f"{basepath}/{fig_names[fig]}/fig/").glob("*.svg")
for path in pathlist:
c.run(f"inkscape {str(path)} --export-pdf={str(path)[:-4]}.pdf")
@task
def _convertpdf2png(c, fig):
if fig is None:
for f in range(len(fig_names)):
_convert_pdf2png(c, str(f + 1))
return
pathlist = Path(f"{basepath}/{fig_names[fig]}/fig/").glob("*.pdf")
for path in pathlist:
c.run(
f'inkscape {str(path)} --export-png={str(path)[:-4]}.png -b "white" --export-dpi=250'
)