To perform multifractal detrended fluctuation analysis using EMD, pass the desired IMF indices to the extensions dictionary in the MFDFA function.
When you provide IMFs via the extensions dictionary (e.g., extensions = {"EMD": [6,7,8]}), the library subtracts those specific IMFs from the timeseries. This effectively sets the polynomial detrending order to 0, as the trend is handled by the EMD components instead of polynomial fitting.
import numpy as np
from MFDFA import MFDFA
# Define the lag range (e.g., from small to long segments)
lag = np.logspace(0.7, 4, 30).astype(int)
# Perform (MF)DFA by declaring which IMFs to subtract via the 'extensions' dictionary
lag, dfa = MFDFA(y, lag=lag, extensions={"EMD": [6,7,8]})