Extracting Time Profiles from 3D+t data (4D)

3 ビュー (過去 30 日間)
Edwin
Edwin 2019 年 9 月 30 日
コメント済み: N/A 2020 年 11 月 13 日
Hi All,
I'm curious if anyone can provide a simple solution to this problem. I have a 4D data set (3D+time) and a 3D mask. In order to extract all the 1D time profiles using the combination, I am using the below method. My question is if anyone is aware of a faster/more simple way to accomplish this same task. Thank you all!
Cheers,
Edwin
temp = 3DMask;
[r,c,v] = ind2sub(size(temp),find(temp == 1));
%
for i = 1:size(r,1)
timeSeries(:,i) = Data_4D(r(i),c(i),v(i),:);
end
  1 件のコメント
N/A
N/A 2020 年 11 月 13 日
I am also facing the same problem. Could you please elaborate what do you mean by "Data_4D"?.

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

採用された回答

Dinesh Yadav
Dinesh Yadav 2019 年 10 月 3 日
The code is already well optimized, except parfor can be used in this case rather than just for to get the code running faster if size of 4D and 3D matrices are big.
The code cannot be vectorized as individual elements have to be selected based on the condition (find(temp==1)). We cannot use Boolean masking and reshaping as size of elements vary at each time step depending on the condition given. So I don’t think there is a way to further optimize the code but it can be effectively parallelized by using parfor command.
  1 件のコメント
Edwin
Edwin 2019 年 10 月 3 日
Thank you Dinesh. I was hoping there was a way to vectorize perhaps but wasn't sure. Thanks for the help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePerformance Profiling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by