Additionally, I might re-write this as
```python
sample_id_indices = [i for i, sample_id in enumerate(sample_ids) if sample_id in selected_ids ]
```