Image orientation changed after running tedana

Hello,

I am currently using tedana_wrapper.py to combine multi-echo data. The script runs smoothly, but the optimally combined data appears to be tilted.
Looking at the intermediate files I can see that this happens at the beginning of the script, i.e. after applying 3dZcat (see attached). Would you know why this change in orientation is happening, and is there any way to prevent it? AFNI does mention that I should consider running 3dWarp -deoblique, but this just does the exact same thing to the orientation.

Many thanks
Best regards,
Bram

What version of tedana are you using?

version__=“v2.5 beta11” is stated in my tedana.py file

Hi @bramb !

It sounds like this is the tedana that ships with AFNI which – although it inspired the tedana @tsalo and I work on – is actually quite different in its internals. If there are any folks on here who monitor AFNI questions, they would be the experts on why you’re seeing this image orientation change ! Or you could post on the AFNI message board.

Hope that helps,

Elizabeth

Hi Elizabeth, @emdupre @tsalo

Thank you for your reply. You are correct. I was under the impression that I was using your version after running pip install tedana, but somehow got lost in the process and ended up using the AFNI version.

I created a miniconda environment for running the updated tedana (after pip install it says version 0.0.7).
I am now able to run t2smap, but not tedana:
Traceback (most recent call last):
File “/home/bram/.local/bin/tedana”, line 7, in
from tedana.workflows.tedana import _main
File “/home/bram/.local/lib/python2.7/site-packages/tedana/init.py”, line 8, in
from .due import (due, Doi)
File “/home/bram/.local/lib/python2.7/site-packages/tedana/due.py”, line 19, in
from builtins import str
ImportError: No module named builtins

I am guessing that it has something to do with the environment trying to use python 2.7 (which I don’t understand, because it has version 3.7 installed)?

Just to see what happens with the orientation I ran t2smap, and I can gladly say that the orientation was preserved. Really keen on getting the ‘correct’ tedana to run, would you have any advice?

Many thanks,
Best regards,
Bram

Indeed, tedana requires Python 3. I’m not sure what happened, but my guess is that the Python 3 miniconda environment wasn’t activated when you called pip install tedana?

Hi Taylor,

I tried pip install tedana in both the base environment and tedana environment but ended up with the same error. Running pip install future in the base environment (even though it was already installed in the tedana environment) somehow fixed the problem.

I have tried to run tedana a few times, but the process was killed due to memory error (which seems odd with 32gb RAM/25gb swap space?). I have also tried running it with compressed files but it just seems to get stuck, running for several hours on a single subject dataset:

INFO:tedana.workflows.tedana:Loading input data: [‘rasubj08_func_cap_ET1.nii.gz’, ‘rasubj08_func_cap_ET2.nii.gz’, ‘rasubj08_func_cap_ET3.nii.gz’]
INFO:tedana.workflows.tedana:Computing EPI mask from first echo
INFO:tedana.workflows.tedana:Computing T2* map
INFO:tedana.combine:Optimally combining data with voxel-wise T2 estimates
INFO:tedana.decomposition.eigendecomp:Computing PCA of optimally combined multi-echo data
INFO:tedana.decomposition.eigendecomp:Making initial component selection guess from PCA results
INFO:tedana.combine:Optimally combining data with voxel-wise T2 estimates
INFO:tedana.model.fit:Fitting TE- and S0-dependent models to components

Apologies for the beginner questions. Your help is much appreciated.

Best regards,
Bram

We’ve seen memory issues happen once before, but I think solving the issue kind of fell onto the back burner. I’m sorry to see that it’s affecting your data. We will move it up the queue and try to resolve it soon.

Would you mind sharing some information about your data to make it easier for us to replicate the bug? I’m thinking total file size for one echo, size in X/Y/Z dimensions, and number of TRs should be sufficient.

No problem. Single echo time files are 1.1gb each (696mb compressed). These are relatively long functional runs as we are doing pharmacological fMRI: 36minutes with a TR of 1.6s = 1350 volumes. We are getting 50 slices of 2.2mm (X/Y/Z = 92/92/50)

Not sure it this will be of additional value, but I also get a memory error when running t2smap with --fitmode ts:

