How to use arguments validation functions for multi-frame images?

조회 수: 1 (최근 30일)
Wei Yow
Wei Yow 2023년 6월 7일
댓글: Wei Yow 2023년 6월 8일
Hi, I am designing a function to analyse an image sequence frame by frame to return a vector of time according to the cardiac cycle. For the image file argument validation, how do I customise a validation function for these two purposes:
1) ensure each sequence have a reasonable duration (number of frames, minimum 75 frames in total) 2) must be a 3D array
Thanks in advance!
function peaktimes = detectCardiacPhase(img, frameRate)
arguments
img (:,:,:) {mustBeNumeric}
frameRate double {mustBePositive} = 15 %default value of frameRate is 15 frames/sec
end
end

채택된 답변

Ashutosh
Ashutosh 2023년 6월 8일
From what I am understanding, you need your function to perform 2 preliminary checks on any input video (or in other words, image sequence) file:
  1. Video file must have at least 75 frames, ie the sequence must have at least 75 images.
  2. The image sequence must be 3 dimensional. I am assuming you mean each image is 2 dimensional and each image in the sequence is stacked on top of each other to make the sequence 3 dimensional. Hence the third dimension (or depth) of the sequence is equal to the number of frames in sequences
I will admit I am not entirely sure I got these right, so let me know if something is amiss.
You can check the 2 conditions as follows:
function peaktimes = detectCardiacPhase(img, frameRate)
errorMsg1 = "The entered sequence is not 3D";
errorMsg2 = "The entered sequence is too short";
if length(size(img)) ~= 3 % check if input is 3D
error(errorMsg1);
elseif size(img,3) < 75 % check if there are at least 75 frames
error(errorMsg2);
end
% main
% function
end
You can also refer to the documentation for the error function.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by