Creating an annotation list using time stamps
I have ECG data of length 230897 and sampling frequency=100hz. I would like to create an annotation list (of length 230897) corresponding to the timestamps and duration (in seconds) of the arrhythmia event (sequence of 1's):
timestamps                                  duration
2014-09-10T22:10:20.000000000                 3.5
2014-09-10T23:10:10.000000000                 4
2014-09-10T23:50:20.000000000                 6

FOr example: the annotation list should be of length 230897 and at '2014-09-10T22:10:20.000000000' there should be 1's for 3.5 seconds; at'2014-09-10T23:10:10.000000000' 1's for 4 seconds and so on. This is what I have tried so far and unfortunately, it is not working:
start_time= '2014-09-10T21:01:10.000000000'
data_length=230897
annot_list = np.zeros(data_length)

prev=0, fs=100
for t in timestamps:
        time_diff = t - prev
        seconds = time_diff.astype('timedelta64[s]').astype(np.int32)
        total_cov = seconds*fs
        i1 = i0 + total_cov
        i0, i1 = int(i0), int(i1)
        annot_list[i0:i1] = 1.0
        i0 = i1
        prev = t

Can someone please help me here?

Assuming that your data looks like that:
timestamps = [np.datetime64(&quot;2014-09-10T22:10:20.000000000&quot;),
    np.datetime64(&quot;2014-09-10T23:10:10.000000000&quot;),
    np.datetime64(&quot;2014-09-10T23:50:20.000000000&quot;)]

durations = [3.5,4,6]

Then, you can simply iterate over your list and caluclate your start index and your stop index from your start time, your timestamp and your duration, like so:
start_time = np.datetime64(&quot;2014-09-10T21:01:10.000000000&quot;)
data_length = 2308970
annot_list = np.zeros(data_length)
freq = 100

for timestamp, duration in zip(timestamps, durations):
    time_from_start = int(
        freq * (np.timedelta64(timestamp - start_time, &quot;s&quot;).astype(&quot;float32&quot;))
    )
    duration = int(freq * duration)
    annot_list[time_from_start : time_from_start + duration] = 1

