Effacer les filtres
Effacer les filtres

Incorrect table size, unsure why.

8 vues (au cours des 30 derniers jours)
Miguel
Miguel le 16 Nov 2022
Modifié(e) : Matt J le 18 Nov 2022
start_ROI = 1
stop_ROI = 9
bin = 180*60
start_time = 172827;
final_time = start_time + 259200;
for j = (start_ROI:stop_ROI)
%Table to hold frames moved data
Frames_movedabove = [];
Frames_movedbelow = [];
for i = (start_time:bin:final_time)
%Filter out respective thresholds and calculate total # frames moved
abovetest = asabove(i:(i+bin),j);
belowtest = sobelow(i:(i+bin),j);
%Create tables with total # frames moved above threshold
Frames_movedabove(length(Frames_movedabove)+1) = sum(abovetest);
Frames_movedbelow(length(Frames_movedbelow)+1) = sum(belowtest);
end
end
geno_1 = 1:9
for i = (start_time:bin:final_time)
Dummyabove = [];
Dummybelow = [];
%Filter out
Abovetable = asabove(i:(i+bin),geno_1);
Belowtable = sobelow(i:(i+bin),geno_1);
Dummyabove(length(Dummyabove)+1,:) = sum(Abovetable);
Dummybelow(length(Dummybelow)+1,:) = sum(Belowtable);
end
Hello,
I have some code I wrote for analyses that I have been tasked to do. My individual analysis code, above, works fine. I am able to go throughout all my RegionsOfInterest, per specified timeslot, and then graph it all.
When trying to recreate it for a population analysis, is when I run into issues. My idea was to go into my "overall data table", pull out only a genotype's worth of data (rather than simply 1 ROI-- in this case 1 genotype is ROIs 1:9), average out the values for each timeslot, and then graph the averages for a 25hr "every ROI in this genotype" graph. My main hiccup is thus: when I run the "individual" code, my Frames_movedabove/below tables are 1x25, which is what I want, as it's 1 data point per hour. However, my equivalent table for the population analysis, rather than being 9x25, is 1x9.
I attached a photo of what my final graph for individual analysis looks like. End goal is to output one like that, but for an entire population rather than simply 1 ROI. I am new to matlab so sorry if this is a trivial question and thanks in advance for the help.
  1 commentaire
Matt J
Matt J le 16 Nov 2022
Modifié(e) : Matt J le 16 Nov 2022
However, my equivalent table for the population analysis
Which variable in your code represents this table? If it's Dummyabove and Dummybelow, you are discarding all of the results they contain every time you do this at the top of the loop,
Dummyabove = [];
Dummybelow = [];
In any case, this looks like the wrong approach if all you are trying to do is partition matrices into bins and average them, see my answer below.

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 16 Nov 2022
Modifié(e) : Matt J le 16 Nov 2022
It's not clear what the sizes of all the given variables in your code are. However, to divide a matrix into BINx1 strips and average them individually, you don't need to use such a complicated pattern of loops. Just use appropriate reshaping, e.g.,
bin=180*60;
asabove=rand(bin*9,25);
asaboveBinned=reshape( mean( reshape(asabove,bin,[]) ) ,[9,25]);
whos asabove*
Name Size Bytes Class Attributes asabove 97200x25 19440000 double asaboveBinned 9x25 1800 double
  11 commentaires
Miguel
Miguel le 18 Nov 2022
Thank you so much! I am new to matlab and this week has been hard... so brain power has been running at ~5% or so and quite foggy.
I'm having trouble interpreting what the resulting table's data means, however. Would these then represent the means of the values at each hour? And if so, would I then average together the hour/population that I am interested in from asaboveBinned, in order to then get the values I am looking for?
How would you recommend I change that error? My end goal was to scan asabove, from my start time in bin increments (which is equal to amount of frames in 1 hour) to my final time. When I make it (i:bin,j) I instead get no data.
Matt J
Matt J le 18 Nov 2022
Modifié(e) : Matt J le 18 Nov 2022
I'm having trouble interpreting what the resulting table's data means, however
It is dividing the original data into bin x 1 tiles and finding the average within each tile. Below is a simplified illustration with bin=5.
>> sepblockfun(asabove, 5,'mean')
ans =
3.4000 3.2000 4.6000 4.8000 4.2000
4.6000 5.8000 3.6000 3.4000 6.4000
2.4000 3.2000 2.8000 5.4000 6.0000
How would you recommend I change that error?
Well, obviously I would recommend you abandon the loop altogether in favor of sepblockfun. However, I believe what you really wanted in the original loop was,
abovetest = asabove(i:(i+bin-1),j);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by