Hi,
Thank you for the incredible work in bringing all the Homer3 motion correction methods to Cedalion.
I am facing a repeat crashing error while running PCA and PCA recurse (from the main branch of Cedalion github). The other motion correction methods seem to be implementing fine. I am using a few resting state recordings obtained using NIRStar 15.2 from a NIRSport 8x8. The issue is that every-time I run PCA on any subject's data, even with minimal motion artifacts (attached screenshot) and no bad channels, it crashes and throws out the same error (attached error message).
I am running it as:
rec["od_pca"], x , y= motion_correct.motion_correct_PCA(rec["od"], ma_mask_refined,nSV=0.97)
The error message:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[208], line 1
----> 1 rec["od_pca"], x , y= motion_correct.motion_correct_PCA(rec["od"], ma_mask_refined,nSV=0.97)
3 # compare_raw_cleaned(rec, "od_orig", "od", "od_pca", "PCA")
File ~/Documents/Python/Cedalion/cedalion/src/cedalion/sigproc/motion_correct.py:308, in motion_correct_PCA(fNIRSdata, tInc, nSV)
305 yo = y_zscore.copy()
306 c = np.dot(y_zscore.T, y_zscore)
--> 308 V, St, foo = svd(c)
310 svs = St / np.sum(St)
312 svsc = svs.copy()
File ~/miniconda3/envs/cedalion_env/lib/python3.11/site-packages/scipy/linalg/_decomp_svd.py:106, in svd(a, full_matrices, compute_uv, overwrite_a, check_finite, lapack_driver)
13 def svd(a, full_matrices=True, compute_uv=True, overwrite_a=False,
14 check_finite=True, lapack_driver='gesdd'):
15 """
16 Singular Value Decomposition.
17
(...) 104
105 """
--> 106 a1 = _asarray_validated(a, check_finite=check_finite)
107 if len(a1.shape) != 2:
108 raise ValueError('expected matrix')
File ~/miniconda3/envs/cedalion_env/lib/python3.11/site-packages/scipy/_lib/_util.py:537, in _asarray_validated(a, check_finite, sparse_ok, objects_ok, mask_ok, as_inexact)
535 raise ValueError('masked arrays are not supported')
536 toarray = np.asarray_chkfinite if check_finite else np.asarray
--> 537 a = toarray(a)
538 if not objects_ok:
539 if a.dtype is np.dtype('O'):
File ~/miniconda3/envs/cedalion_env/lib/python3.11/site-packages/numpy/lib/_function_base_impl.py:646, in asarray_chkfinite(a, dtype, order)
644 a = asarray(a, dtype=dtype, order=order)
645 if a.dtype.char in typecodes['AllFloat'] and not np.isfinite(a).all():
--> 646 raise ValueError(
647 "array must not contain infs or NaNs")
648 return a
ValueError: array must not contain infs or NaNs
Could someone suggest a fix? I checked for NaNs and infs in the rec["od"] time series and there seem to be none so I am not sure what the issue is here.
Thank you.
Happy new year, Ankit!
We use the main branch for releases, whereas the development happens on the dev branch. The next version is scheduled for end of January and there have been many changes since the last release, including a bug fix to the cedalion.sigproc.motion.pca_recurse method. Could you please try the dev branch to see if this fixes your issue?
Kind regards,
Eike
Hi Eike,
Happy New Year.
I have been attempting to use the dev branch and using different pipelines but still haven't been able to resolve the issue. the PCA, recursive, PCA and spline function crash completely and throw an error suggesting that NaN or inf values were found in the signal (I checked and they weren't there). Is it possible that negative values in OD data tend to throw off the processing by these methods?
Please let me know if there are any workarounds or if there's something I can try.
Thanks.
Warm Regards,
Ankit
Hi Ankit,
would it be possible that you share (either here or by sending it to middell@tu-berlin.de) the data file and the script/notebook so that I could try to reproduce the error?
Greetings,
Eike




