3-Dimensional Matrix and Standard Deviation

5 ビュー (過去 30 日間)
Sami Case
Sami Case 2021 年 5 月 23 日
コメント済み: Sami Case 2021 年 5 月 25 日
Hi there,
I have a 3-Dimensional matrix (sizeX, sizeY, 700 Frames). I would like to group the "frames" in groups of 10, so that I can take the standard deviation of each of these groups of frames. E.g. -- Since I have 700 frames (z values), I would like to take the standard deviation of 1:10, then 11:20, then 21:30. For mean, I could just bin them in groups of ten (using for loop and mean function) and get my 70 values. But for standard deviation, I'm not sure how to do this.
  2 件のコメント
Sami Case
Sami Case 2021 年 5 月 23 日
**Similar to the Grouped-Z Project function in ImageJ where you can do Standard Deviation of your data with a group size of 10.
Sami Case
Sami Case 2021 年 5 月 25 日
See DGM’s comment below for answer help.

サインインしてコメントする。

採用された回答

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 23 日
Hi,
Here is a relatively simple solution for the standard deviation calculation:
D = DATA; % DATA of size: X-by-Y-Zs, where Zs = 1:700;
IND = 1:10:700;
for ii=2:numel(IND)
S_D(ii-1) = std2(D(:,:,IND(ii-1):IND(ii))); % Standard deviation
M_D(ii-1)=mean2(D(:,:, IND(ii-1):IND(ii))); % Mean values
end
Good luck.
  4 件のコメント
Sami Case
Sami Case 2021 年 5 月 23 日
This is still showing a 1x70 vector. My goal it to have a standard deviation from 1-70 for each cell in the matrix. So my matrix is 160-by-160 and the z is 700. I would like to have a standard deviation of the cell in column 1, row 1 for every z. And for column 2, row 2 for every z. The output should be 160 by 160 by 70 matrix.
DGM
DGM 2021 年 5 月 24 日
編集済み: DGM 2021 年 5 月 24 日
Try this:
D = rand(10,10,100); % random sample data
blocksize = 10; % how many pages to collapse?
npages = size(D,3);
IND = 1:blocksize:npages;
stdpict = zeros(size(D,1),size(D,2),numel(IND));
meanpict = zeros(size(D,1),size(D,2),numel(IND));
for ii=1:numel(IND)
idxrange = IND(ii):(IND(ii)+blocksize-1);
% Standard deviation of block along dim 3
stdpict(:,:,ii) = std(D(:,:,idxrange),0,3);
% Mean of block along dim 3
meanpict(:,:,ii) = sum(D(:,:,idxrange),3)/blocksize;
end
% the indexing will break if npages is not integer-divisible by blocksize
This does operations along dim3 of each block of pages. That sounds like what you're after.
Prior code was also indexing 1:11, 11:21, 21:31, etc, and dropping the last sample block.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by