jdtuck / fdasrsf_python

elastic fda python code
http://research.tetonedge.net
BSD 3-Clause "New" or "Revised" License
52 stars 18 forks source link

Error while implementing align_fPCA #4

Closed akashsaha06 closed 4 years ago

akashsaha06 commented 4 years ago

I have installed fdasrsf using pip install. While trying out align_fPCA, I am encountering the following error: `--------------------------------------------------------------------------- IndexError Traceback (most recent call last)

in 1 t = np.linspace(0, T, len(fLA[0])) 2 f = np.asarray(fLA) ----> 3 obj = fdasrsf.align_fPCA(f.T, t, num_comp=3, showplot=False, smoothdata=False) /opt/anaconda3/envs/pipenv/lib/python3.7/site-packages/fdasrsf/time_warping.py in align_fPCA(f, time, num_comp, showplot, smoothdata) 981 # Get Final PCA 982 mididx = np.round(time.shape[0] / 2) --> 983 m_new = np.sign(fn[mididx, :]) * np.sqrt(np.abs(fn[mididx, :])) 984 mqn2 = np.append(mqn, m_new.mean()) 985 qn2 = np.vstack((qn, m_new)) IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices` This error appears after updating step: r=50, possibly because of `np.round(time.shape[0] / 2)`. Is there a way around this to obtain functional principal components of group of functions.
jdtuck commented 4 years ago

so align_fPCA is not what you want, it aligns to the principal components. If your data is not aligned you first want to create an fdawarp object and use the srsf_align method to align. You then can use the fdajpca to extract them. Have you read the corresponding papers for this package?

akashsaha06 commented 4 years ago

I am going through the corresponding papers for the package. I would follow the steps provided. Thanks.