Thank you for responding to my questions.
Yes of course
It is a simple jython script
1.It starts from an open multiframe single channel hyperstack image.
2. if one checkbox is selected in the dialogue it goes to this particular frame
3. If more then one checkbox is selected it generates a derivative multichannel image
the problem is that if that derivative image is closed the dialogue disappears
here is the code:
from ij import IJ, ImageStack, CompositeImage, ImagePlus
from ij.io import DirectoryChooser, OpenDialog
from os import walk
from ij import WindowManager
import re
import os
from ij.gui import GenericDialog, NonBlockingGenericDialog, WaitForUserDialog
from java.awt import Color
imp = IJ.getImage()
overlay=imp.getOverlay()
stack = imp.getImageStack()
imp_dimensions=imp.getDimensions()
datasetlines=stack.getSliceLabels()
filledwithTrue=[True, False]
gd = GenericDialog("channel names source")
gd.addCheckboxGroup(2, 1, ["get channels from slice labels","get channels from a file"], filledwithTrue)
gd.showDialog()
checkedIDs=gd.getCheckboxes()
IDs=[elem.getLabel() for elem in checkedIDs if elem.getState() is True]
indexes=[checkedIDs.index(elem) for elem in checkedIDs if elem.getState() is True]
if indexes[0]==1:
od = OpenDialog("Choose channel names file", None)
datasetfile = od.getFileName()
srcDir = od.getDirectory()
datasetpath = os.path.join(srcDir, od.getFileName())
datasetsource = open(datasetpath, "r+")
datasetlines=datasetsource.read().split('\n')
datasetsource.close()
print(len(datasetlines))
forever="yes"
while forever=="yes" :
filledwithTrue=[False for elem in datasetlines]
gd = NonBlockingGenericDialog("channels")
gd.addCheckboxGroup(len(datasetlines)//3+4, 4, datasetlines, filledwithTrue)
gd.showDialog()
checkedIDs=gd.getCheckboxes()
IDs=[elem.getLabel() for elem in checkedIDs if elem.getState() is True]
indexes=[checkedIDs.index(elem) for elem in checkedIDs if elem.getState() is True]
if len(IDs)==0:
break
Nchannels_in_result=len(IDs)
if len(IDs)==1:
imp.setPosition(indexes[0]+1)
if len(IDs)>1:
Nchannels_in_ori=imp_dimensions[2]
print(Nchannels_in_result)
print(Nchannels_in_ori)
frames=[]
channels=[]
combo = ImageStack(imp.width, imp.height)
for i in range(0,Nchannels_in_result):
frames.append(int(indexes[i]//imp_dimensions[2]+1))
channels.append(((indexes[i]+1)-(frames[i]-1)*imp_dimensions[2])%(imp_dimensions[2]+1))
print(str(i+1)+" "+str(((indexes[i]+1)-(frames[i]-1)*imp_dimensions[2]))+" "+str(frames[i])+" "+str(channels[i]))
for k in range(1, Nchannels_in_result+1):
extract = stack.getProcessor((frames[k-1]-1)*Nchannels_in_ori+channels[k-1])
combo.addSlice(extract)
for i in range(1,len(IDs)+1):
combo.setSliceLabel(IDs[i-1],i)
imp2 = ImagePlus("selected markers combined", combo)
imp2.setCalibration(imp.getCalibration().copy())
imp2.setDimensions(Nchannels_in_result, 1, 1)
imp2.setOverlay(overlay)
comp = CompositeImage(imp2, CompositeImage.COMPOSITE)
comp.show()