Skip to content

Commit cadcf25

Browse files
authored
Merge pull request #34 from JosephBrunet/improve-slurm-launcher
Improve slurm launcher
2 parents 14ce24a + da648f2 commit cadcf25

5 files changed

Lines changed: 71 additions & 2 deletions

File tree

docs/advanced/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Pages:
66

77
- [Transmural Analysis](./cardio-analysis.md): Extract transmural profiles from angle and FA maps with `cardio-analysis`.
88
- [Streamlines](./streamlines.md): Generate and visualize 3D streamlines with `cardio-generate-streamlines` and `cardio-visualize-streamlines`.
9+
- [SLURM Launcher](./slurm-launcher.md): Submit chunked `cardio-tensor` jobs on HPC clusters.
910

1011
See also:
1112

docs/advanced/slurm-launcher.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# SLURM Launcher
2+
3+
Use `cardio-tensor-slurm` to submit chunked orientation jobs as SLURM array tasks.
4+
5+
## What It Does
6+
7+
- Splits a dataset into chunks.
8+
- Generates a `.slurm` script.
9+
- Submits one or more SLURM arrays with `sbatch`.
10+
- Monitors output progress.
11+
12+
The launcher calls `cardio-tensor` on each task with:
13+
14+
```bash
15+
cardio-tensor <conf_file> --start_index <start> --end_index <end>
16+
```
17+
18+
## Basic Usage
19+
20+
```bash
21+
cardio-tensor-slurm path/to/parameters.conf
22+
```
23+
24+
## Useful Options
25+
26+
```bash
27+
cardio-tensor-slurm path/to/parameters.conf \
28+
--start_index 0 \ # First slice index (inclusive)
29+
--end_index 5000 \ # Last slice index (exclusive)
30+
--chunk_size 100 \ # Slices processed per SLURM task
31+
--time_limit 4:00:00 \ # Wall-time limit for each task
32+
--cpus_per_task 8 \ # CPU cores requested per task
33+
--mem_gb 64 \ # Memory requested per task (GB)
34+
--array_parallel 50 \ # Max concurrent tasks in the SLURM array
35+
--partition nice \ # Optional partition/queue name
36+
--log_dir /path/to/logs \ # Where SLURM stdout/stderr logs are written
37+
--submit_dir /path/to/slurm_scripts # Where generated .slurm scripts are saved
38+
```
39+
40+
Other useful flags:
41+
42+
- `--no_monitor`: submit jobs and return immediately (do not watch output progress).
43+
- `--dry_run`: generate the `.slurm` script and print `sbatch` command without submitting.
44+
45+
Run help for the full list:
46+
47+
```bash
48+
cardio-tensor-slurm -h
49+
```
50+
51+
## Troubleshooting
52+
53+
- **`sbatch` fails**
54+
Verify partition/account/time/memory policy on your cluster.
55+
56+
- **Job fails before running `cardio-tensor`**
57+
Check logs in `OUTPUT_PATH/slurm/log/`.
58+
59+
- **No progress in monitor**
60+
Confirm output folder permissions and that tasks can write outputs.
61+
62+
- **Want to debug without submitting jobs**
63+
Use `--dry_run`.

docs/reference/cli.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Compute myocyte orientation from a 3D volume using a configuration file.
99
- `cardio-tensor`
1010
Computes structure tensor, helix/transverse angle, FA, and eigenvectors.
1111

12+
- `cardio-tensor-slurm`
13+
Submits chunked `cardio-tensor` runs as SLURM array jobs.
14+
See [SLURM Launcher](../advanced/slurm-launcher.md).
15+
1216
See the [example](../getting-started/examples.md) to get started.
1317

1418
---

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ nav:
3434
- advanced/index.md
3535
- Transmural Analysis: advanced/cardio-analysis.md
3636
- Streamlines: advanced/streamlines.md
37+
- SLURM Launcher: advanced/slurm-launcher.md
3738
- Reference:
3839
- reference/index.md
3940
- CLI Commands: reference/cli.md

