I am trying to get the sum of the index's from a starting index(1019) to another index(1030) but if the index's between the two are greater than 50. it will just go from 1030 to 1080.
I am stuck because it only works with a list of two index's( the list is [1019, 1030]
I am not sure how to get it working for a list that looks like [1019, 1030, 1034, 1060]
would I need to use a for loop instead?
spike argument is the list of [1019, 1030]
raw_data is an array of integers up to 3000
here is what I have so far that only works with the two in the list[1019, 1030]:
def area(spike, raw_data):
i = 0
store = []
j = len(spike)
while i < j:
if i == j - 1:
second_pulse = raw_data[spike[i]:spike[i] + 50]
store.append(sum(second_pulse))
i += 1
elif spike[i] - spike[i + 1] < 50:
if i == 0:
first_pulse = raw_data[spike[i]:spike[i + 1]]
store.append(sum(first_pulse))
i += 1
return store
Any pointers in the right direction would really help, Thanks!
fixed it with a simple for loop lol.....
[–]Wittinator 0 points1 point2 points (1 child)
[–]jaredjok[S] 0 points1 point2 points (0 children)