1234567891011121314151617181920212223242526272829303132333435363738 |
- function [sweep_cut, sweep_time,sweep_points] = gb_cutting_sweeps(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});
-
- if isfield(cfg, 'baseline_rectify')
-
- % rectify epoch
- sweep_cut{x} = abs(sweep_cut{x});
-
-
- bs_start = round(cfg.baseline_rectify(1)*cfg.SR);
- bs_end = round(cfg.baseline_rectify(2)*cfg.SR);
-
- bs_points{x} = bs_start+cfg.sp_trigger(x):cfg.sp_trigger(x)+bs_end;
-
- bs_cut{x} = abs(data(bs_points{x}));
-
-
-
-
- % identify mean of the baselined period
- baselined_chunk = mean(bs_cut{x},2);
-
- % subtract the mean from the baselined period from the rectified epoch
- sweep_cut{x} = sweep_cut{x} - baselined_chunk;
- end
- end
- sweep_time = linspace(cfg.start_time,cfg.end_time, length(sweep_points{1})) ;
|