Effacer les filtres
Effacer les filtres

Mean of a bunch of slices

2 vues (au cours des 30 derniers jours)
Med_Imager
Med_Imager le 6 Mar 2012
% -----------------Step 3 -Masking the PCASL Files
PCASL_Files_Masked= PCASL_Files.*Human_Mask; %apply the mask. PCASL Files Masked = 64x64x128x16, Human_Mask=64x64x128x16
PCASL_Files_Masked=mean(PCASL_Files_Masked,4); %Taking the mean of each image, now PCASL_Files_Masked= 64x64x128
PCASL_Files_Masked=double(PCASL_Files_Masked);
save('PCASL_Files_Masked','PCASL_Files_Masked'); %Saving the PCASL_Files_Masked
Question 1) When I am taking the mean of all 16 slices I do PCASL_Files_Masked=mean(PCASL_Files_Masked,4); Is this theoretically correct? I am just not sure about using the '4'
Question 2) Next I want to get the mean over each image, however only in the 'masked' area
PCASL_Files_Masked_1= mean(mean(PCASL_Files_Masked)); % gives the mean signal over each measurement or each brain volume (there's 128 of them), so mean of (64, 64, 1:128)
But it doesn't do the job correctly. I want to ONLY take the mean over where the BRAIN is, not the rest of the space (which is zero) Just to clarify again, I believe when Matlab takes the mean over the image it even accounts for the number of pixels in the zero area(outside of the brain)
As in :
mean=[brain signal(which is some value)+ outside brain(which is zero)]/ [number of pixels in brain area+ number of pixels outside of brain] which is theoretically wrong.
Thanks in advance

Réponses (2)

Jan
Jan le 7 Mar 2012
Q1. mean(X, 4) calculates the mean over the 4th dimension. Therefore I assume your command is correct. I suggest to try it using a tiny test matrix.
Q2. If you want to ignore the zeros in a mean, simply use sum(X) and divide by sum(X ~= 0).
  2 commentaires
Image Analyst
Image Analyst le 7 Mar 2012
I think there are only 3 dimensions - I think the final x16 meant 16 bit integers, not an additional dimension.
Med_Imager
Med_Imager le 7 Mar 2012
There are 4 dimensions at first
64x64x128x16
size of each image=64x64
# of repetitions=128
Slices in each image=16

Connectez-vous pour commenter.


Image Analyst
Image Analyst le 7 Mar 2012
If you have a mask image you can do
pixelsInsideMask = sliceImage(maskImage); % This is a 1D vector of pixels only within the mask area.
meanInsideMask = mean(pixelsInsideMask);
Now sliceImage and even maskImage can vary as you move through the volume slice by slice. To keep track of meanInsideMask as a function of slice, make it an array
for slice = 1 : totalNumberOfSlices
% First somehow get sliceImage.
% Next somehow get maskImage - the mask for this slice level.
% Then, once you have those....
pixelsInsideMask = sliceImage(maskImage); % This is a 1D vector of pixels only within the mask area.
meanInsideMask(slice) = mean(pixelsInsideMask);
end

Catégories

En savoir plus sur MRI dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by