global_score] = viterbi_path_log(log(Prior), log(Transition_matrix),
                                          log_observ_likelihood)
        #[path, predecessor_state_index, global_score] =  viterbi_path(Prior, Transition_matrix, observ_likelihood)

        # Some gestures are not within the vocabulary
        [pred_label, begin_frame, end_frame, Individual_score,
         frame_length] = viterbi_colab_clean(path,
                                             global_score,
                                             threshold=-100,
                                             mini_frame=19)

        #begin_frame = begin_frame + 1
        end_frame = end_frame + 5  # note here 3DCNN should add 5 frames because we used 4 frames
        ### plot the path and prediction
        if False:
            im = imdisplay(global_score)
            plt.imshow(im, cmap='gray')
            plt.plot(range(global_score.shape[-1]),
                     path,
                     color='c',
                     linewidth=2.0)
            plt.xlim((0, global_score.shape[-1]))
            # plot ground truth
            gesturesList = smp.getGestures()
            for gesture in gesturesList:
                # Get the gesture ID, and start and end frames for the gesture
                gestureID, startFrame, endFrame = gesture
                frames_count = numpy.array(range(startFrame, endFrame + 1))
                pred_label_temp = (
                    (gestureID - 1) * 10 + 5) * numpy.ones(len(frames_count))
                plt.plot(frames_count,
        log_observ_likelihood[-1, 0:5] = 0
        log_observ_likelihood[-1, -5:] = 0

        print("\t Viterbi path decoding " )
        # do it in log space avoid numeric underflow
        [path, predecessor_state_index, global_score] = viterbi_path_log(log(Prior), log(Transition_matrix), log_observ_likelihood)
        #[path, predecessor_state_index, global_score] =  viterbi_path(Prior, Transition_matrix, observ_likelihood)
        
        # Some gestures are not within the vocabulary
        [pred_label, begin_frame, end_frame, Individual_score, frame_length] = viterbi_colab_clean(path, global_score, threshold=-100, mini_frame=19)

        #begin_frame = begin_frame + 1
        end_frame = end_frame + 5 # note here 3DCNN should add 5 frames because we used 4 frames
        ### plot the path and prediction
        if True:
            im  = imdisplay(global_score)
            plt.clf()
            plt.imshow(im, cmap='gray')
            plt.plot(range(global_score.shape[-1]), path, color='c',linewidth=2.0)
            plt.xlim((0, global_score.shape[-1]))
            # plot ground truth
            gesturesList=smp.getGestures()
            for gesture in gesturesList:
            # Get the gesture ID, and start and end frames for the gesture
                gestureID,startFrame,endFrame=gesture
                frames_count = numpy.array(range(startFrame, endFrame+1))
                pred_label_temp = ((gestureID-1) *10 +5) * numpy.ones(len(frames_count))
                plt.plot(frames_count, pred_label_temp, color='r', linewidth=5.0)
            
            # plot clean path
            for i in range(len(begin_frame)):