store mask created from roipoly on scans running in for loop, in new variable
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Raheema Al Karim Damani
am 30 Okt. 2019
Kommentiert: Raheema Al Karim Damani
am 15 Nov. 2019
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
0 Kommentare
Akzeptierte Antwort
KALYAN ACHARJYA
am 1 Nov. 2019
Bearbeitet: KALYAN ACHARJYA
am 1 Nov. 2019
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.....
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MRI finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!