Skip to content

Commit

Permalink
added merge_low_imfs
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcw authored Dec 7, 2023
1 parent 07911d2 commit 2473618
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tmEMD.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,19 @@ def run_tmEMD(Xs, sample_rate, psd_func=get_psd, freqs0=None, pre_emd_mode='eEMD
return it_mask_freqs, it_mix_scores, it_adj_mix_scores, it_consistency_scores, it_is, optimised_mask_freqs, converged



### --- Extra utilities --- ###
def merge_low_imfs(imfs, n_merge):
nImfs = imfs.shape[1]

imfis_merge = np.arange(nImfs)[-n_merge:]
imfis_preserve = np.setdiff1d(np.arange(nImfs), imfis_merge)

imfs_ = []
for imfi in imfis_preserve:
imfs_.append(imfs[:, imfi])
imfs_.append(imfs[:, imfis_merge].sum(axis=1))
imfs_ = np.column_stack(imfs_)
return imfs_


### --- Figures --- ###
Expand Down

0 comments on commit 2473618

Please sign in to comment.