You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: DetectionResult.m
    path of file: ./repos/WDK/3-EventDetection/helper
    
    the code of the file until where you have to start completion: %contains arrays of ManualEvents: goodEvents, missedEvents, badEvents
classdef DetectionResult < handle
    properties
        goodEvents;%array of Event
        missedEvents;%array of EventAnnotation
        badEvents;%array of
    
function eventsPerClass = NumEventsPerClass(events,nClasses)
            countMap = containers.Map('KeyType','double','ValueType','double');
            
            for i = 1 : length(events)
                event = events(i);
                label = event.label;
                if isKey(countMap,label)
                    countMap(label) = countMap(label) + 1;
                else
                    countMap(label) = 1;
                end