필터 지우기
필터 지우기

store mask created from roipoly on scans running in for loop, in new variable

조회 수: 1 (최근 30일)
I have a series of mri scans stored in a 256 x256 x 19 variable. Each scan in the series has a different ROI that I want to mask out using roipoly. Is there a way that I can turn this code into a for loop to mask out the roi and store the output mask eg. tumor1, tumor2, tumor3 for each scan in a separate variable after each iteration?
%%
[tumor2, x2, y2] = roipoly(segmentT2Flair(:,:,2));
%%
[tumor3, x3, y3] = roipoly(segmentT2Flair(:,:,3));
%%
[tumor4, x4, y4] = roipoly(segmentT2Flair(:,:,4));
%%
[tumor5, x5, y5] = roipoly(segmentT2Flair(:,:,5));
%%
% mask over tumor ROI
%segment_mask = poly2mask(xi, yi, 256, 256); %creates a mask based on dimensions
segment_mask = cat(3,tumor1, tumor2, tumor3, tumor4, tumor5, tumor6, tumor7, tumor8, tumo
%%
for i = numslices:-1:1
[tumor(i), xi, yi] = roipoly(SegmentT2Flair(:,:,i)); %when i run this it only saves the mask and dimensions of the last slice not the 18 before
end
for i: numslices:-1:1 %in this loop the images are outputted as jpg but not stored in matlab array and dimensions are not stored
[tumor] = roipoly(SegmentT2Flair(:,:,i))
filename = ['Segmented', num2str(i), '*.jpg']
saveas(1, filename);
hold off

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 11월 1일
편집: KALYAN ACHARJYA 2019년 11월 1일
You can store the mask in cell array and later call any mask as per requiremnets.
n=?? % define
mask=cell(1,n)
for i=1:n
%Mask generation, say mask_data
mask{i}=mask_data
end
Noy you can any mask as later say mask{1}, mask{2}, so on.....

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MRI에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by