How to fix error: "Index in position 1 is invalid. Array indices must be positive integers or logical values"

조회 수: 8 (최근 30일)
Hello! I am trying to run an automatic software on MATLAB that converts 2D images of brain slices into a 3D model. I am currently in the "slice outline" phase, but I can't seem to troubleshoot an error that reads "Index in position 1 is invalid. Array indices must be positive integers or logical values." If anyone can help solve this I would really appreciate it! I'll attach the code below:
Full error message:
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in Img_filename_list (line 41)
img_name{(img_idy+(length(Name_Channels)-channel_check))/length(Name_Channels),channel_check}=char(img_names_raw(ii));
Error in STEP_1_Slice_Outline (line 10)
img_name=Img_filename_list(img_format);
Code:
(Slice Outline)
STEP_0_Parameters;
toolbox_chk
warning('off')
img_name=Img_filename_list(img_format); # <---- line 10#
h_progress = waitbar(0,'Slice Boundary Detection');
manual_list=[];
Code for (Img_filename_list.m) : (line 37-44)
for ii=1:size(img_info_no,1)
img_idy=find(img_info_no(:,4)==ii);
for channel_check = 1:length(Name_Channels)
if img_info_no(img_idy,3)==channel_check
img_name{(img_idy+(length(Name_Channels)-channel_check))/length(Name_Channels),channel_check}=char(img_names_raw(ii)); # <-----line 41#
end
end
end

채택된 답변

James Tursa
James Tursa 2020년 8월 28일
Type the following at the command line:
dbstop if error
Then run your code. When the error occurs, the code will pause with all variables intact. Examine img_format to see what it is and then backtrack in your code to figure out why it isn't what you expect.
  댓글 수: 1
CD11
CD11 2020년 9월 4일
Thanks for the function! I wasn't able to understand the error from the img_format file, but I adjusted some paramters in a different file that was being referenced (Step_0) and the error was resolved.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by