'load_bids_event' not working

Hi, I am trying to apply the load_bids_event and getting an error that I can’t figure out… I have gone through the link below and tried both the absolute and relative path but it is not working…

When I used the relative path it is showing me the error below…

cwd = os.getcwd()  # Get the current working directory (cwd)

data_dir = '../data/Localizer/'
layout = BIDSLayout(data_dir, derivatives=True)

def load_bids_events(layout, subject):
    '''Create a design_matrix instance from BIDS event file'''
    tr = layout.get_tr()
    n_tr = nib.load(layout.get(subject=subject, scope='raw', suffix='bold')[0].path).shape[-1]

    onsets = pd.read_csv(layout.get(subject=subject, suffix='events')[0].path, sep='\t')
    onsets.columns = ['Onset', 'Duration', 'Stim']
    return onsets_to_dm(onsets, sampling_freq=1/tr, run_length=n_tr)

dm = load_bids_events(layout, 'sub-S01')

IndexError Traceback (most recent call last)
9 return onsets_to_dm(onsets, sampling_freq=1/tr, run_length=n_tr)
—> 11 dm = load_bids_events(layout, ‘sub-S01’)

in load_bids_events(layout, subject)
4 tr = layout.get_tr()
----> 5 n_tr = nib.load(layout.get(subject=subject, scope=‘raw’, suffix=‘bold’)[0].path).shape[-1]
7 onsets = pd.read_csv(layout.get(subject=subject, suffix=‘events’)[0].path, sep=‘\t’)

IndexError: list index out of range

Would really appreciate any help… Regards