I need help creating a loop for an experiment

I am fairly new to MATLAB and I am having trouble conceptualizing this code. I have an experiment with 25 subjects, where we will be collecting two videos each day for each subject (for 21 days), and will need to randomely select these videos for review over 28 days from this growing pool. I will have to edit some videos, and I need a way to randomely select the videos so that they are not viewed on consecutive days, and not to be viewed more than 3 or 4 times. This is so that videos are not all reviewed early on in the experiment.In other words:
Day 1 - Record 2 events
Day 2 - Record 2 events...
Day 21 - Record two events
The review of the videos is as follows:
Day 2 - Review 1 videos
Day 3- Review 2 videos
Day 4- Review 3 videos
Day 5- Review 4 videos
Days 6- Review 5 videos...
Day 28- Review 5 videos
To reiterate, there will be 42 videos to be recorded, and 125 reviews (1/3 review conditions will be baseline/no review), and I cant have the videos reviewed on consecutive days, or more than 3 or 4 times.
Would it be something like:
videoPool=1:42
subi=1:25
day=1:28
randSel=randi(videopool,1,1)
if videoPool ==
randi(videopool,1,1)
else
or
A=[1 2 ;1 2]
sz=size(A);
x=randi(42,sz)
This is where I am getting lost

4 Comments

two videos each day for each subject (for 21 days)
there will be 42 videos to be recorded,
The only way that can work out is if you mean 42 videos per subject
and 125 reviews
review over 28 days
125 total reviews over all 25 subjects or 125 reviews per subject?
125 reviews over 28 days is
125/28
ans = 4.4643
over 4 reviews per day, including all duplicate reviews. On the first day, a subject records 2 videos, and you have to do 4 reviews, so you need to review each of the two videos twice on the first day, which contradicts the need to not review the same video on consecutive days.
Sorry for not being clear. It will be 42 videos recorded per subject (2 per day over 21 days), and 125 reviews per subject. One of the conditions is no review/baseline, so ~42 of the 125 review sessions will be at baseline.
The 1st day there will be no review. Review starts on day 2. By day 2 they will have recorded 4 videos, day 3 they will have recorded 6 videos and so on.
And shouldn't it be 125/42, which is nearly 3? If I change it to 126, it is exactly 3, but I am having trouble with having too many reviews early on, as I think the 1st section of review will be reviewed too early and I would like it to be more evenly distributed over the 28 days.
125/28 was reviews per day. 125/42 is average reviews per video.
I see you added schedule information. I will think about it more but have something else to do at the moment.
Thank you for your help Walter!

Sign in to comment.

 Accepted Answer

Number the videos produced each day starting at 1 and going to 1050 (21 days, 50 videos each day).
videoPool=[];
K=[1,2,3,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];%reviews per day for each of 25 people
h=[];
for k=1:27
videoPool=[videoPool,(k-1)*50+1:k*50];%50 new videos each day added to pool
s=randperm(numel(videoPool),K(k)*25);%select videos to review
DayReview{k}=reshape(videoPool(s),[],25);%each column is the video each person will review
h=[h,DayReview{k}(:)'];
f=find(histc(h,1:max(videoPool))==4);
h(ismember(h,f))=[];%once reviewed 4-times delete from history and videoPool
videoPool(ismember(videoPool,f))=[];%delete 4-time reviewed videos from pool
end

6 Comments

You were going from 2:28, I just shifted it to 1:27 for better indexing. Below a skewed the selection 80% from the upper half, 20% from the lower half. If you want to look at a particular participant just look at the column of DayReview{} for each day. For example day 10, participant 17 would review DayReview{10}(:,17). Per the code below, the videos can only be reviewed four times. If you want only three times you can change.
videoPool=[];
K=[1,2,3,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];%reviews per day for each of 25 people
h=[];
for k=1:27
if k<=21
videoPool=[videoPool,(k-1)*50+1:k*50];%50 new videos each day added to pool for the first 21 days
end
i=max(K(k)*25+25,floor(numel(videoPool)/2));%for skewing selection to upper half
d=numel(videoPool)-i;
if d~=0
s=[randperm(i,K(k)*20)+d,randperm(d,K(k)*5)];%select videos to review
else
s=randperm(i,K(k)*25);
end
DayReview{k}=reshape(videoPool(s),[],25);%each column is the video each person will review
h=[h,DayReview{k}(:)'];
f=find(histc(h,1:max(videoPool))==4);%change to 3 if you only want maximum 3-times by all participants
h(ismember(h,f))=[];%once reviewed 4-times delete from history and videoPool
videoPool(ismember(videoPool,f))=[];%delete 4-time reviewed videos from pool
end
Do you want the participants to only review their own videos? Or are all the videos produced by all participants placed in the VideoPool for review? Currently my code has all the videos produced by all participants placed in the review pool (1-1050).
Did you change anything in the code? It works perfectly for me.
This should work for each participant.
K=[1,2,3,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];%reviews per day for each of 25 people
for participant=1:25
videoPool=[];
h=[];
for k=1:27
if k<=21
videoPool=[videoPool,(k-1)*2+1:k*2];%2 new videos each day added to pool for the first 21 days
end
i=max(K(k)+1,floor(numel(videoPool)/2));%for skewing selection to upper half
d=numel(videoPool)-i;
if d~=0
s=[randperm(i,floor(.8*K(k)))+d,randperm(d,ceil(.2*K(k)))];%select videos to review
else
s=randperm(i,K(k));
end
DayReview{participant,k}=videoPool(s);%each column is the video each person will review
h=[h,DayReview{k}];
f=find(histc(h,1:max(videoPool))==4);%change to 3 if you only want maximum 3-times by all participants
h(ismember(h,f))=[];%once reviewed 4-times delete from history and videoPool
videoPool(ismember(videoPool,f))=[];%delete 4-time reviewed videos from pool
end
end
This should prevent consecutive video reviews.
K=[1,2,3,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];%reviews per day for each of 25 people
for participant=1:25
videoPool=[];
h=[];
Removed=[];
for k=1:27
if k<=21
videoPool=[videoPool,(k-1)*2+1:k*2];%2 new videos each day added to pool for the first 21 days
end
i=max(K(k)+1,floor(numel(videoPool)/2));%for skewing selection to upper half
d=numel(videoPool)-i;
if d~=0
s=[randperm(i,floor(.8*K(k)))+d,randperm(d,ceil(.2*K(k)))];%select videos to review
else
s=randperm(i,K(k));
end
DayReview{participant,k}=videoPool(s);
h=[h,DayReview{k}];
f=find(histc(h,1:max(videoPool))==4);%change to 3 if you only want maximum 3-times by all participants
h(ismember(h,f))=[];%once reviewed 4-times delete from history and videoPool
videoPool(ismember(videoPool,f))=[];%delete 4-time reviewed videos from pool
tempRemove=DayReview{k}(~ismember(DayReview{k},f));
videoPool(ismember(videoPool,DayReview{k}))=[];
videoPool=[videoPool,Removed];
Removed=tempRemove;
end
end
I don't think you are reading the matrix properly. Each row is a person. As you move through the columns you are moving to the next day. There are no videos being reviewed on consecutive days for the same person. Video 2 for person 1 and person 2 are different videos (each person makes different videos as your previous said).

Sign in to comment.

More Answers (0)

Products

Tags

Community Treasure Hunt

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

Start Hunting!