Skip to content

Commit 22fb355

Browse files
author
Murat Bilgel
committed
WIP fix: skip hmc on 3D PET
1 parent 5dce8c8 commit 22fb355

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

petprep/utils/misc.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@ def estimate_pet_mem_usage(pet_fname: str) -> tuple[int, dict]:
7878
nvox = int(np.prod(img.shape, dtype='u8'))
7979
# Assume tools will coerce to 8-byte floats to be safe
8080
pet_size_gb = 8 * nvox / (1024**3)
81-
pet_tlen = img.shape[-1]
81+
82+
if img.ndim == 4:
83+
pet_tlen = img.shape[3]
84+
elif img.ndim == 3:
85+
pet_tlen = 1
86+
else:
87+
raise ValueError('PET image must be 3D or 4D')
88+
8289
mem_gb = {
8390
'filesize': pet_size_gb,
8491
'resampled': pet_size_gb * 4,

petprep/workflows/pet/base.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,6 @@ def init_pet_wf(
166166
all_metadata = [config.execution.layout.get_metadata(file) for file in pet_series]
167167

168168
nvols, mem_gb = estimate_pet_mem_usage(pet_file)
169-
if nvols <= 1 - config.execution.sloppy:
170-
config.loggers.workflow.warning(
171-
f'Too short PET series (<= 5 timepoints). Skipping processing of <{pet_file}>.'
172-
)
173-
return
174169

175170
config.loggers.workflow.debug(
176171
'Creating pet processing workflow for <%s> (%.2f GB / %d frames). '

petprep/workflows/pet/fit.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#
2121
# https://www.nipreps.org/community/licensing/
2222
#
23+
import os
2324
from pathlib import Path
2425

2526
import nibabel as nb
@@ -198,12 +199,17 @@ def init_pet_fit_wf(
198199
)
199200
hmc_buffer = pe.Node(niu.IdentityInterface(fields=['hmc_xforms']), name='hmc_buffer')
200201

202+
if pet_tlen <= 1:
203+
# 3D PET
204+
petref = pet_file
205+
hmc_xforms = Path(os.getenv('FSLDIR')) / 'etc' / 'flirtsch' / 'ident.mat'
206+
config.loggers.workflow.debug('3D PET file - motion correction not needed')
201207
if petref:
202208
petref_buffer.inputs.petref = petref
203-
config.loggers.workflow.debug('Reusing motion correction reference: %s', petref)
209+
config.loggers.workflow.debug('(Re)using motion correction reference: %s', petref)
204210
if hmc_xforms:
205211
hmc_buffer.inputs.hmc_xforms = hmc_xforms
206-
config.loggers.workflow.debug('Reusing motion correction transforms: %s', hmc_xforms)
212+
config.loggers.workflow.debug('(Re)using motion correction transforms: %s', hmc_xforms)
207213

208214
timing_parameters = prepare_timing_parameters(metadata)
209215
frame_durations = timing_parameters.get('FrameDuration')

0 commit comments

Comments
 (0)