Multiple measurements in Image J

Hi everyone, Happy holidays!

I am new to ImageJ and I’m trying to use it for measuring 8 traits/shrimp (thorax length, tail length etc) in my shrimp samples. I have 20k shrimp that I need to measure and so far I measured 3k of them, however, I think I do something wrong because despite my best efforts it takes very long time (3 months so far and I want to graduate…). So, the way I measure them is one trait at a time and then copy the length on an excel file (e.g. shrimp 1: trait 1 measure, copy in excel; trait 2 measure, copy in excel etc). However, I was wondering if instead of copy each value in an excel file after each measure for each trait and shrimp, I can customize the results table and do the measurements in a set order and then export the table to excel. Can someone (please!) help me with this? Any resource or guidance how to do these measurements faster is very welcomed!

Thanks!

try creating a plugin that automatizes your job and make use of this Personalized Result Table

We don’t know your analysis protocol. We can give you a better advise when you can give a better explanation of your measurements.

As far as I can help you out at this moment, I would suggest to make a macro. You can record a macro in the plugins>macros>record menu. In that case you can run your (8) measurements automatically. The other point is that measurements of the same picture are presented in the result table in columns (like excel). So it’s recommended to just make your 8 measurements on a single image and copy all these 8 results in excel.

It’s also possible to iterate over all your sample files and do the same measurement over and over. You have to invest some days (as a beginner) in making such a macro. But in your case it’ll save you lots of time.

Because I don’t know your measurement protocols (and a Image sample), I can not help you out with a macro at this moment. But it’s definitely possible (as a beginner) to make a macro yourself.

1 Like

Thank you BishopWolf and NoUsername for your quick reply.
I will try to follow your suggestions.

Protocol: I have between 50 and 100 shrimp per picture on graph paper (1mm grid) and each measurement is taken along the axis of the shrimp body (I have a PDF of the with the protocol, I can send it to you NoUsername along with a sample picture but I don’t know how…my email is herp@case.edu if you can send me an email to send them to you would be great). I am willing to learn how to automatize this process but I don’t know how (as I have little to none experience programming). If you can help me I would much appreciate.

Thanks!

Hi @shrimp

20k samples sounds like a job for a computer :slight_smile:

I guess you are looking for an automated segmentation of your shrimps. To the regions of interesst (ROIs) you can then apply some measurements.

An automated analysis works best if all images are quite similiar (shrimps always have the same orientation, background does not shift, etc.). If you could upload one of your images it would be easier for others to help.

3 Likes

Hi @tibuch

They are a lot, but I need to measure them somehow… Unfortunately when I took the pictures I didn’t know the process can be automatized so, I took the pictures and arranged the shrimp in a slightly unorganized manner (I am attaching a sample here), having in mind that I need to measure them by hand. If I want to retake the picture will mean that I will have to rearrange the shrimps again which will take a lot of time (weeks, months) hence, I think I will go ahead and do the measurements by hand (but I am open to ideas on how to do it faster). I am also attaching my measurements protocol here.

Thanks!

https://drive.google.com/file/d/0B9xjfgD46EFIQ0NtX3ZwWnd2OVk/view?usp=sharing
https://drive.google.com/file/d/0B9xjfgD46EFIWkNoLW9iWVdMWDA/view?usp=sharing

I’ve made a macro which he is going to implement and test. However, I can not come up with ideas to measure his features automatically. If anybody has good ideas, you’re welcome for suggestions. At this moment “shrimp” has to measure all his properties automatically.

In the macro I’ve made he can just go on with measuring without concerning about the table which is made. At the end of the day he can copy and paste the result table in his excel file. However, it would be nice if some properties can be measured automatically.

If you share the macro others can help or use it for a similar problem.

2 Likes

Can somebody tell me which codes I should use to place a piece of code in a box?

```
put your code here.
```
this is code
1 Like
function append(arr, value) {
     arr2 = newArray(arr.length+1);
     for (i=0; i<arr.length; i++)
        arr2[i] = arr[i];
     arr2[arr.length] = value;
     return arr2;
  }

function measure(string){
	setTool("polyline");
	waitForUser("thanks to Robin (:", string);
	run("Measure");
}

filename = File.nameWithoutExtension;
run("Set Measurements...", "  redirect=None decimal=3");

Dialog.create("test");
Dialog.addString("What is your experimtal code?", "empty");
Dialog.show();
expcode = Dialog.getString();

filenamearray = newArray();
expcodearray = newArray();
thorlarray = newArray();
taillarray = newArray();
furlarray = newArray();
thorwarray = newArray();
sexarray = newArray();
ovisacbooleanarray = newArray();
ovisaclarray = newArray();

filenamearray = append(filenamearray, filename);
expcodearray = append(expcodearray, expcode);

measure("select the thorax length");
thorlarray = append(thorlarray, getResult("Length", nResults-1));

measure("select the tail length");
taillarray = append(taillarray, getResult("Length", nResults-1));

measure("select the furca length");
furlarray = append(furlarray, getResult("Length", nResults-1));

measure("select the thorax width");
thorwarray = append(thorwarray, getResult("Length", nResults-1));

Dialog.create("thanks to Robin (:");
Dialog.addString("What is the sex of this shrimp; male (m) or female (f)?", "answer");
Dialog.show();
sex = Dialog.getString();
if (sex == "f"){
	sexarray = append(sexarray, sex);
}
	else if (sex == "m"){
	sexarray = append(sexarray, sex);
	}
	else sexarray = append(sexarray, "wrong sex input; "+sex);

Dialog.create("thanks to Robin (:");
Dialog.addString("Are eggs located in the ovisac? yes = 1, no = 0?", "answer");
Dialog.show();
ovisaceggs = Dialog.getString();
if (ovisaceggs == 1) {
	ovisacbooleanarray = append(ovisacbooleanarray, ovisaceggs);
}
	else if (ovisaceggs == 0) {
		ovisacbooleanarray = append(ovisacbooleanarray, ovisaceggs);
	}
	else ovisacbooleanarray = append(ovisacbooleanarray, "wrong number: "+ovisaceggs);

if (ovisaceggs == 1) {
	measure("select the ovisac length");
	ovisaclarray = append(ovisaclarray, getResult("Length", nResults-1));
}	
	else if (ovisaceggs == 0) {
		ovisaclarray = append(ovisaclarray, " ");
	}
	else ovisaclarray = append(ovisaclarray, "wrong number ovisaceggs: "+ovisaceggs);

Array.show(filenamearray, expcodearray, thorlarray, taillarray, furlarray, thorwarray, sexarray, ovisacbooleanarray, ovisaclarray);

It’s almost finished. I’m waiting on a review. If it’s all ok, than I’ll make it iterable. And I didn’t include the set scale option at the start of the macro.

Dear @NoUsername,
my suggestion is to pass to some scripting/programming language like python.
Some years ago, I was struggling in a similar issue and then I decided to pass to python: since handling Results Table (with personalized names, with personalized measurements and column names and maybe we would like to append another analysis) with IJ Macro is quite a mess (in my opinion), you will struggle with Rename Results and anytime you measure something you will have to pay attention how to manage Results Tables and so on.

Have a nice day,
Emanuele

I’m starting to learn it. But it’s not something you can learn in 1 day.

I’ll go on to java, it’s the hardest way, but has the most possibilities. Thanks for your suggestion, I’m working on it!

Any tips how to learn python/java?