index variable based on time points
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Raheema Al Karim Damani
am 5 Dez. 2019
Kommentiert: Raheema Al Karim Damani
am 6 Dez. 2019
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 Kommentare
Walter Roberson
am 5 Dez. 2019
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.
Akzeptierte Antwort
Walter Roberson
am 5 Dez. 2019
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);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu MRI 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!