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: ExtractFrame.m
    path of file: ./repos/ImageM/ImageM/+imagem/+actions/+image
    
    the code of the file until where you have to start completion: classdef ExtractFrame < imagem.actions.TimeLapseImageAction
% Extract a frame from a lime-lapse image.
%
%   Class ExtractFrame
%
%   Example
%   ExtractFrame
%
%   See also
%

% ------
% Author: David Legland
% e-mail: david.legland@inra.fr
% Created: 2019-11-15,    using Matlab 9.7.0.1190202 (R2019b)
% Copyright 201
    
function run(obj, viewer) %#ok<INUSL,INUSD>
        
        % get handle to current doc
        doc = currentDoc(viewer);
        img = doc.Image;

        % determine current slice, and slice number
        currentFrame = viewer.FrameIndex; % assume class 'Image5DViewer'
        nFrames = frameNumber(img);
        
        % open a dialog to choose slice index
        gd = imagem.gui.GenericDialog('Extract Frame');
        frameLabel = sprintf('Frame Index (max %d)', nFrames);
        addNumericField(gd, frameLabel, currentFrame, 0);
        setSize(gd, [300 100]);
        
        showDialog(gd);
        if wasCanceled(gd)
            return;
        end