Extract results from ResultTable for different channels

Tags: #<Tag:0x00007fa3014096a0> #<Tag:0x00007fa301409560>


Hello everybody,

I have a problem with the handling of ResultsTable for the measurements of different parameters in different channels. I have a timeframe stack composed of different channels. What I do is to extract the channel, segment the nuclei for one channel and measure their shape, then use the rois to measure the mean intensity in the other channel, so that to be able to to trace back for the same cell the intensity in the other channels and its dimensions.

The problem is that if I try to extract the result of the measured intensity for one channel, it writes the shape measurements, while another result table opens with the measurements I want. How can I refer to the new ResultTable?

Here is my function

def iterate(imp, path_cyan, path_venus, path_cherry):
	"""Iterate through timeframes to process images"""
	mcherry = extractChannel(imp,2)
	venus = extractChannel(imp,3)
	mask_cyan = extractChannel(imp,4)
	BlurImage(mask_cyan, 2.0, 1.0)  
	IJ.run(mask_cyan, "Subtract Background...", "rolling=30 sliding stack")
	IJ.run(mask_cyan,"Convert to Mask", "method=Li background=Dark calculate")
	IJ.run(mask_cyan, "Watershed", "stack")
	rm = RoiManager().getInstance() #select the roi
	table, p = segmentParameters(mask_cyan)
	for i in range(mask_cyan.getStackSize()): 
		mask_cyan.setSliceWithoutUpdate(i + 1)
		if p.analyze(mask_cyan):
			print "All ok: "+ str(i+1)
			print "There was a problem in analyzing", mask_cyan
		for roi in range(0, rm.getCount()):
			result = "Frame: "+str(i+1)+"\t"+table.getRowAsString(roi)+"\n"
		mcherry.setSliceWithoutUpdate(i + 1)

		for roi in range(0, rm.getCount()):
			result = table.getRowAsString(roi)+"\n"

		venus.setSliceWithoutUpdate(i + 1)

		for roi in range(0, rm.getCount()):
			result = table.getRowAsString(roi)+"\n"
	#problema:table refers to the rt where I have cyan´s results. How can I refer it to the new rt?
		rm.runCommand("Select All"); rm.runCommand("Delete")

I am writing in Jython, so I would really appreciate a help in this programming language :slight_smile:


Without seeing the whole code:

You can rename the tables and then reference them to store the individual results. Here an example:

#author: M. Austenfeld
from ij import IJ;
from ij import WindowManager;

imp = IJ.openImage("http://wsr.imagej.net/images/blobs.gif");
IJ.run(imp, "Measure", "");
#Rename first table!
IJ.run(imp, "Measure", "");
#Rename second table!
#Get reference to first table!
#Get reference to second table!


Thank you @Bio7 for the reply, but I am not sure how to apply what you showed me ot my problem.

In fact, what I am doing is looping through each frame of my stack, while performing the particle analysis in one channel (cyan) and using the calculated rois to measure mean intensity in the other channels for the same frame (cherry and venus). After having completed one frame, I reset the roi manager and start again. While loopiing through the rois, I extract the corresponding info from the table to write it in another file. I do this because I would like to be independent of the ResultTable and because I will have to do this thing for several stacks, not only one…
I hope I have explained better the problem :slight_smile:


Why do you have to do it in such a complicated way? Isn’t that a use case where the Redirect to option in Analyze > Set Measurements… can be used (i.e. analyze particles in one channel, get the measurements from the other channel)? You don’t have to export ROIs to the manager to achieve this.


Hi @imagejan, thank you for the advice, I will try to figure out how to use this option in Jython.
I am doing it in a complicated way because I am a student and it is the first time I am facing this problem, so I keep on fixing it by trials and errors… :sweat_smile: