HBClab / NiBetaSeries

Nipype implementation of BetaSeries Correlations (Beta)
https://nibetaseries.readthedocs.io
MIT License
32 stars 28 forks source link

array must not contain infs or NaNs #340

Open KMIsenburg opened 3 years ago

KMIsenburg commented 3 years ago

Is your feature request related to a problem? Please describe. I'm running nibetaseries on a group of 25 subjects, each with 4-6 runs at the participant level. It seems to work for most of the participants and most of the runs, and the output files look food. However, for several runs I get the same error in my crash files (will post an example below). The problem is that the error doesn't tell me which array contains NaNs. I double checked my regressor tsv files and can't find any na/a or NaNs in the columns that I've selected as confounds.

Traceback (most recent call last): File "/opt/miniconda-latest/lib/python3.7/site-packages/nipype/pipeline/plugins/multiproc.py", line 69, in run_node result['result'] = node.run(updatehash=updatehash) File "/opt/miniconda-latest/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 473, in run result = self._run_interface(execute=True) File "/opt/miniconda-latest/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 557, in _run_interface return self._run_command(execute) File "/opt/miniconda-latest/lib/python3.7/site-packages/nipype/pipeline/engine/nodes.py", line 637, in _run_command result = self._interface.run(cwd=outdir) File "/opt/miniconda-latest/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 375, in run runtime = self._run_interface(runtime) File "/opt/miniconda-latest/lib/python3.7/site-packages/nibetaseries/interfaces/nistats.py", line 90, in _run_interface confounds=confounds) File "/opt/miniconda-latest/lib/python3.7/site-packages/nistats/first_level_model.py", line 441, in fit confounds_names, self.min_onset) File "/opt/miniconda-latest/lib/python3.7/site-packages/nistats/design_matrix.py", line 411, in make_first_level_designmatrix matrix, = full_rank(matrix) File "/opt/miniconda-latest/lib/python3.7/site-packages/nistats/utils.py", line 256, in full_rank U, s, V = spl.svd(X, full_matrices=False) File "/opt/miniconda-latest/lib/python3.7/site-packages/scipy/linalg/decomp_svd.py", line 109, in svd a1 = _asarray_validated(a, check_finite=check_finite) File "/opt/miniconda-latest/lib/python3.7/site-packages/scipy/_lib/_util.py", line 239, in _asarray_validated a = toarray(a) File "/opt/miniconda-latest/lib/python3.7/site-packages/numpy/lib/function_base.py", line 496, in asarray_chkfinite "array must not contain infs or NaNs") ValueError: array must not contain infs or NaNs

Describe the solution you'd like It would be helpful to know which file of mine is generating this error/

Describe alternatives you've considered I've tried looking through the tsv files for the confound regressors because I assumed NaNs would be coming from here, but it doesn't seem like it is the issue unless 0s can also generate this error.

Thanks for your help :)

jdkent commented 3 years ago

0s should not generate that error (AFAIK), could you share what your call to nibetaseries looks like and your events file/confounds file for a problematic participant?

KMIsenburg commented 3 years ago

Hi James,

Attached is a screenshot of my script that calls nibetaseries, an events file and the confounds file for a problematic run. Just to note, all of the other runs for this participant worked.

The events file and regressor file are tsv but I changed to txt to allow for upload. Screen Shot 2021-04-29 at 11 07 41 AM

sub-01_ses-1_task-omgspa_run-01_desc-confounds_regressors.txt sub-01_ses-1_task-omgspa_run-01_events.txt

KMIsenburg commented 3 years ago

By the way I want to make a note above, I used more than just white_matter, I also used csf, trans_x, trans_y, trans_z, rot_x, rot_y, rot_z

If I try re-running with just white_matter it works...so the error has to be coming from either csf or one of the movement parameters.

jdkent commented 3 years ago

If you could upgrade to the 0.6.0 release, it may fix the issue you are having, if not, I can take a deeper look: https://hub.docker.com/r/hbclab/nibetaseries/tags?page=1&ordering=last_updated

KMIsenburg commented 3 years ago

Thanks James, let me see what I can do in terms of upgrading!

Tsjitsjikow commented 3 years ago

As posted here: https://neurostars.org/t/error-with-nans-in-nibetaseries/19153/5;

The rotation parameters (as well as others) of your confounds file are incomplete. This is probably causing the issue :-).

KMIsenburg commented 3 years ago

Hi @jdkent I've fixed the issue - somehow some of my tsv files were compromised and parts of the latter rows were completely cut off. All taken care of, thanks !