INFO:tedana.workflows.t2smap:Loading input data: [‘rasubj08_func_cap_ET1.nii’, ‘rasubj08_func_cap_ET2.nii’, ‘rasubj08_func_cap_ET3.nii’]
INFO:tedana.workflows.t2smap:Creating output directory: /home/bram/TED.rasubj08_func_cap_ET1.capsaicin
INFO:tedana.workflows.t2smap:Using user-defined mask
INFO:tedana.workflows.t2smap:Computing adaptive T2* map
/home/bram/miniconda3/envs/TEDANA/lib/python3.7/site-packages/tedana/decay.py:91: RuntimeWarning: divide by zero encountered in true_divide
t2s = 1. / betas[1, :].T
INFO:tedana.workflows.t2smap:Computing optimal combination
INFO:tedana.combine:Optimally combining data with voxel- and volume-wise T2 estimates
Traceback (most recent call last):
File “/home/bram/miniconda3/envs/TEDANA/bin/t2smap”, line 10, in
sys.exit(_main())
File “/home/bram/miniconda3/envs/TEDANA/lib/python3.7/site-packages/tedana/workflows/t2smap.py”, line 231, in _main
t2smap_workflow(**vars(options))
File “/home/bram/miniconda3/envs/TEDANA/lib/python3.7/site-packages/tedana/workflows/t2smap.py”, line 205, in t2smap_workflow
combmode=combmode)
File “/home/bram/miniconda3/envs/TEDANA/lib/python3.7/site-packages/tedana/combine.py”, line 157, in make_optcom
combined = _combine_t2s(data, tes, t2s)
File “/home/bram/miniconda3/envs/TEDANA/lib/python3.7/site-packages/tedana/combine.py”, line 35, in _combine_t2s
alpha = tes * np.exp(-tes / ft2s)
MemoryError

Hope this helps!
Best regards,
Bram

Hi @emdupre @tsalo,

Did you have any luck fixing the bug?
If there is anything that I could share/do that might help, just let me know.

Best regards,
Bram

Would you mind pulling this branch and running tedana from that to see if it reduces the memory use?

1 Like

This did appear to help, though it mentioned something about not being compatible with the low memory option:

tedana -d rasubj07_func_con_ET1.nii rasubj07_func_con_ET2.nii rasubj07_func_con_ET3.nii -e 10.6 26.08 41.56 --verbose --out-dir saline --lowmem
/home/bram/miniconda3/envs/TEDANA/lib/python3.7/site-packages/sklearn/externals/joblib/init.py:15: DeprecationWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
warnings.warn(msg, category=DeprecationWarning)
INFO:tedana.workflows.tedana:Using output directory: /home/bram/saline
INFO:tedana.workflows.tedana:Loading input data: [‘rasubj07_func_con_ET1.nii’, ‘rasubj07_func_con_ET2.nii’, ‘rasubj07_func_con_ET3.nii’]
INFO:tedana.workflows.tedana:Computing EPI mask from first echo
INFO:tedana.workflows.tedana:Computing T2* map
INFO:tedana.combine:Optimally combining data with voxel-wise T2 estimates
WARNING:tedana.decomposition.pca:Low memory option is not compatible with MLE dimensionality estimation. Switching to Kundu decision tree.
INFO:tedana.decomposition.pca:Computing PCA of optimally combined multi-echo data
INFO:tedana.metrics.kundu_fit:Fitting TE- and S0-dependent models to components
INFO:tedana.selection.tedpca:Performing PCA component selection with Kundu decision tree
INFO:tedana.selection.tedpca:Selected 852 components with Kappa threshold: 16.41, Rho threshold: 21.91
INFO:tedana.decomposition.ica:ICA attempt 1 converged in 488 iterations
INFO:tedana.workflows.tedana:Making second component selection guess from ICA results
INFO:tedana.metrics.kundu_fit:Fitting TE- and S0-dependent models to components
INFO:tedana.metrics.kundu_fit:Performing spatial clustering of components
INFO:tedana.selection.tedica:Performing ICA component selection with Kundu decision tree v2.5
INFO:tedana.io:Writing optimally combined time series: /home/bram/saline/ts_OC.nii
INFO:tedana.io:Variance explained by ICA decomposition: 98.50%

It didn’t run completely because I ran out of disk space with verbose set true, but it definitely got a lot further than the last time. I am only wondering how/if we could get a full T2* timeseries. I was expecting that t2svG.nii would contain the timeseries, but this appears to contain only a single volume/map. I also tried running t2smap with ts mode again, but this still throws a memory error.

That’s good to hear. The warning is expected, because IncrementalPCA doesn’t support MLE dimensionality estimation, so we instead default to the Kundu decision tree for dimensionality reduction.

As you said, you can generate FIT T2*/S0 estimate time series with t2smap. We can look into the memory errors there. However, we don’t support FIT within the tedana workflow because the T2*/S0 estimates are so noisy. We would also recommend not running FIT with only three echoes. I would think that that would require something in the range of 6-8 echoes to get reliable volume-wise T2* and S0 estimates. The default is to generate single T2* and S0 maps representing average values over time.

1 Like