Hi, everyone!
First time poster here :). I was wondering how to print a list or a make a dictionary of all ICA components and their respective variances. The problem seems to be that ica.get_explained_variance_ratio only calculates variance jointly across all the specified components. Also, I am aware that the sum of all variances does not amount to 100% from previous examples :).
for components in range(ica.n_components_):
explained_comp = ica.get_explained_variance_ratio(filt_data, components=[components], ch_type=ch_type)
ratios = explained_var_ratio[ch_type] # this seems to return just cumulative value
print(
f’ICA component {components} explains {ratios}’
)
Output for all components is: ICA component () explains 0.0401906384322992
Thanks for any input or suggestions!
Hi, thanks for your quick response :). I was using the example found in this link, under the title “Looking at the ICA solution” (Repairing artifacts with ICA — MNE 1.7.1 documentation), however, it only calculates cumulative variance of components for specified channels (“mag”, “eeg”), but I would like to see the explained variance ratios of all the chosen components individually for “meg” (if n_components = 20, I would like to make a list/dict of the components and their respective variances. Can you maybe offer some help? Thanks in advance!