Creating a sublist from a Position List


I was wondering if it is possible to create a sublist of positions from an overall position list? For example, if I have positions list with a, b, c and I want to create a new list with just a and b, how would you do that?

Hi @cngpit,

Does deleting position c work for you (select position c, and press Remove)? You can always save the complete list first and load it again later. If I mis-understand your question, please do explain.

Hi Nico,

Sorry for not being clear. I’m modifying a script (AutofocusFirstPosition which gets all marked positions:

import org.micromanager.MultiStagePosition;
import org.micromanager.StagePosition;
import ij.IJ;

runnable= new Runnable(){
public void run(){

xyStage = mmc.getXYStageDevice();
zStageFocus = mmc.getFocusDevice();

posList = mm.uiManager().getPositionList();
list = posList.getPositions();

//get all positions
posList = mm.uiManager().getPositionList();
list = posList.getPositions();
// Running autofocus for every 10th positions
for (i = 0; i < posList.getNumberOfPositions(); ++i) {
if (i%10 == 0) {
// Go to pos i (where the autofocus will be applied)
posi = posList.getPosition(i);
posi.goToPosition(posi, mmc);

//Record position before autofocus
zpos = mmc.getPosition();

AfM = mm.getAutofocusManager()
AFMM = AfM.getAutofocusMethod()

//compute the z-offset
offset = mmc.getPostion()-zpos;
IJ.log("offset is "+ offset);

//apply the offset to the position of the list (Here instead of using list, I would like to use a sublist that consists of positions 0 through 9 so that the offset gets applied and then sublist from position 11 through 19 for the 2nd offset, etc.)
for (msp: list) {
sp = msp.get(zStageFocus);
sp.set1DPosition(zStageFocus, sp. get1DPosition () + offset);
IJ.log("Offset applied to all positions ");

//Parameters define when the runnable is run (frame,position,channel,slide)

Does this work?

for (i = 0; i < 9; ++i) {
   msp = list.get(i);
   sp = msp.get(zStageFocus);
   sp.set1DPosition(zStageFocus, sp. get1DPosition () + offset);

I tried, but it sent me an error message: “Acquisition failed”. Is the variable “list” an indexed list?
Let me know and thanks for the suggestions!

What was the error (enable debug log mode in Tools > Options, and check the Corelog file in directory Corelogs, or use Help > Report a Problem)?

Your variable “list” is a PositionList:

Thank you for your help. I got it working with the following code:

for (x = i; x<=i+9; x++) {
     msp = posList.getPosition(x);
     IJ.log("Offset applied to position " + x);
     sp = msp.get(zStageFocus);
     sp.set1DPosition(zStageFocus, sp.get1DPosition() + offset);