Masking dicom multiple files with same mask
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aga
am 16 Mai 2014
Kommentiert: Stelios Fanourakis
am 28 Mär. 2018
Dear all,
I want to mask dicom files (#slices>100) with same mask and than do the histogram for all slices of the unmasked part and masked separately . For single (1 slice file) it works perfect:
test_image=dicomread(fullfile(pathname, filename) );
imagesc(test_image)
test_if=imfreehand;
notmask=createMask(test_if);
mask=~notmask; //since I want to have everything except mask area
test_image(mask);
test_image(~mask)=NaN;
imagesc(test_image)
Histogram also works:
hist(double(test_image(:)).
But I can't find the right indexing method for masking all slices. I tried:
for cnt=1:p X(:,:,1,numel(dicomlist))=dicomread(fullfile(pwd, dicomlist(cnt).name)); % Xmask(:,:,1,numel(dicomlist))=double(X(:,:,1,numel(dicomlist))).*mask; % Xmask(find(Xmask==0))=NaN;
end (the upper sometimes work)
or in a different way, similar to single file (below differen tries):
Xmask(mask,1,numel(dicomlist));
Xmask(mask, numel(dicomlist);
Xmask(:,:,1,p)=X(mask);
That all failedm, usually with an error that indexing has to be placed in the end or there is dimension mismatch.
So I am both curious and confused..What is the proper way of doing that? Thank you in advance!
0 Kommentare
Akzeptierte Antwort
Henric Rydén
am 19 Mai 2014
Hi,
you should load all your dicom files into a 3D matrix. Then, make your mask 3D using repmat. Your code should look something like this: (I haven't tried it so expect errors)
slices = 50; % I don't know how many slices you have, change this
test_image=dicomread(fullfile(pathname, filename));
myAwesomeData = zeros(size(test_image,1),size(test_image,2), slices);
myAwesomeData(:,:,1) = test_image;
test_if=imfreehand;
mask=createMask(test_if);
test_image(mask)=NaN;
figure;
imagesc(test_image)
for idx = 2 : slices
myAwesomeData(:,:,idx) = dicomread(dicomlist(idx).name);
end
maskedData = myAwesomeData(repmat(mask,1,1,slices));
2 Kommentare
Stelios Fanourakis
am 28 Mär. 2018
Excuse me. To this line myAwesomeData(:,:,1) = test_image;
It gives me the error 'Assignment has more non-singleton rhs dimensions than non-singleton subscripts'
what does this mean?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu DICOM Format 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!