Make substack from slice numbers in array


I a trying to make a substack with specific slices identified in a previous step and stored in an array.
Example: I have a stack with 100 slices, I want to make a substack from slices stored in an array [2, 4, 7, 23, 50].
I was thinking about using run("Make Substack...", " slices=" +array);but this does not work… Any suggestion?

Hi @Olivier,

I’m pretty sure the only option is to make it a string first which can be feel a bit of a long winded way of going about it to be honest. Example below:

substack = newArray(2,4,7,23,50); 

string = "";

for (i = 0; i < lengthOf(substack); i++) {
    if (i == 0) {
        string = string + substack[i];
    } else {
        string = string + "," + substack[i];

run("Make Substack...", " slices=" + string);
1 Like

This is did the trick, thank you!

1 Like