function [amplitudes, sweep_cut] = gb_background_activity(cfg, data) sweep_start = round(cfg.start_time*cfg.SR); sweep_end = round(cfg.end_time*cfg.SR); for x = 1:length(cfg.sp_trigger) sweep_points{x} = sweep_start+cfg.sp_trigger(x):cfg.sp_trigger(x)+sweep_end; sweep_cut{x} = data(sweep_points{x}); %plot(sweep_cut{x}) switch cfg.analysis case 'p2p' MEP_max{x} = max(sweep_cut{x}); MEP_min{x} = min(sweep_cut{x}); amplitudes(x,1) = MEP_max{x} - MEP_min{x}; case 'mean' amplitudes(x,1) = mean(sweep_cut{x}); case 'median' amplitudes(x,1) = median(sweep_cut{x}); case 'sum' amplitudes(x,1) = sum(sweep_cut{x}); end end