@requires_sklearn
def test_ica_rank_reduction():
 raw = read_raw_fif(raw_fname).crop(0.5, stop).load_data()
 picks = pick_types(raw.info, meg=True, stim=False, ecg=False, eog=False, exclude='bads')[:10]
 n_components = 5
 max_pca_components = len(picks)
 for n_pca_components in [6, 10]:
  with warnings.catch_warnings(record=True):
   warnings.simplefilter('always')
   ica = ICA(n_components=n_components, max_pca_components=max_pca_components, n_pca_components=n_pca_components, method='fastica', max_iter=1).fit(raw, picks=picks)
  rank_before = raw.estimate_rank(picks=picks)
  assert_equal(rank_before, len(picks))
  raw_clean = ica.apply(raw.copy())
  rank_after = raw_clean.estimate_rank(picks=picks)
  assert_true((n_components < n_pca_components <= rank_after <= rank_before))

@ requires_sklearn def test_ica_rank_reduction ( ) : raw = read_raw_fif ( raw_fname ) . crop ( 0.5 , stop ) . load_data ( ) picks = pick_types ( raw . info , meg = True , stim = False , ecg = False , eog = False , exclude = 'bads' ) [ : 10 ] n_components = 5 max_pca_components = len ( picks ) for n_pca_components in [ 6 , 10 ] : with warnings . catch_warnings ( record = True ) : warnings . simplefilter ( 'always' ) ica = ICA ( n_components = n_components , max_pca_components = max_pca_components , n_pca_components = n_pca_components , method = 'fastica' , max_iter = 1 ) . fit ( raw , picks = picks ) rank_before = raw . estimate_rank ( picks = picks ) assert_equal ( rank_before , len ( picks ) ) raw_clean = ica . apply ( raw . copy ( ) ) rank_after = raw_clean . estimate_rank ( picks = picks ) assert_true ( ( n_components < n_pca_components <= rank_after <= rank_before ) )
test recovery ica rank reduction .