フィルターのクリア

index variable based on time points

2 ビュー (過去 30 日間)
Raheema Al Karim Damani
Raheema Al Karim Damani 2019 年 12 月 5 日
i have a variable with 1400 images stored in it. I want to index this loop into 40 time points, (so there are 40 variables each containing 35 frames)
mri % 128 x 128 x 1400 uint16
I am trying to build a loop that for each instance in the loop (t = 40), 35 frames are stored into an output variable so essentially at the end I could have an output variable which is
output % 128 x 128 x 35 frames x 40 timepoints
%here is the rudimentary code that I am working from to build into a for loop
perf_0 = mri(:,:,1:35);
perf_1 = mri(:,:,36:70);
perf_2 = mri(:,:,71:105);
perf_3 = mri(:,:,106:140);
perf_4 = mri(:,:,141:175);
perf_5 = mri(:,:,176:210);
perf_6 = mri(:,:,211:245);
  4 件のコメント
Walter Roberson
Walter Roberson 2019 年 12 月 5 日
i = mri(:,:,1:35)
Are the values inside the mri array indices? Because you have
mri8807081(:,:,i+1)
where i is the results you pulled out of mri, so the mri values would have to be indices.
Your loop only uses t for output, so it is going to do the same calculation for each iteration and all of the output() values would come out the same along the 4th dimension. If that is your intent then you should consider only doing the calculation once and repmat() it .
Your original question talks about extracting portions of the variable mri, but here you are extracting portions of the variable mri8807081 using the portions of mri as indices.
Raheema Al Karim Damani
Raheema Al Karim Damani 2019 年 12 月 6 日
apologies for the confusion, no my intent is what I mentioned earlier to extract segments of the mri variable, basically for first iteration it should index the first 35 frames, the second iteration, the next 35 frames. I think i figured out my query, thank you for your help!

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 12 月 5 日
output = zeros(size(mri,1), size(mri,2), 35, 40, class(mri));
for t = 1 : 40
output(:,:,:,t) = mri(:,:,35*(t-1) + (1:35));
end
However if this was your purpose then just use
output = reshape(mri, size(mri,1), size(mri,2), 35, 40);
  1 件のコメント
Raheema Al Karim Damani
Raheema Al Karim Damani 2019 年 12 月 6 日
Thank you that's the approach that I used as well!

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by