def detect_Massimini2004(dat_orig, s_freq, time, opts):
    if opts.invert:
        dat_orig = -dat_orig
    dat_det = transform_signal(dat_orig, s_freq, 'double_butter', 
                               opts.det_filt)
    above_zero = detect_events(dat_det, 'above_thresh', value=0.)
    sw_in_chan = []
    if above_zero is not None:
        troughs = within_duration(above_zero, time, opts.trough_duration)
        if troughs is not None:
            troughs = select_peaks(dat_det, troughs, opts.max_trough_amp)
            if troughs is not None:
                events = _add_halfwave(dat_det, troughs, s_freq, opts)
                if len(events):
                    events = within_duration(events, time, opts.duration)
                    events = remove_straddlers(events, time, s_freq)
                    sw_in_chan = make_slow_waves(events, dat_det, time, s_freq)
    if len(sw_in_chan) == 0:
        lg.info('No slow wave found')
    return sw_in_chan