Skip to content

Commit 092ebc7

Browse files
committed
Free intermediate arrays in QC workflow to reduce peak memory
The QC stage held onto full 4D BOLD arrays (pre-denoising) and nibabel image objects long after they were needed, causing OOM kills on memory-constrained SLURM jobs (e.g. 16 GB).
1 parent a5cc10e commit 092ebc7

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/rbc/workflows/qc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def single_session_qc(
9999
pre_data = pre_img.get_fdata()
100100
tmpl_mask = tmpl_mask_img.get_fdata()
101101
dvars_init = dvars_qc_metrics(pre_data, tmpl_mask, fd)
102+
del pre_img, pre_data, tmpl_mask_img
102103

103104
# 5. Coregistration overlap (BOLD mask warped to anat space vs anat brain mask)
104105
bold_mask_in_anat = fsl.flirt(
@@ -124,6 +125,7 @@ def single_session_qc(
124125
mni_mask_img = resample_from_to(mni_mask_img, tmpl_brain_img, order=0)
125126
mni_mask_arr = mni_mask_img.get_fdata()
126127
tmpl_brain_arr = tmpl_brain_img.get_fdata()
128+
del tmpl_brain_img, mni_mask_img
127129
norm = registration_qc_metrics(tmpl_brain_arr, mni_mask_arr)
128130

129131
qc_outputs = QCOutputs()

0 commit comments

Comments
 (0)