paper/paper.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ For non-diffusion imaging modalities, such as micro-CT [@reichardt_fiber_2020],
5959

6060
Cardiotensor addresses this gap by providing an open-source Python package specifically tailored to structure tensor analysis of large cardiac volumes. Rather than relying on diffusion modeling, cardiotensor infers tissue orientation directly from image intensity gradients, making it applicable across a wide range of modalities and scales. Previous studies have demonstrated strong agreement between structure tensor–based orientation and DT-MRI–derived metrics when applied to the same human hearts [@teh_validation_2016]. The package supports full pipelines from raw image stacks to myocyte orientation maps and tractography. Its architecture is optimized for large datasets, using chunked and parallel processing suitable for high-performance computing environments. The overall processing workflow, from input volumes to orientation maps and tractography, is summarized in \autoref{fig:pipeline}.
6161

62-
Cardiotensor has already been successfully applied in published work to characterize 3D cardiomyocyte architecture in healthy and diseased human hearts using synchrotron tomography [@brunet_multidimensional_2024] to datasets over a terabyte in size. While cardiotensor was conceived for cardiac imaging, the package is modality‑ and tissue‑agnostic. Any volumetric dataset exhibiting coherent fibrous microstructure can be analyzed, including brain white matter, skeletal muscle, and tendon. This generality makes the library useful for both cardiovascular and broader anatomical or histological studies.
62+
Cardiotensor has already been successfully applied in published work to characterize 3D cardiomyocyte architecture in healthy and diseased human hearts using synchrotron tomography [@brunet_multidimensional_2024]. In practice, cardiotensor has been applied to whole-heart HiP-CT datasets exceeding 1–5 TB (teravoxel scale). While cardiotensor was conceived for cardiac imaging, the package is modality‑ and tissue‑agnostic. Any volumetric dataset exhibiting coherent fibrous microstructure can be analyzed, including brain white matter, skeletal muscle, and tendon. This generality makes the library useful for both cardiovascular and broader anatomical or histological studies.
6363

6464
![Cardiotensor pipeline for 3D cardiac orientation analysis and tractography.
6565
(a) Input whole‑ or partial‑heart volume with optional myocardial mask.
@@ -70,7 +70,7 @@ The third eigenvector field (smallest eigenvalue) is visualized as arrows color
7070

7171
## Implementation
7272

73-
Cardiotensor is implemented in Python and designed to efficiently process very large 3D cardiac imaging datasets. It relies primarily on NumPy [@van_der_walt_numpy_2011] for numerical computation, with I/O accelerated by tifffile [@gohlke_cgohlketifffile_2025], Glymur [@evans_quintusdiasglymur_2025], and OpenCV [@bradski_opencv_2000]. Dask [@rocklin_dask_2015] is used exclusively to parallelize file reading, while the core computations rely on Python’s multiprocessing module for local parallelism. The package builds on the structure-tensor library [@jeppesen_quantifying_2021] to calculate the 3D structure tensor and eigenvector decomposition.
73+
Cardiotensor is implemented in Python and designed to efficiently process terabyte-scale 3D cardiac imaging datasets. It relies primarily on NumPy [@van_der_walt_numpy_2011] for numerical computation, with I/O accelerated by tifffile [@gohlke_cgohlketifffile_2025], Glymur [@evans_quintusdiasglymur_2025], and OpenCV [@bradski_opencv_2000]. Dask [@rocklin_dask_2015] is used exclusively to parallelize file reading, while the core computations rely on Python’s multiprocessing module for local parallelism. The package builds on the structure-tensor library [@jeppesen_quantifying_2021] to calculate the 3D structure tensor and eigenvector decomposition.
7474

7575
The package supports multiple use cases:
7676

0 commit comments

Comments
 (0)