def filter_sessions(session_df, options):
    """Create a set of filters to restrict sessions"""
    lcl = locals()
    lcl.update(options)
    full_query = []
    if options.get('device_id'):
        full_query.append('device_id == @device_id')
    if options.get('empatica_id'):
        full_query.append('id == @empatica_id')
    if options.get('participant_id'):
        full_query.append('participant_id == @participant_id')
    if options.get('start_date'):
        full_query.append('start_datetime >= @start_date')
    if options.get('end_date'):
        full_query.append('start_datetime <= @end_date')
    if options.get('n_recent'):
        n_recent = options['n_recent']
    else:
        n_recent = session_df.shape[0]
    if options.get('query'):
        full_query.append(' & '.join(options['query']))
    if len(full_query):
        session_df.query(' & '.join(full_query), inplace=True)
    session_df = session_df.iloc[-n_recent:]
    return session_df
