endpoints/bradykinesia_endpoints.py
def calculate_hand_movement_bout_lengths(data):
    '''
    Calculate bout lengths of no hand movement and hand movement
    :param data: Predicted hand movement - binary predictions (1 = hand movement, 0 = no hand movement).
    :return: bout lengths of no hand movement (list), bout lengths of hand movement (list)
    '''
    count_0 = 0
    count_1 = 0
    no_hand_movement_bouts = []
    hand_movement_bouts = []
    for idx, i in enumerate(data):
        if i == 0:
            count_1 = 0
            count_0+=1
            if idx+1<len(data):
                if data[idx+1]==1:
                    no_hand_movement_bouts.append(count_0)
        if i == 1:
            count_1+=1
            count_0 = 0
            if idx+1<len(data):
                if data[idx+1]==0:
                    hand_movement_bouts.append(count_1)

        if idx+1 == len(data):
            if count_0>0:
                no_hand_movement_bouts.append(count_0)
            if count_1>0:
                hand_movement_bouts.append(count_1)

    return no_hand_movement_bouts, hand_movement_bouts

    Calculate bout lengths of no hand movement and hand movement
    :param data: Predicted hand movement - binary predictions (1 = hand movement, 0 = no hand movement).
    :return: bout lengths of no hand movement (list), bout lengths of hand movement (list)
    
Calculate bout lengths of no hand movement and hand movement
Calculate bout lengths of no hand movement and hand movement
def calculate_hand_movement_bout_lengths(data):
    count_0 = 0
    count_1 = 0
    no_hand_movement_bouts = []
    hand_movement_bouts = []
    for idx, i in enumerate(data):
        if i == 0:
            count_1 = 0
            count_0+=1
            if idx+1<len(data):
                if data[idx+1]==1:
                    no_hand_movement_bouts.append(count_0)
        if i == 1:
            count_1+=1
            count_0 = 0
            if idx+1<len(data):
                if data[idx+1]==0:
                    hand_movement_bouts.append(count_1)
        if idx+1 == len(data):
            if count_0>0:
                no_hand_movement_bouts.append(count_0)
            if count_1>0:
                hand_movement_bouts.append(count_1)
    return no_hand_movement_bouts, hand_movement_bouts
def calculate_hand_movement_bout_lengths ( data ) : count_0 = 0 count_1 = 0 no_hand_movement_bouts = [ ] hand_movement_bouts = [ ] for idx , i in enumerate ( data ) : if i == 0 : count_1 = 0 count_0 += 1 if idx + 1 < len ( data ) : if data [ idx + 1 ] == 1 : no_hand_movement_bouts . append ( count_0 ) if i == 1 : count_1 += 1 count_0 = 0 if idx + 1 < len ( data ) : if data [ idx + 1 ] == 0 : hand_movement_bouts . append ( count_1 ) if idx + 1 == len ( data ) : if count_0 > 0 : no_hand_movement_bouts . append ( count_0 ) if count_1 > 0 : hand_movement_bouts . append ( count_1 ) return no_hand_movement_bouts , hand_movement_bouts
Calculate bout lengths of no hand movement and hand movement
Calculate bout lengths of no hand movement and hand movement
'''
    Calculate bout lengths of no hand movement and hand movement
    :param data: Predicted hand movement - binary predictions (1 = hand movement, 0 = no hand movement).
    :return: bout lengths of no hand movement (list), bout lengths of hand movement (list)
    '''
bout lengths of no hand movement (list), bout lengths of hand movement (list)
bout lengths of no hand movement ( list ) bout lengths of hand movement ( list )
data
Predicted hand movement - binary predictions (1 = hand movement, 0 = no hand movement).
Predicted hand movement - binary predictions ( 1 = hand movement 0 = no hand movement ) .