File tree Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Expand file tree Collapse file tree 3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,14 @@ def estimate_pet_mem_usage(pet_fname: str) -> tuple[int, dict]:
78
78
nvox = int (np .prod (img .shape , dtype = 'u8' ))
79
79
# Assume tools will coerce to 8-byte floats to be safe
80
80
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
+
82
89
mem_gb = {
83
90
'filesize' : pet_size_gb ,
84
91
'resampled' : pet_size_gb * 4 ,
Original file line number Diff line number Diff line change @@ -166,11 +166,6 @@ def init_pet_wf(
166
166
all_metadata = [config .execution .layout .get_metadata (file ) for file in pet_series ]
167
167
168
168
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
174
169
175
170
config .loggers .workflow .debug (
176
171
'Creating pet processing workflow for <%s> (%.2f GB / %d frames). '
Original file line number Diff line number Diff line change 20
20
#
21
21
# https://www.nipreps.org/community/licensing/
22
22
#
23
+ import os
23
24
from pathlib import Path
24
25
25
26
import nibabel as nb
@@ -198,12 +199,17 @@ def init_pet_fit_wf(
198
199
)
199
200
hmc_buffer = pe .Node (niu .IdentityInterface (fields = ['hmc_xforms' ]), name = 'hmc_buffer' )
200
201
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' )
201
207
if petref :
202
208
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 )
204
210
if hmc_xforms :
205
211
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 )
207
213
208
214
timing_parameters = prepare_timing_parameters (metadata )
209
215
frame_durations = timing_parameters .get ('FrameDuration' )
You can’t perform that action at this time.
0 commit comments