# PCA explained variance from scout time series

Hello,

I am extracting the scout time series (Brainnetome atlas) from source signal with PCA method. I was wondering if there was a way to get for each scout the value of the variance explained by the first PC in the ROI as a whole and also for each vertex.

Is there a way to obtain this in a matrix? Thank you for your time!

Regards,
Angelantonio

Hello @angelantonio

For the moment, this value is not saved. However when extracting the scout time series it is printed in the Matlab Command Window as:

• For constrained sources, the explained variance value is printed for each scout. E.g.:
`BST> First component explains 40.3438% of the signal of cluster Cont_Cing_1 L.`

• For unconstrained sources, only the explained variance value for last dimension (Z) for each scout is printed. E.g.:
`BST> First component explains 83.5981% of the signal of cluster Cont_Cing_1 L.`

• In case of using PCA to flat a Unconstrained source map, the explained variance value only for the last vertex in the source map is shown. E.g.:
`First component explains 68.8834% of the signal.`

We are currently in the process to update how PCA is computed in Brainstorm. Including the storage of the explained variance values may be a good option for that PCA revamping. Any thought @Marc.Lalancette?

Best,
Raymundo

Hello, indeed as Raymundo said, what's displayed is a bit bugged right now, but it should improve when we update the PCA. I don't think we'll store the values as it's not really compatible with our Brainstorm structures, but it should be fairly easy to recompute if needed.

If `Scout` is your scout PCA time series, and `Sources` is the original array of time series for each vertex in that scout, then the total variance "explained" is:
`sum(Scout.^2,2) / sum(sum(Sources.^2,2));`
while for each vertex, it would be this:
`(Sources * Scout').^2 ./ sum(Sources.^2,2) / sum(Scout.^2,2);`

You can get the data by right clicking in the Brainstorm tree, "file", "export to matlab". Then the actual data is in the "F" field. But it's a little bit more complicated because you need the indices of the vertices for the scout, which give you the rows of the F matrix. Sorry if it's not clear enough, feel free to ask for more details. 