streamline
10 changed files+135−14
README.mdmodified+9−3View file
@@ -1,7 +1,13 @@
11 # [Dandiset 000986](https://dandiarchive.org/dandiset/000986)
22
3-This is a test
3+## Usage
44
5-<iframe src="https://figures.figpack.org/figures/default/d0be3702700b8893f0432754/index.html" width="100%" height="800px"></iframe>
5+Build all figures and generate index:
66
7-Will that iframe get rendered on github pages?
7+```bash
8+snakemake
9+```
10+
11+## Adding Sessions
12+
13+Edit `sessions.yaml` and run `snakemake`.
Snakefilemodified+31−9View file
@@ -1,16 +1,38 @@
1+import yaml
2+
3+# Load session configuration
4+with open("sessions.yaml", "r") as f:
5+ config = yaml.safe_load(f)
6+
7+# Extract session information
8+sessions = config["sessions"]
9+session_ids = [s["session_id"] for s in sessions]
10+
11+# Define all targets
112 rule all:
213 input:
3- "figures/ses-1.url",
4- "figures/ses-2.url",
14+ expand("figures/{session_id}.url", session_id=session_ids),
15+ "index.md"
516
6-rule create_figure1:
17+# Dynamic rule to create figures for each session
18+rule create_figure:
719 output:
8- "figures/ses-1.url"
9- shell:
10- "python scripts/create_figure.py sub-LA11/sub-LA11_ses-1_behavior.nwb {output}"
20+ "figures/{session_id}.url"
21+ run:
22+ # Find the session configuration
23+ session = next(s for s in sessions if s["session_id"] == wildcards.session_id)
24+ nwb_path = session["nwb_path"]
25+
26+ # Run the figure creation script
27+ shell(f"python scripts/create_figure.py {nwb_path} {{output}}")
1128
12-rule create_figure2:
29+# Rule to generate index.md from template
30+rule generate_index:
31+ input:
32+ expand("figures/{session_id}.url", session_id=session_ids),
33+ "sessions.yaml",
34+ "templates/index.md.jinja"
1335 output:
14- "figures/ses-2.url"
36+ "index.md"
1537 shell:
16- "python scripts/create_figure.py sub-LA11/sub-LA11_ses-2_behavior.nwb {output}"
38+ "python scripts/generate_index.py"
figures/ses-1.urlmodified+1−1View file
@@ -1 +1 @@
1-https://figures.figpack.org/figures/default/d0be3702700b8893f0432754/index.html
1+https://figures.figpack.org/figures/default/f176e1ad4d2201b6d7d5484f/index.html
figures/ses-2.urlmodified+1−1View file
@@ -1 +1 @@
1-https://figures.figpack.org/figures/default/bc864e107350c71743dd4eaf/index.html
1+https://figures.figpack.org/figures/default/f5b2445ffce5b07576412f6e/index.html
figures/ses-3.urladded+1−0View file
@@ -0,0 +1 @@
1+https://figures.figpack.org/figures/default/a1271cc3be5e4fa743dd1d39/index.html
figures/ses-4.urladded+1−0View file
@@ -0,0 +1 @@
1+https://figures.figpack.org/figures/default/c7898573e9b653f353acc418/index.html
index.mdadded+22−0View file
@@ -0,0 +1,22 @@
1+# [Dandiset 000986](https://dandiarchive.org/dandiset/000986)
2+
3+
4+sub-LA11/sub-LA11_ses-1_behavior.nwb
5+
6+<iframe src="https://figures.figpack.org/figures/default/f176e1ad4d2201b6d7d5484f/index.html" width="100%" height="800px" style="border:none;"></iframe>
7+
8+
9+sub-LA11/sub-LA11_ses-2_behavior.nwb
10+
11+<iframe src="https://figures.figpack.org/figures/default/f5b2445ffce5b07576412f6e/index.html" width="100%" height="800px" style="border:none;"></iframe>
12+
13+
14+sub-LA11/sub-LA11_ses-3_behavior.nwb
15+
16+<iframe src="https://figures.figpack.org/figures/default/a1271cc3be5e4fa743dd1d39/index.html" width="100%" height="800px" style="border:none;"></iframe>
17+
18+
19+sub-LA11/sub-LA11_ses-4_behavior.nwb
20+
21+<iframe src="https://figures.figpack.org/figures/default/c7898573e9b653f353acc418/index.html" width="100%" height="800px" style="border:none;"></iframe>
22+
scripts/generate_index.pyadded+42−0View file
@@ -0,0 +1,42 @@
1+#!/usr/bin/env python3
2+"""Generate index.md from template using session configuration and figure URLs."""
3+
4+import yaml
5+from pathlib import Path
6+from jinja2 import Template
7+
8+# Load sessions configuration
9+with open("sessions.yaml", "r") as f:
10+ config = yaml.safe_load(f)
11+
12+# Read figure URLs for each session
13+sessions_with_urls = []
14+for session in config["sessions"]:
15+ session_id = session["session_id"]
16+ url_file = Path(f"figures/{session_id}.url")
17+
18+ if url_file.exists():
19+ with open(url_file, "r") as f:
20+ figure_url = f.read().strip()
21+ else:
22+ # Placeholder if URL file doesn't exist yet
23+ figure_url = "# Figure not yet generated"
24+
25+ session_with_url = session.copy()
26+ session_with_url["figure_url"] = figure_url
27+ sessions_with_urls.append(session_with_url)
28+
29+# Load and render template
30+with open("templates/index.md.jinja", "r") as f:
31+ template = Template(f.read())
32+
33+rendered = template.render(
34+ dandiset_id=config["dandiset_id"],
35+ sessions=sessions_with_urls
36+)
37+
38+# Write output
39+with open("index.md", "w") as f:
40+ f.write(rendered)
41+
42+print(f"Generated index.md with {len(sessions_with_urls)} sessions")
sessions.yamladded+19−0View file
@@ -0,0 +1,19 @@
1+dandiset_id: "000986"
2+subject: "sub-LA11"
3+
4+sessions:
5+ - session_id: "ses-1"
6+ nwb_path: "sub-LA11/sub-LA11_ses-1_behavior.nwb"
7+ title: "Session 1"
8+
9+ - session_id: "ses-2"
10+ nwb_path: "sub-LA11/sub-LA11_ses-2_behavior.nwb"
11+ title: "Session 2"
12+
13+ - session_id: "ses-3"
14+ nwb_path: "sub-LA11/sub-LA11_ses-3_behavior.nwb"
15+ title: "Session 3"
16+
17+ - session_id: "ses-4"
18+ nwb_path: "sub-LA11/sub-LA11_ses-4_behavior.nwb"
19+ title: "Session 4"
templates/index.md.jinjaadded+8−0View file
@@ -0,0 +1,8 @@
1+# [Dandiset {{ dandiset_id }}](https://dandiarchive.org/dandiset/{{ dandiset_id }})
2+
3+{% for session in sessions %}
4+{{ session.nwb_path }}
5+
6+<iframe src="{{ session.figure_url }}" width="100%" height="800px" style="border:none;"></iframe>
7+
8+{% endfor %}