Running Workflows¶
This guide covers running SPIMquant workflows in various environments.
Workflow Overview¶
SPIMquant workflows consist of several stages:
- Data Loading: Read BIDS-formatted SPIM data
- Registration: Align to template using deformable registration
- Segmentation: Detect pathology using various methods
- Quantification: Extract statistics by brain region
- Visualization: Generate quality control outputs
Local Execution¶
Single Subject¶
Process one subject at a time:
Multiple Subjects¶
Process all subjects in parallel:
The --cores option controls parallelization:
--cores all: Use all available cores--cores N: Use N cores--cores 1: Sequential processing
Cluster Execution¶
SLURM¶
SPIMquant can submit jobs to SLURM clusters:
Custom Profiles¶
Create a custom profile in spimquant/profiles/:
Cloud Execution¶
Coiled¶
Run on cloud infrastructure with Coiled:
Cloud Storage¶
Read data directly from cloud storage:
# S3
pixi run spimquant s3://bucket/bids /output participant --cores all
# GCS
pixi run spimquant gs://bucket/bids /output participant --cores all
Workflow Control¶
Dry Run¶
Test workflow without execution:
This shows:
- Jobs that would be executed
- Input/output files
- Rule dependencies
- Estimated resource usage
Partial Execution¶
Run specific parts of the workflow:
# Run until specific rule
pixi run spimquant ... --until convert_to_nifti
# Run from specific rule
pixi run spimquant ... --from register_to_template
# Force re-run specific rule
pixi run spimquant ... --forcerun segment_pathology
Resume After Failure¶
SPIMquant automatically resumes from the last successful step:
Monitoring Progress¶
Real-time Monitoring¶
Watch progress during execution:
# Enable verbose output
pixi run spimquant ... --verbose
# Show executed commands
pixi run spimquant ... --printshellcmds
Progress Tracking¶
Snakemake displays:
- Completed jobs
- Running jobs
- Pending jobs
- Failed jobs
Log Files¶
Check logs for detailed information:
# Snakemake log
cat /output/.snakemake/log/*.log
# Job-specific logs
cat /output/.snakemake/log/<job_name>/*.log
Resource Management¶
Memory Limits¶
Set memory constraints:
Thread Control¶
Control threading per job:
Time Limits¶
Set maximum execution time for cluster jobs.
Workflow Visualization¶
DAG Visualization¶
Generate workflow graph:
Rule Graph¶
Show rule dependencies:
Troubleshooting¶
Failed Jobs¶
When jobs fail:
- Check log files in
.snakemake/log/ - Re-run with
--verbosefor detailed output - Use
--printshellcmdsto see exact commands - Check input file existence and permissions
Cleaning Up¶
Remove intermediate files:
# Clean specific outputs
pixi run spimquant ... --delete-temp-output
# Clean all outputs (use with caution)
pixi run spimquant ... --delete-all-output
Lock Files¶
If workflow is interrupted, remove locks:
Best Practices¶
- Always dry run first: Use
-nto validate - Monitor resources: Watch memory and CPU usage
- Use checkpoints: Save intermediate results
- Clean temp files: Free disk space after completion
- Generate reports: Document your workflow execution
Next Steps¶
- Group Analysis: Statistical comparisons
- Cloud Processing: Scale to cloud infrastructure
- Examples: Complete workflow examples