1import yaml
3# Load session configuration
4with open("sessions.yaml", "r") as f:
5 config = yaml.safe_load(f)
7# Extract session information
8sessions = config["sessions"]
9session_ids = [s["session_id"] for s in sessions]
11# Define all targets
12rule all:
13 input:
14 expand("figures/{session_id}.url", session_id=session_ids),
15 "index.md"
17# Dynamic rule to create figures for each session
18rule create_figure:
19 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"]
26 # Run the figure creation script
27 shell(f"python scripts/create_figure.py {nwb_path} {{output}}")
29# Rule to generate index.md from template
30rule generate_index:
31 input:
32 expand("figures/{session_id}.url", session_id=session_ids),
33 "sessions.yaml",
34 "templates/index.md.jinja"
35 output:
36 "index.md"
37 shell:
38 "python scripts/generate_index.py"