ZeroDivisionError with combine.py for multi-echo fMRI

I have multi-echo data that I’m working with (new to fmriprep and tedana). It seems like I’m having an issue with the combination step of tedana, getting this error:

Standard error:
/usr/local/miniconda/lib/python3.7/site-packages/sklearn/utils/init.py:4: DeprecationWarning: Using or importing the ABCs from ‘collections’ instead of from ‘collections.abc’ is deprecated, and in 3.8 it will stop working
from collections import Sequence
INFO:tedana.workflows.t2smap:Using output directory: /tmp/work/fmriprep_wf/single_subject_01_wf/func_preproc_ses_1_task_rest_echo_1_wf/bold_t2smap_wf/t2smap_node
INFO:tedana.workflows.t2smap:Loading input data: [’/tmp/work/fmriprep_wf/single_subject_01_wf/func_preproc_ses_1_task_rest_echo_1_wf/skullstrip_bold_wf/bold_file…data…sub-01…ses-1…func…sub-01_ses-1_task-rest_echo-1_bold.nii.gz/apply_mask/vol0000_xform-00000_merged_masked.nii.gz’, ‘/tmp/work/fmriprep_wf/single_subject_01_wf/func_preproc_ses_1_task_rest_echo_1_wf/skullstrip_bold_wf/bold_file…data…sub-01…ses-1…func…sub-01_ses-1_task-rest_echo-2_bold.nii.gz/apply_mask/vol0000_xform-00000_merged_masked.nii.gz’, ‘/tmp/work/fmriprep_wf/single_subject_01_wf/func_preproc_ses_1_task_rest_echo_1_wf/skullstrip_bold_wf/bold_file…data…sub-01…ses-1…func…sub-01_ses-1_task-rest_echo-3_bold.nii.gz/apply_mask/vol0000_xform-00000_merged_masked.nii.gz’]
INFO:tedana.workflows.t2smap:Computing adaptive mask
INFO:REPORT:An adaptive mask was then generated, in which each voxel’s value reflects the number of echoes with ‘good’ data.
INFO:tedana.workflows.t2smap:Computing adaptive T2* map
INFO:REPORT:A monoexponential model was fit to the data at each voxel using nonlinear model fitting in order to estimate T2* and S0 maps, using T2*/S0 estimates from a log-linear fit as initial values. For each voxel, the value from the adaptive mask was used to determine which echoes would be used to estimate T2* and S0. In cases of model fit failure, T2*/S0 estimates from the log-linear fit were retained instead.
INFO:tedana.workflows.t2smap:Computing optimal combination
INFO:tedana.combine:Optimally combining data with voxel-wise T2* estimates
INFO:REPORT:Multi-echo data were then optimally combined using the T2* combination method (Posse et al., 1999).
INFO:REFERENCES:Posse, S., Wiese, S., Gembris, D., Mathiak, K., Kessler, C., Grosse‐Ruyken, M. L., … & Kiselev, V. G. (1999). Enhancement of BOLD‐contrast sensitivity by single‐shot multi‐echo functional MR imaging. Magnetic Resonance in Medicine: An Official Journal of the International Society for Magnetic Resonance in Medicine, 42(1), 87-97.
Traceback (most recent call last):
File “/usr/local/miniconda/bin/t2smap”, line 10, in
sys.exit(_main())
File “/usr/local/miniconda/lib/python3.7/site-packages/tedana/workflows/t2smap.py”, line 256, in main
t2smap_workflow(**kwargs)
File “/usr/local/miniconda/lib/python3.7/site-packages/tedana/workflows/t2smap.py”, line 231, in t2smap_workflow
combmode=combmode)
File “/usr/local/miniconda/lib/python3.7/site-packages/tedana/combine.py”, line 190, in make_optcom
data[echo_idx, :echo, :], tes[:, :echo], t2s
[echo_idx, …])
File “/usr/local/miniconda/lib/python3.7/site-packages/tedana/combine.py”, line 58, in _combine_t2s
combined = np.average(data, axis=1, weights=alpha)
File “/usr/local/miniconda/lib/python3.7/site-packages/numpy/lib/function_base.py”, line 386, in average
“Weights sum to zero, can’t be normalized”)
ZeroDivisionError: Weights sum to zero, can’t be normalized
Return code: 1

Hi @QuintinFrerichsWUSTL,

The ZeroDivisionError is a known issue in tedana (see ME-ICA/tedana#513). It seems to happen fairly randomly due to estimated T2* values very close to zero. We have solved it in our current version on GitHub, but we haven’t made a release since then. We will try to make a release soon, after which we can update fMRIPrep’s requirements to use that version.

I hope that helps.

Best,
Taylor

Thanks, this makes sense. I’ll just wait on that until the new update is pushed. Appreciate the help!

MANAGED BY INCF