Skip to content

Commit 958bdf8

Browse files
committed
Add presentation WIP
1 parent 226a5ce commit 958bdf8

File tree

1 file changed

+243
-88
lines changed

1 file changed

+243
-88
lines changed

index.qmd

Lines changed: 243 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,266 @@
11
---
2-
title: A template presentation
3-
subtitle: so much fun
4-
author: SWC Neuroinformatics Unit
5-
execute:
2+
title: photon-mosaic
3+
subtitle: Progress, Workflow, and UI Ideas
4+
author: Laura Porta
5+
execute:
66
enabled: true
77
format:
8-
revealjs:
9-
theme: [default, niu-dark.scss]
10-
logo: img/logo_niu_dark.png
11-
footer: "Edit this footer | 2023-07-26"
12-
slide-number: c
13-
menu:
14-
numbers: true
15-
chalkboard: true
16-
scrollable: true
17-
preview-links: false
18-
view-distance: 10
19-
mobile-view-distance: 10
20-
auto-animate: true
21-
auto-play-media: true
22-
code-overflow: wrap
23-
highlight-style: atom-one
24-
mermaid:
25-
theme: neutral
26-
fontFamily: arial
27-
curve: linear
28-
html:
29-
theme: [default, niu-dark.scss]
30-
logo: img/logo_niu_dark.png
31-
date: "2023-07-05"
32-
toc: true
33-
code-overflow: scroll
34-
highlight-style: atom-one
35-
mermaid:
36-
theme: neutral
37-
fontFamily: arial
38-
curve: linear
39-
margin-left: 0
40-
embed-resources: true
41-
page-layout: full
42-
my-custom-stuff:
43-
my-reuseable-variable: "I can use this wherever I want in the markdown, and change it in only once place :)"
44-
---
45-
46-
## Contents
47-
48-
Some example slides - [also look at example RevealJS slides in the Quarto docs](https://quarto.org/docs/presentations/revealjs/)
49-
50-
* Non-executable and executable code-blocks
51-
* bullet points with highlighting
52-
* two-column slides
53-
* how to include a slide from a separate MD file
54-
* preview and link to a webpage
55-
56-
## Just a code block, nothing gets executed...
57-
58-
... but there is some fancy highlighting
59-
60-
```{.python code-line-numbers="1|3|4-9"}
61-
from pathlib import Path
62-
63-
home_path = Path.home()
64-
if home_path.exists():
65-
data_path = home_path / "data"
66-
else:
67-
pass
68-
# raise some error maybe?
8+
revealjs:
9+
theme: [default, niu-dark.scss]
10+
logo: img/logo_niu_dark.png
11+
footer: "photon-mosaic dev | 2025-05-19"
12+
slide-number: c
13+
menu:
14+
numbers: true
15+
chalkboard: true
16+
scrollable: true
17+
preview-links: false
18+
view-distance: 10
19+
mobile-view-distance: 10
20+
auto-animate: true
21+
auto-play-media: true
22+
code-overflow: wrap
23+
highlight-style: atom-one
24+
mermaid:
25+
theme: neutral
26+
fontFamily: arial
27+
curve: linear
28+
html:
29+
theme: [default, niu-dark.scss]
30+
logo: img/logo_niu_dark.png
31+
date: "2025-05-19"
32+
toc: true
33+
code-overflow: scroll
34+
highlight-style: atom-one
35+
mermaid:
36+
theme: neutral
37+
fontFamily: arial
38+
curve: linear
39+
margin-left: 0
40+
embed-resources: true
41+
page-layout: full
42+
---
43+
44+
## Project summary
45+
46+
`photon-mosaic` is a pipeline and toolkit for automating preprocessing of 2p and 3p calcium imaging data.
47+
48+
It was designed to:
49+
50+
* Standardize steps like derotation, contrast adjustment, suite2p, etc.
51+
* Enable reproducibility via Snakemake
52+
* Be modular and extensible
53+
* Reduce manual clicks for common workflows
54+
55+
---
56+
57+
## Current Status
58+
59+
* ✅ Read/write modules for structured folder input
60+
* ✅ Derotation preprocessing steps
61+
* ✅ Suite2p integration (via Snakemake rules)
62+
* 🧪 Tests for core components
63+
* 📄 Docs with `sphinx` and embedded Markdown
64+
* ⏳ Idea for interactive terminal UI in progress
65+
66+
---
67+
68+
## Why Snakemake?
69+
70+
Snakemake helps automate reproducible workflows.
71+
72+
Instead of writing:
73+
74+
```bash
75+
python step1.py && python step2.py && ...
6976
```
7077

71-
## A code block that's actually executed at render-time
78+
You declare:
79+
80+
```yaml
81+
rule derotate:
82+
input: "raw.tif"
83+
output: "derotated.tif"
84+
shell: "python derotate.py {input} {output}"
85+
```
86+
87+
Snakemake tracks dependencies & reruns only what changed.
88+
89+
---
90+
91+
## Snakemake = DAG of Tasks
92+
93+
Each rule specifies:
94+
95+
* Inputs: files that must exist before running
96+
* Outputs: files produced by the rule
97+
* Scripts: that do the actual work
98+
99+
---
72100
73-
```{python}
74-
#| echo: true
75-
#| code-fold: true
101+
## Snakemake = DAG of Tasks
76102
77-
from pathlib import Path
103+
Snakemake builds a **DAG** (Directed Acyclic Graph) from these dependencies.
78104
79-
print("Hello world")
105+
```{mermaid}
106+
flowchart LR
107+
raw["raw.tif"] --> derotate
108+
derotate --> derotated["derotated.tif"]
109+
derotated --> suite2p
110+
suite2p --> suite2p_out["suite2p/output"]
80111
```
81112

82-
## You can execute code without showing that you have by using #|echo: false
83-
```{python}
84-
#| echo: false
113+
Only changed or missing outputs will be recomputed.
114+
115+
---
116+
117+
## Enforcing a Shared Folder Structure
118+
119+
We follow the [**NeuroBlueprint**](https://github.com/SainsburyWellcomeCentre/neuro-blueprint) data standard.
85120

86-
from pathlib import Path
121+
NeuroBlueprint defines:
87122

88-
print("Hello world")
123+
* `rawdata/` and `derivatives/` as top-level folders
124+
* Hierarchical subject/session/datatype levels
125+
* Standard naming for folders (e.g. `sub-001_ses-01_date-YYYYMMDD`)
126+
* Clear separation of raw vs processed data
127+
128+
This ensures that:
129+
130+
* Pipelines work consistently across labs
131+
* Data remains readable and parseable
132+
* Custom metadata remains attached to each subject/session
133+
134+
```{mermaid}
135+
flowchart TD
136+
A[project/] --> B1[rawdata/]
137+
A --> B2[derivatives/]
138+
B1 --> C1[sub-001/]
139+
C1 --> D1[ses-01/]
140+
D1 --> E1[funcimg/]
89141
```
90142

91-
{{< include slides/extra_slide.qmd >}}
143+
---
92144

93-
## An example image
145+
## How NeuroBlueprint Is Used in Snakemake
94146

95-
Include an image:
147+
We dynamically generate Snakemake `input` and `output` targets from the NeuroBlueprint structure:
96148

97-
![](img/bg_logo_wide.png){width=900 fig-align=center}
149+
```python
150+
preprocessed_outputs = [
151+
processed_data_base / f"sub-{i}_{new}" / f"ses-{j}" / "funcimg" / f"{name}.tif"
152+
for i, (_, new) in enumerate(dataset_pairs)
153+
for j, name in enumerate(output_patterns)
154+
]
155+
```
98156

157+
This keeps your Snakefile **decoupled from hardcoded paths**, and ensures output files remain BIDS-like.
99158

100-
## Link and a preview a webpage:
159+
---
160+
161+
## Modular Design
101162

102-
::: {style="text-align: center; margin-top: 1em"}
103-
[interoperable Python-based tools for computational neuroanatomy](https://brainglobe.info/index.html){preview-link="true" style="text-align: center"}
104-
:::
163+
Each step is a module with inputs/outputs.
105164

106-
## Use a variable several times
165+
```{mermaid}
166+
flowchart TD
167+
subgraph Modules
168+
A1[reader]
169+
B1[preprocessing]
170+
C1[suite2p]
171+
D1[postprocessing]
172+
end
173+
174+
A1 --> B1 --> C1 --> D1
175+
```
176+
177+
Modularity allows:
178+
179+
* Clear function boundaries
180+
* Unit testing
181+
* User extension
182+
183+
---
184+
185+
## Snakemake Rule Example
186+
187+
```python
188+
rule suite2p:
189+
input:
190+
tiff=lambda wc: str(...)
191+
output:
192+
F=".../F.npy",
193+
bin=".../data.bin"
194+
run:
195+
run_suite2p(input.tiff, output.F, output.bin, ...)
196+
```
197+
198+
This uses logic and config patterns to determine filenames from the folder structure.
199+
200+
---
201+
202+
## Challenge: Complexity for Users 😓
203+
204+
Snakemake is powerful... but YAML, paths, and rule syntax can scare users.
205+
206+
* Hard to onboard new users
207+
* Many researchers prefer GUIs or simple CLI tools
208+
* Need a gentler interface
209+
210+
---
211+
212+
## Proposed Solution: Terminal UI
213+
214+
A TUI (terminal user interface) could help:
215+
216+
* Select pipeline steps interactively
217+
* Auto-generate Snakemake config
218+
* Submit jobs or monitor execution
219+
* Debug failed rules with context
220+
221+
---
222+
223+
## TUI Concept Sketch
224+
225+
```{mermaid}
226+
flowchart TD
227+
A[User launches tui] --> B[Select modules]
228+
B --> C[Configure paths]
229+
C --> D[Preview DAG]
230+
D --> E[Launch Snakemake]
231+
E --> F[Live status + logs]
232+
```
233+
234+
---
235+
236+
## Feature: Add Custom User Scripts
237+
238+
In the TUI, we could let users:
239+
240+
1. Select a `.py` or `.sh` file
241+
2. Specify input/output pattern
242+
3. Register it as a new step
243+
244+
```{mermaid}
245+
flowchart LR
246+
raw --> derotate --> custom["user_script.py"] --> suite2p
247+
```
248+
249+
This allows non-developers to integrate their analysis into the pipeline **without editing Snakefiles manually**.
250+
251+
---
252+
253+
## What's Next?
254+
255+
* [ ] Decide on TUI framework (`textual`, `prompt_toolkit`, etc.)
256+
* [ ] Add dry-run validation
257+
* [ ] Improve logging/debugging
258+
* [ ] Add optional GUI export?
259+
260+
---
107261

108-
Variables defined in the metadata is re-useable anywhere
262+
## Thanks!
109263

110-
* {{< meta my-custom-stuff.my-reuseable-variable >}}
111-
* {{< meta my-custom-stuff.my-reuseable-variable >}}
264+
📦 [`photon-mosaic`](https://github.com/your-org/photon-mosaic)
265+
📚 Docs coming soon
266+
💬 Let's discuss feedback, bottlenecks, and next steps!

0 commit comments

Comments
 (0)