/
Smoothing Timetrends

Smoothing Timetrends

Moving average

  • CSPM (from SPM12) includes a function that will create a moving average.
  • Start CSPM (to add the folder to the path)
  • Load the variable into matlab (see here for details).
  • Get the variable name of the timetrend
  • Set the number of samples over which to calculate the average
>> num_samples4window = 20;
  • Run the following command
    • "t" is the name of the timetrend variable in matlab workspace
>> tma = movingaverage( t, num_samples4window )

The filtered timetrend is saved in the variable "tma"

To view the results, run the following commands:

>> figure('Name','Before/after smoothing')
>> plot(t,'b')
>> hold on
>> plot(tma,'r')
>> legend {'Original' 'Smoothed'}

To save, either copy the smoother timetrend values from the command window, or use the save command with the -ascii option:

>> save smoothed_tt.txt tma -ascii

Related content

peakdetection_gui
peakdetection_gui
More like this
Import Data into a MATLAB Variable
Import Data into a MATLAB Variable
More like this
CSPM Physiology
CSPM Physiology
More like this
Power spectra
Power spectra
More like this
peakdetection command line
peakdetection command line
More like this
CSPM for analysis
CSPM for analysis
More like this