Fmriprep to tedana

multi-echo
fmriprep

#1

Hi NeuroStars,

New to both fmriprep and tedana (& multiecho in general). We’ve been able to successfully run fmriprep on some multiecho data on our cluster (yay!) but are getting the error below when we try to use tedana. It’s not immediately clear to us what this error means (e.g. is it an issue with the data? the preproc? the inputs?). See call below the error. We’ve also tried running without masks and with multiple masks, but don’t feel familiar enough with the other flags to go with anything other than the defaults. Any thoughts/advice greatly appreciated!

[failed] tedana output
attempting to run tedana for sub-06ME

/share/apps/tedana/0.0.4/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.
return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:161: RuntimeWarning: invalid value encountered in true_divide
F_S0 = (alpha - SSE_S0) * (n_echos - 1) / (SSE_S0)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:168: RuntimeWarning: invalid value encountered in true_divide
F_R2 = (alpha - SSE_R2) * (n_echos - 1) / (SSE_R2)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:177: RuntimeWarning: invalid value encountered in greater
F_S0[F_S0 > F_MAX] = F_MAX
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:178: RuntimeWarning: invalid value encountered in greater
F_R2[F_R2 > F_MAX] = F_MAX
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:161: RuntimeWarning: divide by zero encountered in true_divide
F_S0 = (alpha - SSE_S0) * (n_echos - 1) / (SSE_S0)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
“This module will be removed in 0.20.”, DeprecationWarning)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/sklearn/ensemble/weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should not be imported. It will be removed in a future NumPy release.
from numpy.core.umath_tests import inner1d
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/sklearn/grid_search.py:42: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. This module will be removed in 0.20.
DeprecationWarning)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/sklearn/learning_curve.py:22: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the functions are moved. This module will be removed in 0.20
DeprecationWarning)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/scipy/stats/stats.py:2253: RuntimeWarning: invalid value encountered in true_divide
return (a - mns) / sstd
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.
return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/selection/select_comps.py:555: RuntimeWarning: invalid value encountered in greater
np.union1d(np.union1d(all_comps[spz > 1],
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/selection/select_comps.py:628: RuntimeWarning: invalid value encountered in greater
np.union1d(np.union1d(all_comps[spz > 1],
Extremely limited reliable BOLD signal space! Not filtering components beyond BOLD/non-BOLD guesses.
No BOLD components detected! Please check data and results!

tedana call
Echo1=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mid_acq-normal_rec-magnitude_run-01_echo-1_bold_space-MNI152NLin2009cAsym_preproc.nii.gz
Echo2=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mid_acq-normal_rec-magnitude_run-01_echo-2_bold_space-MNI152NLin2009cAsym_preproc.nii.gz
Echo3=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mid_acq-normal_rec-magnitude_run-01_echo-3_bold_space-MNI152NLin2009cAsym_preproc.nii.gz
Echo4=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mid_acq-normal_rec-magnitude_run-01_echo-4_bold_space-MNI152NLin2009cAsym_preproc.nii.gz

    Mask1=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mem_acq-normal_rec-magnitude_run-01_echo-1_bold_space-MNI152NLin2009cAsym_brainmask.nii.gz

    tedana -d ${Echo1} ${Echo2} ${Echo3} ${Echo4} -e 12.2 29.48 46.76 64.04 --mask ${Mask1} --label ${SUBJ_ID}_tedana

#2

Hi @alioco !

It looks like this is something to do with the input data, but it’s hard to say what without looking at the data itself. Is the fmriprep output something you could share ?

tedana is undergoing a bit of an internal overhaul right now, so hopefully this is something we can address internally. If you’re anxious to process in the mean time, I’d recommend either using the afni_proc.py implementation of tedana or using some of the older meica.py code.


#3

Thanks so much, @emdupre !

Let me double check RE sharing the data-- assuming we can, what would be the preferred way for us to do this? In the mean time, will definitely try the implementations you suggested!


#4

Thanks @alioco ! If you have an institutional Box account or something similar and can send a link (Google drive even works great), I’d be able to take a look.


#5

Hi @emdupre , we tried to run tedana on another subject’s multi-echo fmriprep outputs and this time got different errors and are missing most of the derivatives. See log and list of derivatives below. If it would also be helpful to see the fmriprep outputs for this subject, pls let me know!

Thanks!

Log
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[ tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.
return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:161: RuntimeWarning: invalid value encountered in true_divide
F_S0 = (alpha - SSE_S0) * (n_echos - 1) / (SSE_S0)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:168: RuntimeWarning: invalid value encountered in true_divide
F_R2 = (alpha - SSE_R2) * (n_echos - 1) / (SSE_R2)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:177: RuntimeWarning: invalid value encountered in greater
F_S0[F_S0 > F_MAX] = F_MAX
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:178: RuntimeWarning: invalid value encountered in greater
F_R2[F_R2 > F_MAX] = F_MAX
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/fit.py:161: RuntimeWarning: divide by zero encountered in true_divide
F_S0 = (alpha - SSE_S0) * (n_echos - 1) / (SSE_S0)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_select ion module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This modu le will be removed in 0.20.
“This module will be removed in 0.20.”, DeprecationWarning)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/sklearn/ensemble/weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should n ot be imported. It will be removed in a future NumPy release.
from numpy.core.umath_tests import inner1d
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/sklearn/grid_search.py:42: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection m odule into which all the refactored classes and functions are moved. This module will be removed in 0.20.
DeprecationWarning)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/sklearn/learning_curve.py:22: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selectio n module into which all the functions are moved. This module will be removed in 0.20
DeprecationWarning)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/scipy/optimize/minpack.py:436: RuntimeWarning: Number of calls to function has reached maxfev = 1200.
warnings.warn(errors[info][0], RuntimeWarning)
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[ tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.
return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[ tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.
return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval

output files
accepted.txt comp_table_pca.txt dn_ts_OC.nii hik_ts_OC.nii meica_mix.1D midk_ts_OC.nii s0v.nii t2ss.nii tsoc_nogs.nii
betas_hik_OC.nii comp_table.txt dn_ts_OC_T1c.nii hik_ts_OC_T1c.nii meica_mix_T1c.1D pcastate.pkl s0vs.nii t2svG.nii tsoc_orig.nii
betas_hik_OC_T1c.nii csdata.txt feats_OC2.nii lowk_ts_OC.nii mepca_mix.1D rejected.txt sphis_hik.nii t2sv.nii veins_l0.nii
betas_OC.nii csstepdata.json glsig.1D __meica_mix.1D midk_rejected.txt s0vG.nii T1gs.nii ts_OC.nii veins_l1.nii


#6

Hi @alioco ! It looks like those are actually all of the right derivatives – were there others you were expecting ?

I haven’t yet had a chance to look at the files you sent but that is high on my to-do list ! Will update ASAP, but please feel free to post any other errors you come across as well !


#7

Oh, great news! I was under the impression that medn files should be used for task analysis (based on https://tedana.readthedocs.io/en/latest/approach.html#derivatives)- which files should we actually use @emdupre ? tsoc_orig or tsoc_nogs? Sorry if I’m missing the documentation somewhere… Thank you! :slightly_smiling_face:


#8

Those should definitely be updated ! Would you like to open an issue on GitHub for that ?

I’d recommend the dn_ts_OC – this is the optionally combined time series, removing components identified as noise.


#9

hey @emdupre just wanted to give you a quick update-- looks like for a different subject than the one I sent you, we only get the BOLD error for one (of four) runs of data, although it doesn’t say no BOLD components detected just “Extremely limited reliable BOLD signal space! Not filtering components beyond BOLD/non-BOLD guesses.” I can send you this run if you’d like. Turns out for the subject I did send you, we’d specified the mask incorrectly :see_no_evil: so the two mid runs seem fine, but the two mem runs crash with the following error:
attempting to run tedana for sub-06ME

/share/apps/tedana/0.0.4/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.
return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/combine.py:35: RuntimeWarning: divide by zero encountered in true_divide
alpha = tes * np.exp(-tes / ft2s)
Traceback (most recent call last):
File “/share/apps/tedana/0.0.4/bin/tedana”, line 11, in
sys.exit(_main())
File “/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/workflows/tedana.py”, line 447, in _main
tedana_workflow(**vars(options))
File “/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/workflows/tedana.py”, line 387, in tedana_workflow
OCcatd = model.make_optcom(catd, tes, mask, t2s=t2sG, combmode=combmode)
File “/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/combine.py”, line 156, in make_optcom
combined = _combine_t2s(data, tes, t2s)
File “/share/apps/tedana/0.0.4/lib/python3.6/site-packages/tedana/model/combine.py”, line 48, in _combine_t2s
combined = np.average(data, axis=1, weights=alpha)
File “/share/apps/tedana/0.0.4/lib/python3.6/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

Sorry if I’m sending you on a wild goose chase! I’m almost sure we didn’t specify anything incorrectly this time, but here’s the tedana call, just in case:
Echo1=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mem_acq-normal_rec-magnitude_run-01_echo-1_bold_space-MNI152NLin2009cAsym_preproc.nii.gz
Echo2=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mem_acq-normal_rec-magnitude_run-01_echo-2_bold_space-MNI152NLin2009cAsym_preproc.nii.gz
Echo3=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mem_acq-normal_rec-magnitude_run-01_echo-3_bold_space-MNI152NLin2009cAsym_preproc.nii.gz
Echo4=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mem_acq-normal_rec-magnitude_run-01_echo-4_bold_space-MNI152NLin2009cAsym_preproc.nii.gz

    Mask1=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mem_acq-normal_rec-magnitude_run-01_echo-1_bold_space-MNI152NLin2009cAsym_brainmask.nii.gz

Mask2=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mem_acq-normal_rec-magnitude_run-01_echo-2_bold_space-MNI152NLin2009cAsym_brainmask.nii.gz

Mask3=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mem_acq-normal_rec-magnitude_run-01_echo-3_bold_space-MNI152NLin2009cAsym_brainmask.nii.gz

Mask4=${WorkDir}/${fmriprepdir}/fmriprep/${SUBJ_ID}/func/sub-06ME_task-mem_acq-normal_rec-magnitude_run-01_echo-4_bold_space-MNI152NLin2009cAsym_brainmask.nii.gz

    tedana -d ${Echo1} ${Echo2} ${Echo3} ${Echo4} -e 12.2 29.48 46.76 64.04 --mask ${Mask1} --label ${SUBJ_ID}_tedana

#10

Hi @emdupre & neurostars,

I still haven’t been able to get past the “ZeroDivisionError: Weights sum to zero, can’t be normalized” that we see in some of our subjects.

We recently piloted an updated MB/ME sequence and we processed it both with an older version of fmriprep and a newer version, which looks like it has an updated ME-EPI workflow to create the optimal combination of echoes. The latter ran fine, however when using the output of the former followed tedana, we see the “ZeroDivisionError: Weights sum to zero, can’t be normalized” error. Is the combination incorporated into the 1.2.4 release of fmriprep effectively the same as tedana? We were hoping to answer this ourselves by comparing side by side, but unfortunately can’t get past this error.

Thank you!!
ali


#11

Hi @alioco,

This must be coming from a zero value in the T2* map. I wonder if the mask you’re using, taken from echo 4, includes voxels that somehow have zeroes in the preprocessed files. Otherwise, I’m thinking that the adaptive mask created by tedana, which determines how many echoes have “good” signal for each voxel, has a zero somewhere that the mask doesn’t.

Would you be willing to share the mask and preprocessed files for this run?

Best,
Taylor


#12

Hi @alioco,

Sorry for the long delay ! Following up on your question about the optimal combination in fMRIPrep, this is indeed the same one as in tedana. FMRIPrep v1.2.4+ is actually calling tedana to do the optimal combination.

I am curious about the error you’re receiving in tedana, though ! @tsalo’s suggestion is probably the right one, here.


#13

@emdupre No worries, thanks so much for getting back to me, I super appreciate all the guidance and insights! I sent the processed data to @tsalo so hopefully that will be helpful in trying to figure out what’s going on.

Thank you both, again, for all your help and work on these awesome tools in general :hugs:


#14

@alioco It looks like there are a total of 9 voxels with a value of zero in the adaptive mask (i.e., tedana has estimated that none of the echoes have “good” signal for these voxels), but which are included in the first echo’s brain mask. This is a bug that we’ll have to address in tedana, I think. I have raised an issue in the repository and we’ll hopefully be able to push a fix soon.

In the meantime, I would recommend not using an explicit mask for this subject, and then masking the optimally combined and denoised data after the fact. The optimally combined data should be the same for all voxels except those 9, while the denoised data could be somewhat different because spatial information is used in the identification of good and bad components.

@emdupre Does that sound good to you as well?


#15

Yes, that seems reasonable to me. Please let us know if you hit any other issues @alioco !


#16

great, thanks so much @tsalo & @emdupre that seems to have done the trick! are there plans to output the ICs found by tedana from fmriprep now that they have been integrated? sorry if I missed this…


#17

I don’t believe that fMRIPrep runs the full tedana workflow yet, but there are definitely plans to get the full pipeline integrated, which will include writing out the components from the ICA step.

We’re also working on figuring out how best to visually report tedana outputs. Once we have our tedana-specific visual reports figured out, I also imagine that we’ll try to incorporate those figures into the fMRIPrep visual reports.


#18

hi @emdupre & @tsalo

just wanted to update you both that we were able to analyze the data! there do seem to be differences in activations based on whether the data were processed with FMRIPREP v1.2.4 v earlier FMRIPREP (we’ve been using v1.1.8) + tedana (v0.0.5). not sure if there were changes made between fmriprep releases or in the integration that would account for this, but either way figured I’d share.


#19

This is great, thank you for sharing !

I would strongly recommend the integrated optimal combination, as we check to ensure that scaling is applied equally across all voxels (which is really important for calculating individual echo weightings). It’s nice to see, though, that they show similar patterns here !