Help with Results Columns Please!

imagej
results-table
column

#1

Hello!
I’m developing a Macro for automated image analysis of lab samples. I have most of the work done now but I’ve been stuck for a while on a simple problem. I’m not a programmer and I think it probably has a simple solution but I have been fiddling with it for several days now and can’t figure it out for the life of me!

In short: I want a way to take the Area column in the Results window, and subtract another column containing a user input value from it, and display the result in a third new column.

I’ve been able to successfully use setResult to populate the results window, but I can’t find a way to subtract the values in one column from another column.

Any suggestions would be wildly appreciated!
-Kyle


#2

Hi there,

You could copy and process the raw data in excel. It’s easy that way.

Adam


#3

Hey, if I understood you correctly this might work:
Given that the user-input and the area are in the same row…
You still have to change the “UserInput” column to the name it displays in the results window.

Let me know if it helps :slight_smile:

                    for (e=0;e<nResults;e++){
                        area = getResult("Area",e);
                        userinput = getResult("UserInput",e);
                        substracted = area + userinput;
                        setResult("Substracted", e, substracted);
                        updateResults();
                        }

#4

Thankyou Spamhunter, that is an excellent suggestion! That really gets me close I think, however, I get a NaN result in the Subtracted column when I run it like that… It seems like my userinput value is not a number. Do you know if there is a conversion macro or something that I can use to make sure that these numbers can be calculated?


#5

Thanks for the suggestion! I’m trying to develop something that my team can use repeatedly for many hundreds of images, so I’m trying to make it as quick and seamless as possible. As such, I want to write a macro code that doesn’t require copy/paste. Thought it may be that the easiest path forward is to transfer the data to excel and have an excel macro do the processing I need. I’m still trying to figure out what the best method is.


#6

Hey,

Could you paste the code where the user is supposed to give Input?
Furthermore, what Kind of Input are we talking about?

Best


#7

Spamhunter, I just figured it out! Thank you so much for your help! That saved me a lot of grief trying to figure it out on my own. Cheers!


#8

Good to hear!

Would you post the solution for the future (I’m also interested ^^)