Open images as a stack (works with a given path but not with an element of a list because of SyntaxError)

Dear Forum,

I wrote a macro in python to apply contrast enhancement with different percentages .
For this purpose I have made a GenericDialog Box with different checkboxes. If a checkbox is TRUE, the macro opens a stack with images and applies contrast enhancement. Hence, I save the path of each stack in a list called “Output”.
So far so good.

Now I want to use this code to open the images as a stack:"Image Sequence...", "open=["Output[0]"] sort")

But this does not work, because of a SyntaxError.
I tried a test with the whole path in the code and it works."Image Sequence...", "open=[/Users/mate/Desktop/preparation/contastenhancement/stack1/.DS_Store] sort")

This code also doesn’t work because it can’t open the whole images as a stack. That’s why I prefer the code before.

imp = IJ.openImage(os.path.join(Output[0]))

What is the correct syntax?

I can’t believe I’m failing here.
Thank you for any advice!

Dear Forum,

I solved this problem. I removed .DS_Store and used FolderOpener.
Here is the result:

k = []
for i in Output:
  j = i.replace('.DS_Store','')
#Open all images as stack  
from ij.plugin import FolderOpener
options = "sort"
path = k[0]
imp =, options)
1 Like