Skip to content

Commit 2525e34

Browse files
committed
Add documentation
1 parent 8eb17e4 commit 2525e34

File tree

9 files changed

+1074
-188
lines changed

9 files changed

+1074
-188
lines changed

.github/workflows/docs.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build and deploy docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repo
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.11" # or your preferred version
23+
24+
- name: Install dependencies
25+
run: |
26+
pip install mkdocs mkdocs-material mkdocstrings[python] photonai
27+
28+
- name: Build and deploy
29+
run: |
30+
mkdocs gh-deploy --force

docs/api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# API Reference
2+
3+
::: photonai_projects.project.PhotonaiProject

docs/getting-started.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Getting started
2+
3+
This page shows how to set up a simple PHOTONAI project using
4+
`PhotonaiProject`, run analyses, perform permutation tests, and
5+
statistically compare different analyses.
6+
7+
## Installation
8+
9+
Install the package (and PHOTONAI) into your environment:
10+
11+
```bash
12+
pip install photonai photonai-projects
13+
```
14+
15+
## Basic concepts
16+
A **PhotonaiProject** manages multiple PHOTONAI analyses in a single
17+
project folder. Each analysis has its own subfolder containing:
18+
19+
- a hyperpipe constructor script (hyperpipe_constructor.py)
20+
21+
- a metadata file (hyperpipe_meta.json)
22+
23+
- a data/ folder with X.npy and y.npy
24+
25+
- (optionally) a permutations/ folder for permutation tests
26+
27+
The typical workflow is:
28+
29+
1. Create a project with PhotonaiProject.
30+
2. Add analyses (data + hyperpipe constructor).
31+
3. Run analyses to train and evaluate the models.
32+
4. Run permutation tests to obtain null distributions.
33+
5. Compare analyses statistically.
34+
35+
## Minimal example
36+
Below is a complete example using the breast cancer dataset from
37+
scikit-learn. We create three analyses using different feature sets,
38+
run them, run permutation tests, and then compare them statistically.
39+
40+
41+
```python
42+
from photonai_projects.project import PhotonaiProject
43+
from sklearn.datasets import load_breast_cancer
44+
45+
# Load example data
46+
X, y = load_breast_cancer(return_X_y=True)
47+
48+
# Split features into different sets
49+
X_1 = X[:, :3]
50+
X_2 = X[:, 3:6]
51+
52+
# Create a project
53+
project = PhotonaiProject(project_folder="example_project")
54+
55+
# ---------------------------------------------------------------------
56+
# 1) Register analyses
57+
# ---------------------------------------------------------------------
58+
for name, current_X in [
59+
("all_features", X),
60+
("first_feature_set", X_1),
61+
("second_feature_set", X_2),
62+
]:
63+
project.add(
64+
name=name,
65+
X=current_X,
66+
y=y,
67+
hyperpipe_script="path/to/hyperpipe_constructor.py",
68+
name_hyperpipe_constructor="create_hyperpipe",
69+
)
70+
71+
project.list_analyses()
72+
73+
# ---------------------------------------------------------------------
74+
# 2) Run analyses
75+
# ---------------------------------------------------------------------
76+
for name in ["all_features", "first_feature_set", "second_feature_set"]:
77+
project.run(name=name)
78+
79+
# ---------------------------------------------------------------------
80+
# 3) Run permutation tests (local example)
81+
# ---------------------------------------------------------------------
82+
# Use a small number of permutations for testing; increase for real studies.
83+
for name in ["all_features", "first_feature_set", "second_feature_set"]:
84+
project.run_permutation_test(name=name, n_perms=10, overwrite=True)
85+
86+
# ---------------------------------------------------------------------
87+
# 4) Statistical comparison of analyses
88+
# ---------------------------------------------------------------------
89+
# For the Nadeau–Bengio test you must provide n_train and n_test as used
90+
# during cross-validation. Here we give a simple example.
91+
n_samples = X.shape[0]
92+
n_train = int(0.8 * n_samples)
93+
n_test = n_samples - n_train
94+
95+
# Compare two analyses (Nadeau–Bengio corrected t-test)
96+
project.compare_analyses(
97+
first_analysis="first_feature_set",
98+
second_analysis="second_feature_set",
99+
method="nadeau-bengio",
100+
n_train=n_train,
101+
n_test=n_test,
102+
)
103+
104+
# Compare two analyses (permutation-based)
105+
project.compare_analyses(
106+
first_analysis="all_features",
107+
second_analysis="second_feature_set",
108+
method="permutation",
109+
n_perms=10,
110+
)
111+
112+
# Compare all pairs at once (optional)
113+
multi_results = project.compare_multiple_analyses(
114+
analyses=["all_features", "first_feature_set", "second_feature_set"],
115+
method="permutation",
116+
n_perms=10,
117+
)
118+
print(multi_results.head())
119+
```
120+
121+
## Running permutation tests on a SLURM cluster
122+
For large numbers of permutations, you can distribute them across a
123+
SLURM array:
124+
125+
```python
126+
project.prepare_slurm_permutation_test(
127+
name="second_feature_set",
128+
n_perms=1000,
129+
conda_env="my_photonai_env",
130+
memory_per_cpu=2,
131+
n_jobs=20,
132+
run_time="0-02:00:00",
133+
random_state=1,
134+
)
135+
```
136+
137+
This creates a slurm_job.cmd script in the analysis folder which you
138+
can submit with:
139+
140+
```bash
141+
cd example_project/second_feature_set
142+
sbatch slurm_job.cmd
143+
```
144+
145+
Each array job will call the Typer CLI entry point run_perm_job and
146+
execute a subset of permutation runs.
147+
148+
## Next steps
149+
See the Usage page for more details on:
150+
151+
- how to design your hyperpipe constructor,
152+
- how metrics and scorers are handled,
153+
- how to interpret the comparison reports.
154+
155+
See the API Reference for the full documentation of PhotonaiProject.

