Skip to content

Commit bc03367

Browse files
authored
CWAS package project - Final submission (#393)
* Add cwas4fmri * Minor changes * Correct typo
1 parent 7080e11 commit bc03367

File tree

4 files changed

+191
-0
lines changed

4 files changed

+191
-0
lines changed
28.6 KB
Loading
235 KB
Loading
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
---
2+
type: "project" # DON'T TOUCH THIS ! :)
3+
date: "2025-06-18" # Date you first upload your project.
4+
# Title of your project (we like creative title)
5+
title: "CWAS4fMRI: a python package to perform Connectome Wide Association Study"
6+
7+
# List the names of the collaborators within the [ ]. If alone, simple put your name within []
8+
names: [Clara El Khantour]
9+
10+
# Your project GitHub repository URL
11+
github_repo: https://github.com/brainhack-school2025/elkhantour_project
12+
13+
# If you are working on a project that has website, indicate the full url including "https://" below or leave it empty.
14+
website: https://brainhack-school2025.github.io/elkhantour_project/
15+
16+
# List +- 4 keywords that best describe your project within []. Note that the project summary also involves a number of key words. Those are listed on top of the [github repository](https://github.com/brainhack-school2020/project_template), click `manage topics`.
17+
# Please only lowercase letters
18+
tags: [fmri, cwas, connectome, package]
19+
20+
# Summarize your project in < ~75 words. This description will appear at the top of your page and on the list page with other projects..
21+
22+
summary: "This project aimed to develop a BIDS App for performing Connectome-Wide Association Studies (CWAS) on fMRI connectivity matrices. The result is a GitHub repository that can be installed via pip, enabling analyses on BIDS-formatted connectomes. Integration tests ensure the pipeline runs reliably, and a dedicated website provides full documentation and example outputs."
23+
24+
# If you want to add a cover image (listpage and image in the right), add it to your directory and indicate the name
25+
# below with the extension.
26+
image: "illuminated-neural-network-stockcake.jpg"
27+
---
28+
<!-- This is an html comment and this won't appear in the rendered page. You are now editing the "content" area, the core of your description. Everything that you can do in markdown is allowed below. We added a couple of comments to guide your through documenting your progress. -->
29+
30+
## Project definition
31+
32+
### Background
33+
34+
The reproducibility crisis in neuroimaging has affected many research domains, and psychiatric research is no exception <sup>[1](https://doi.org/10.1016/j.bpsc.2022.12.006)</sup>. Indeed, psychiatric studies using neuroimaging tools have long struggled with poor reproducibility, largely due to small sample sizes and heterogeneity in analysis methods.
35+
36+
To address this issue, initiatives such as the ENIGMA consortium (Enhancing NeuroImaging Genetics through Meta-Analyses) were launched <sup>[2](https://doi.org/10.1007/s11682-013-9269-5)</sup>. ENIGMA is a consortium comprising international research sites and organized into several Disease Working Groups that focus on most major psychiatric conditions. It promotes a collaborative framework: while data remain at local sites, analyses follow standardized protocols, enabling large-scale meta-analyses across cohorts.
37+
38+
This approach has proven successful for structural and diffusion MRI, thanks to the development of open and reproducible protocols (https://enigma.ini.usc.edu/protocols/). In this context, Waller et al., 2020 developed HALFpipe <sup>[3](https://doi.org/10.1002/hbm.25829)</sup>, an open-source software that facilitates the preprocessing and extraction of connectivity matrices from functional MRI data. However, no standard tools has yet been proposed by ENIGMA for statistical analyses of functional connectivity matrices.
39+
40+
#### Objectives
41+
This project aims to support the broader collaborative effort by developing a dedicated BIDS-App for conducting Connectome-Wide Association Studies (CWAS) based on connectivity matrices.
42+
43+
#### Objectives for BrainHack school
44+
Learn how to :
45+
1. Write scripts in python following the BIDS-app workflow
46+
2. Build a GitHub repository with automated tests with GitHub Actions
47+
3. Develop a sustainable and easy-to-use python package
48+
4. Produce interactive plots and interactive website ✨
49+
50+
### Tools
51+
52+
This project uses the following tools and standards to ensure reproducibility, openness, and long-term usability:
53+
- **Python scripts** : To write functions, modules and be able to test them
54+
- **Git & GitHub**:
55+
- *Public repo*: Enables version control and promotes open-source, collaborative development of the library.
56+
- *GitHub Actions*: Implements automated testing and continuous integration to maintain code quality during development (Git Actions).
57+
- **BIDS Ecosystem**: Ensures compatibility with the BIDS standard, following the workflow of a BIDS App <sup>[4](https://doi.org/10.1371/journal.pcbi.1005209)</sup>.
58+
- For this package, we followed the [BEP-017 proposal](https://bids.neuroimaging.io/extensions/beps/bep_017.html)
59+
- **Python Packaging with uv**: Distributes the tool as an installable open-source Python library for easy integration and reuse.
60+
- Interactive documentation : Provides documentation and examples on the website.
61+
- **Jupyter Notebooks**
62+
- **Plots with Plotly**
63+
- **Website with MyST**
64+
65+
### Data
66+
67+
To test the integration of the pipeline, toy data have been generated using `numpy` and `pandas`.
68+
69+
Local tests have been made base on [Giga-connectome outputs](https://giga-connectome.readthedocs.io/en/latest/).
70+
71+
### Deliverables
72+
73+
1. Python scripts following the BIDS-App workflow
74+
2. A python package ready to be used available on [GitHub](https://github.com/brainhack-school2025/elkhantour_project)
75+
3. A public [GitHub repository](https://github.com/brainhack-school2025/elkhantour_project) with integration test
76+
4. A [website](https://brainhack-school2025.github.io/elkhantour_project/) with interactive plots
77+
78+
## Results
79+
80+
### Progress overview
81+
82+
During Brain Hack School 2025, I developed a functional and pip-installable Python package. I also set up a website with all the documentation you need to run the CWAS pipeline. This first version of the Python package is now open to feedback and collaboration.
83+
84+
### Tools I learned during this project
85+
86+
- **Python scripts** : All original scripts were refactored into modular Python files. Scripts are now organized by topic and function to improve readability and maintainability.
87+
88+
- **Git, GitHub & Testing with pytest** : This project introduced me to advanced GitHub features, including GitHub Actions for continuous integration. I learned to use `pytest` to write and integrate tests that ensure the pipeline remains functional after updates.
89+
90+
- **Python Packaging with uv** : I discovered `uv` during one of the BHS2025 modules in Montreal, and used it to build this package.
91+
92+
- **BIDS Ecosystem** : This project helped me to understand the importance of the BIDS ecosystem and all the related BIDS-App. I discovered BIDS extension proposals (BEPs) such as those for derived data like connectivity matrices.
93+
94+
- **Website with MyST** : I used MyST Markdown to build and publish a clean, structured documentation website.
95+
96+
- **Plots with Plotly** : To create interactive visualizations, particularly for complex connectivity maps involving many brain regions.
97+
98+
### Results
99+
100+
#### Deliverable 1: BIDS workfow implementation
101+
This pipeline was created to follow the BIDS-App workflow as proposed by [Gorgolewski et al., 2017](https://doi.org/10.1371/journal.pcbi.1005209) for group level anlaysis.
102+
103+
<img title="Workflow of the pipeline" alt="Alt text" src="workflow.png">
104+
105+
This pipeline takes as input a directory structured according to the [BEP-017 proposal](https://bids.neuroimaging.io/extensions/beps/bep_017.html). Both the input and output directories are defined via command-line arguments.
106+
107+
#### Deliverable 2: Python package
108+
This package was initialize using [`uv`](https://github.com/astral-sh/uv).
109+
110+
Thanks to this setup, the repository can be installed using using `pip install .`. This configuration ensures that:
111+
- All required dependencies are installed
112+
- The pipeline can be tested using `pytest`
113+
114+
###### Quick start
115+
To run this pipeline, you simply need to follow the next 3 steps:
116+
117+
1. Clone the repository
118+
```
119+
git clone https://github.com/brainhack-school2025/elkhantour_project.git
120+
```
121+
2. Install the package
122+
123+
```
124+
pip install -e .
125+
```
126+
127+
3. Run the pipeline using the command `cwas-rsfmri` followed by the flags.
128+
129+
```bash
130+
cwas-rsfmri --bids_dir=bids_directory --output_dir=results --atlas_file=atlas.txt --atlas=example_atlas --phenotype_file=participants.tsv --group=diagnosis --case_id=NDD --control_id=HC --session=timepoint1 --task=task01 --run=01 --feature=denoiseSimple
131+
```
132+
133+
#### Deliverable 3: Continuous integration with GitHub Action
134+
135+
The tests were implemented using [pytest](https://docs.pytest.org/en/stable/).
136+
137+
Since this package serves as a *glue* between already existing pipelines, the focus is on integration testing rather than unit testing. To support this, toy datasets are automatically generated and deleted during each pytest run to avoid unnecessary disk usage.
138+
139+
For now, two integration tests are included:
140+
1. One without any optional arguments (`scan`, `sequence`, `medication`).
141+
2. One using all optional arguments
142+
143+
These tests are automatically run on GitHub via GitHub Actions on every push to the `main` and `dev_test` branches, as well as on pull requests.
144+
145+
#### Deliverable 4: MyST Website
146+
To provide complete documentation and show example figures generated by the pipeline, a website was built using MyST and is hosted on GitHub Pages.
147+
148+
The documentation is available directly on the site https://brainhack-school2025.github.io/elkhantour_project/
149+
150+
To visualize the interactive figure, please see: https://brainhack-school2025.github.io/elkhantour_project/interactive-plots
151+
152+
<img title="Example of a plot generated with CWAS-rsfmri" alt="Alt text" src="example_cwas.png">
153+
154+
#### Contribution to Open Science
155+
This project aims to:
156+
1. Promote __collaborative science__ through:
157+
- A public GitHub repository open to contributions
158+
- Continuous integration with GitHub Actions, which automatically run on new pull requests
159+
2. Ensure __reproductible pipeline and results__ by:
160+
- Providing a Python package that can be run with just three command-line commands
161+
- Following the BIDS standard for input organization, aligning with community efforts to standardize neuroimaging workflows
162+
3. Offer extensive __documentation__ using MyST markdown, a tool designed for open-source projects that supports clear, structured scientific communication and web-based publishing.
163+
164+
## Conclusion and acknowledgement
165+
166+
This project provides an easy-to-use and fast Python package for researchers working with fMRI connectivity matrices. It's fully open-source and welcomes collaboration from the community.
167+
168+
The package was built using recent, open-source tools and follows principles established by the neuroimaging community to align with current standards in neuroimaging research.
169+
170+
### Next steps
171+
- **Expand integration tests**: Improve existing tests and add failing test cases to ensure the pipeline handles incorrect inputs and edge cases properly.
172+
- **Publish to PyPi**: Once the pipeline is more stable and mature, release an official version to PyPI for easier installation and distribution.
173+
- **Docker & Apptainer**: Containerize the pipeline to ensure full environment reproducibility using Docker and Apptainer.
174+
175+
### Brain Hack School presentation materials
176+
[Project description - Week 2](https://docs.google.com/presentation/d/1BFQEd32ZGSvIpQaBQh5KjRjrZ0RL78illSvqR80Dr_E/edit?usp=sharing).
177+
178+
[Final presentation - Week 4](https://docs.google.com/presentation/d/1AT7jvhL63toRHIYBsFZYHyxpPp-cLphSkeC5kAkJMak/edit?usp=sharing).
179+
180+
## Aknowledgements
181+
This library is based on code originally published by Dr. Clara A. Moreau & Dr. Sebastian Urchs.
182+
183+
The original version of the scripts can be found here : https://github.com/claramoreau9/NeuropsychiatricCNVs_Connectivity
184+
185+
Thanks to Sara & Cleo for their help to create the Myst website! I would like to thank all the Professors, TAs, speakers of Brain Hack School 2025 Montreal. Special thanks to Lune Bellec who was mentoring me over the past few weeks.
186+
187+
## References
188+
1. Botvinik-Nezer R, Wager TD. Reproducibility in neuroimaging analysis: Challenges and solutions. Biol Psychiatry Cogn Neurosci Neuroimaging. 2023;8: 780–788.
189+
2. Thompson PM, Stein JL, Medland SE, Hibar DP, Vasquez AA, Renteria ME, et al. The ENIGMA Consortium: large-scale collaborative analyses of neuroimaging and genetic data. Brain Imaging Behav. 2014;8: 153–182.
190+
3. Waller L, Erk S, Pozzi E, Toenders YJ, Haswell CC, Büttner M, et al. ENIGMA HALFpipe: Interactive, reproducible, and efficient analysis for resting-state and task-based fMRI data. Hum Brain Mapp. 2022;43: 2727–2742.
191+
4. Gorgolewski KJ, Alfaro-Almagro F, Auer T, Bellec P, Capotă M, Chakravarty MM, et al. BIDS apps: Improving ease of use, accessibility, and reproducibility of neuroimaging data analysis methods. PLoS Comput Biol. 2017;13: e1005209.
526 KB
Loading

0 commit comments

Comments
 (0)