<div dir="ltr">hello,<div><br></div><div>I'm having trouble getting Fieldtrip (revision 8108d99ee.) to reliably use Matlab's builtin signal toolbox, rather than the one in Fieldtrip/external/signal. I followed the online suggestions (<a href="https://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path/">https://www.fieldtriptoolbox.org/faq/should_i_add_fieldtrip_with_all_subdirectories_to_my_matlab_path/</a>) and checked the info surrounding ft_defaults.</div><div><br></div><div>Background: Matab's filtfilt is about twice as fast as Fieldtrip's, which would make a big difference for our overnight sleep EEG. I tested a bandpass filter on a small recording while explicitly adding/removing <i>Fieldtrip/external/signal</i> from the path (as NOT recommended, I know). Doing this right before filtfilt is called (from ft_preprocessing -> preproc -> ft_preproc_bandpassfilter -> filter_with_correction, line 73):</div><div><br></div><div><div>Fieldtrip</div><div><i>tic;filt = filtfilt(B, A, dat')';toc<br>Elapsed time is 7.384431 seconds.</i></div></div><div><br></div><div>Matlab</div><div><i>tic;filt = filtfilt(B, A, dat')';toc<br>Elapsed time is 3.328224 seconds.</i><br></div><div><i><br></i></div><div>I get similar speedups when timing ft_preprocessing, different filters, and for (much) larger datasets, so definitely worth it.</div><div><br></div><div>Now I try to do things the recommended way from a fresh Matlab session (with all Fieldtrip-related stuff removed from startup.m).</div><div><br></div><div>First I check:</div><div><br></div><div><i>which -all filtfilt<br></i></div><div><i>C:\Program Files\MATLAB\R2020a\toolbox\signal\signal\filtfilt.m</i></div><div><br></div><div>Then I initialize Fieldtrip:</div><div><br></div><div><i>addpath(myPathToFieldtrip)<br>ft_defaults</i><br></div><div><br></div><div>and check filtfilt again:</div><div><i>which -all filtfilt<br>longPathToFieldtrip\external\signal\filtfilt.m<br>C:\Program Files\MATLAB\R2020a\toolbox\signal\signal\filtfilt.m            %Shadowed</i><br></div><div><br></div><div>which makes sense since the default is to use Fieldtrip's filtfilt.</div><div><br></div><div>I then do as suggested:</div><div><br></div><div><i>global ft_default<br>ft_default.toolbox.signal='matlab';</i><br><br></div><div>and can verify that the global var is correctly set:</div><div><i>ft_default.toolbox<br></i></div><div><i><br></i></div><div><i>ans =  </i></div><div><i>struct with fields:<br><br>     images: 'compat'<br>      stats: 'compat'<br>     signal: 'matlab'<br>    cleanup: {}</i><br></div><div><i><br></i></div><div>But calling <i>which -all filtfilt </i>again, the Fieldtrip path has not been removed. I tried calling <i>ft_defaults </i>a second time (perhaps in order for the new values in <i>ft_default</i> to take effect?), but both filtfilt paths remain. And I verified that Fieldtrip in fact continues to use its own slow filtfilt implementation when calling <i>ft_preprocessing</i>. So it appears that the contents of <i>ft_default.toolbox</i> aren't actually used to update paths, which may or may not be as intended.</div><div><br></div><div>I have to add that at one (and only one) point during my lengthy explorations Fieldtrip DID pick the requested version (and removed the path to <i>\external\signal\ </i>). But I haven't been able to reproduce since, so this seems to work only under highly specific conditions.</div><div><br></div><div>Explicitly removing the path to <i>\external\signal\ </i>using <i>rmpath</i> seems to work, but is also risky because I imagine Fieldtrip may attempt to restore this path depending on what functions are called elsewhere in a script (especially if the request for using the Matlab version in <i>ft_default.toolbox</i> is missed/ignored).</div><div><br></div><div>Besides physically deleting folders, how do I ensure Fieldtrip ALWAYS uses Matlab's signal (or stats/image) toolboxes and will NEVER attempt to add its own versions back to the Matlab path?</div><div><br></div><div>Thanks,</div><div>Roy</div></div>