SPARK is a Python implementation for identifying resting-state functional networks from fMRI data using sparse dictionary learning and K-hubness analysis.
network-analysis/
└── SPARK/
├── install_spark.sh
├── run_spark.sh
├── run_spark_slurm.sh
├── requirements.txt
├── requirements-dev.txt
├── pipeline_steps1_6.py
├── step1_load_data.py
├── step2_estimate_scale.py
├── step3_bootstrap.py
├── step4_dictionary.py
├── step5_clustering.py
├── step6_kmap_atoms.py
└── utils.py
Clone the repository
git clone https://github.com/multifunkim/network-analysis.git
cd network-analysis/SPARKbash install_spark.shbash install_spark.sh --developerDeveloper mode additionally registers the SPARK Python Jupyter kernel.
Edit the configuration section at the beginning of
run_spark.sh
Then execute
bash run_spark.shEdit the configuration section at the beginning of
run_spark_slurm.sh
including your SLURM parameters if needed (account, time, cpus, memory, etc.).
Submit the job
sbatch run_spark_slurm.shBefore running SPARK, update the following variables inside the run_spark.sh:
input_dir="/path/to/input"
mask_path="/path/to/mask.nii.gz"
output_base="/path/to/output"
suffix="_processed"Directory containing the preprocessed fMRI files.
Example
sub-HC043_ses-01_processed.nii.gz
sub-HC044_ses-01_processed.nii.gz
...
Gray matter mask used during SPARK.
SPARK automatically creates one output folder for each subject.
SPARK searches for all files ending with
*_processed.nii
*_processed.nii.gz
For HCP datasets, for example,
suffix="_rfMRI_smoothed_k8"The launcher automatically
- searches all matching fMRI files
- extracts subject identifiers
- creates output directories
- skips completed subjects
- prevents duplicate processing using lock files
- removes lock files after successful completion
For each subject SPARK generates
Subject/
step1.log/
step2.log/
step3.log/
step4.log/
step5.log/
KMAP_Subject/
k_hubness_Subject.nii.gz
atom_001.nii.gz
atom_002.nii.gz
...