-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.txt
More file actions
75 lines (59 loc) · 3.96 KB
/
run.txt
File metadata and controls
75 lines (59 loc) · 3.96 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Neuroimaging workflow — How to run locally (Windows / PowerShell)
Prerequisites
- R (>= 3.6) installed and `Rscript` available on PATH
- Recommended R packages: igraph, ggplot2, dplyr, testthat
Install in R:
install.packages(c("igraph", "ggplot2", "dplyr", "testthat"))
Repository layout (important files referenced below):
- `scripts/run_pipeline.R` : Rscript CLI that runs pipeline stages
- `scripts/run_pipeline.ps1`: PowerShell wrapper for convenience on Windows
- `pipelines/01_preprocess.R`, `02_analysis.R`, `03_plots.R`: pipeline stages
- `data/processed/`: place or generate processed adjacency matrices here
Run pipeline from PowerShell (recommended)
----------------------------------------
# From repository root (open PowerShell in the `neuroimaging-workflow` folder)
# 1) Preprocess (creates `data/processed/example_adj.rds` in the skeleton)
.\scripts\run_pipeline.ps1 -Stage preprocess
# 2) Analysis (reads processed input, writes `results/measures.rds`)
.\scripts\run_pipeline.ps1 -Stage analyze
# 3) Plots (reads `results/measures.rds`, writes figures into `figures/`)
.\scripts\run_pipeline.ps1 -Stage plots
Run pipeline directly with Rscript
---------------------------------
# If you prefer not to use the PowerShell helper, run the Rscript runner directly:
Rscript scripts/run_pipeline.R --stage preprocess
Rscript scripts/run_pipeline.R --stage analyze
Rscript scripts/run_pipeline.R --stage plots
Running tests (basic wiring)
----------------------------
# Tests use testthat and run the minimal pipeline. From PowerShell:
Rscript -e "if (!requireNamespace('testthat', quietly=TRUE)) install.packages('testthat'); testthat::test_dir('tests')"
Notes and troubleshooting
-------------------------
- If `Rscript` is not found, add the R `bin` directory to your PATH or run the full path to Rscript.
- If running from PowerShell you may need to set execution policy to allow scripts (only if you run PowerShell scripts directly):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
(You only need this if PowerShell blocks `.ps1` execution; running `Rscript` is unaffected.)
- The skeleton uses small synthetic data by default. Replace `data/processed/example_adj.rds` with your real adjacency matrices (RDS with numeric matrix) to run real analyses.
Helpful tips
-------------
- To run the whole pipeline in sequence from PowerShell:
.\scripts\run_pipeline.ps1 -Stage preprocess ; .\scripts\run_pipeline.ps1 -Stage analyze ; .\scripts\run_pipeline.ps1 -Stage plots
- To debug a single step, open the R scripts under `pipelines/` and run them interactively in RStudio or via `Rscript` with verbose messages.
Run pipeline from Python using rpy2
---------------------------------
# If you prefer to run the R pipeline from Python (rpy2), install Python requirements:
# pip install -r requirements.txt
# Then run:
python scripts/run_with_rpy2.py --stage preprocess
python scripts/run_with_rpy2.py --stage analyze
python scripts/run_with_rpy2.py --stage plots
Preparing to delete the original package folders
----------------------------------------------
If you plan to delete the original `brainGraph`, `fsbrain`, and `threeBrain` folders from the workspace, create a compact copy of this workflow first. The helper script below copies only the files needed to run analyses (R scripts, pipelines, data, and helpers).
Run this from PowerShell in the repository root:
```powershell
.\scripts\make_compact_repo.ps1 -Destination neuroimaging-workflow-compact
```
This produces a folder `neuroimaging-workflow-compact` beside the current repo containing `R/`, `pipelines/`, `scripts/`, `data/`, and minimal docs. Open that compact folder in RStudio to run the pipeline there. Once you confirm everything works from the compact folder, you can safely remove the original `brainGraph`, `fsbrain`, and `threeBrain` directories from your workspace.
If you want, I can run a final check (run `preprocess`, `analyze`, `plots`) inside the compact copy to ensure everything runs without the package folders.