Select a given number of elements from two vectors without overlap given elements importance
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have two vectors of two conditions (F and S), each containing voxel IDs ordered from most to least important voxel (sorted in descend order), e.g. F = [18793; 17720; 17721; 17696 ...]. The goal is to generate an ROI mask that has the most important voxels from both F and S conditions, such that we add the most important voxel from F and S, followed by the second most important voxel, third important voxel, and so on. But the trick is here: If the next most important voxel in one condition was already selected in the ROI from the other condtion, then we skip this voxel and select the next important voxel that wasn't selected in the ROI (so far). The final number of voxels in the ROI is set by a threshold (threshold = 5000), 2500 must be selected from F and 2500 from S.
Here's an example:
Take first voxel ID from F, and alternate between the F and S: (bolded elements are selected in the final ROI)
F = [18793;17720;17721;17696;18794;17697;18818;17719;17737 ... ]
S = [18793;17721;18794;17720;17722;17697;17698;18818;17696 ... ]
ROI = [ 18793; 17721; 17720; 18794; 17696; 17722; 17697; 17698; 18818; ];
Notice how S(1), S(4) and S(6) weren't selected because they were already selected from F. Same is true for F(3) and F(5).
And we you keep selecting voxels until you select threshold/2 voxels from F and S (both conditions contribute equally to the final ROI).
Note that at the end we don't care about keeping the voxel IDs order in the same way I manually generated above in final ROI. What we care about is really getting the correct IDs in the ROI to generate a binary mask, and so we need to select the IDs correctly as I described above.
I don't want to do this element by element because it takes so much time. Is there a way to vectorize this process?
Thank you for your help in advance!
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!