docs/index.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# PHOTONAI Projects Documentation
2+
3+
Welcome to the **PHOTONAI Projects** toolbox — a lightweight framework for organizing, running, and statistically comparing PHOTONAI analyses.
4+
5+
This package helps you:
6+
7+
- create and manage multiple analyses inside a structured project folder
8+
- run PHOTONAI Hyperpipes on stored datasets
9+
- perform permutation tests (locally or on SLURM clusters)
10+
- aggregate permutation results and compute p-values
11+
- compare multiple analyses statistically
12+
- **Nadeau–Bengio corrected t-test**
13+
- **Permutation-based tests**
14+
15+
Whether you're running a single experiment or dozens of feature-selection pipelines, this toolbox keeps everything organized, reproducducible, and statistically valid.
16+
17+
---
18+
19+
## Quick links
20+
21+
- **[Getting started](getting-started.md)**
22+
- **[API Reference](api.md)**
23+
24+
---
25+
26+
## Installation
27+
28+
```bash
29+
pip install photonai photonai-projects
30+
```
31+
32+
Or, if installing from a local checkout:
33+
34+
```bash
35+
pip install -e .
36+
```
37+
38+
---
39+
40+
## What’s inside the toolbox?
41+
42+
### **Project Management**
43+
44+
Store each analysis in a clean folder structure:
45+
46+
```
47+
project/
48+
├── analysis_1/
49+
│ ├── data/
50+
│ ├── hyperpipe_constructor.py
51+
│ └── hyperpipe_meta.json
52+
├── analysis_2/
53+
└── ...
54+
```
55+
56+
### **Execution**
57+
58+
Run any analysis:
59+
60+
```python
61+
project.run("analysis_name")
62+
```
63+
64+
### **Permutation Tests**
65+
66+
Generate permutation-based null distributions:
67+
68+
```python
69+
project.run_permutation_test("analysis_name", n_perms=1000)
70+
```
71+
72+
### **Statistical Comparison**
73+
74+
Compare analyses using:
75+
76+
- `method="nadeau-bengio"`
77+
- `method="permutation"`
78+
79+
```python
80+
project.compare_analyses("A", "B", method="permutation")
81+
```
82+
83+
### **SLURM Support**
84+
85+
Automatically prepare SLURM array jobs for large permutation workloads.
86+
87+
---
88+
89+
## Additional pages coming soon
90+
91+
- Usage Guide
92+
- Writing hyperpipe constructors
93+
- Best practices
94+
- Reproducibility checklist

docs/stylesheets/pastel-theme.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* ---------------------------------------------------------
2+
Light mode: pastel palette + deep green primary
3+
--------------------------------------------------------- */
4+
:root {
5+
/* Deep green primary (buttons, header, links) */
6+
--md-primary-fg-color: #2e5d50;
7+
--md-primary-fg-color--light: #4f7d70;
8+
--md-primary-fg-color--dark: #1e3f35;
9+
10+
/* Pastel teal accent (highlights, focus, active elements) */
11+
--md-accent-fg-color: #9ad4c2;
12+
--md-accent-fg-color--transparent: rgba(154, 212, 194, 0.2);
13+
14+
/* Pastel background tones */
15+
--md-default-bg-color: #fafcff; /* very soft off-white */
16+
--md-default-fg-color: #2e3c42;
17+
--md-default-fg-color--light: #5d6d74;
18+
19+
/* Code blocks (soft grey background) */
20+
--md-code-bg-color: #f3f6f8;
21+
--md-code-fg-color: #2a3a3f;
22+
}
23+
24+
/* ---------------------------------------------------------
25+
Dark mode: deep pine green + muted pastel highlights
26+
--------------------------------------------------------- */
27+
[data-md-color-scheme="slate"] {
28+
--md-hue: 175; /* keeps greenish theme harmony */
29+
30+
/* Dark pine background */
31+
--md-default-bg-color: #0f1a17;
32+
--md-default-fg-color: #d8e3dd;
33+
--md-default-fg-color--light: #a6b6b0;
34+
35+
/* Dark mode primary colors */
36+
--md-primary-fg-color: #2e5d50;
37+
--md-primary-fg-color--light: #4f7d70;
38+
--md-primary-fg-color--dark: #1e3f35;
39+
40+
/* Soft pastel teal accent */
41+
--md-accent-fg-color: #9ad4c2;
42+
43+
/* Code blocks */
44+
--md-code-bg-color: #172421;
45+
--md-code-fg-color: #dff7f0;
46+
}

0 commit comments

Comments
 (0)