12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- function [ prs ] = orderGratingFlashes( nimages, npulses, maxrepeats, seed )
- %FINDNEWORDER Recover the order of cta,ctb from the new SubUnitFlash stimulus
- % The new stimulus only has radial components and more
- % parameters such as range of radial search, number of angles,
- % number of contrasts, etc. It also uses a different shuffling which
- % might give a different ordering than the one Michael has used
- % before.
- %
- % [ cta, ctb, totalflashes, prs ] = findNewOrder( stimdesc, npulses, maxrepeats, seed )
- %
- % Input:
- % stimdesc: struct containing description of stimulus
- % (mincontrast, maxcontrast, ncontrasts, nangles)
- % npulses: number of pulses recorded from the experiment
- % maxrepeats: only analyze until the maxrepeats-th repeat
- % (use 'inf' for analyzing all the repeats)
- % seed: seed for ran1 (should be the same as in the experiment)
- %
- % Output:
- % cta: contrast at subtiles A, ctb: contrast at subtiles B
- % totalflashes: total number of flashes in one repeat
- % prs: order in which the contrasts are used
- %
-
-
- prs = zeros(nimages * maxrepeats, 1);
-
- for ii = 1:maxrepeats
- [order, seed] = shuffleOrder(nimages, seed);
- prs( (ii-1)*(nimages) + (1:nimages) ) = order;
- end
-
- prs = prs(1:npulses);
- end
- function [order, seed] = shuffleOrder(nelem, seed)
- % Fisher-Yates shuffle (initializes the vector in a random order)
-
- order = ones(nelem, 1);
-
- for ii = 1:nelem
- [jj, seed] = ran1(seed);
- jj = floor(1 + (ii-1)*jj);
-
- order(ii) = order(jj);
- order(jj) = ii;
- end
-
- end
|