Quantification of Plaqueregions

macro
Tags: #<Tag:0x00007fd541cf1480>

#1

Hi there, i am writing this macro for my masterthesis and got stuck in several parts of the code, because of the lack of programming knowledge. Maybe there is someone here that finds the time to help me a bit.

What i am trying to do:

  1. Find the blue regions in multiple composite fluorescence pictures, also get the area. Make a copy of those regions in the blue channel and save the picture as a control.
  2. Use those detected regions for the red channel. Enlage them to a circle of 50 and 100 diameter. Detect red signal and get results. Make a control picture and save it.

It is working manually ->


Problems in the code:
I used the record funktion in imageJ, thats why the code is not automated. I want it to use a specific folder (input) then (outout). Another Problem is that i have to enlage each blue selection manually for the red channel.

Here is my macro so far:

Part 1

run("Set Scale...", "distance=856 known=500 pixel=1 unit=µm global");		//  40x Vergrößerung aufgenommen
<<warning: the options string contains one or more non-ascii characters>>	

selectWindow("14=17_9aCH4.tif");						                               // originalDatei = getTitle();?

run("Make Composite");								
Stack.setDisplayMode("color");
Stack.setChannel(3);

run("Duplicate...", "title=14=17_9aCH4-1.tif duplicate channels=3");   		
setAutoThreshold("Default dark");
//run("Threshold...");
setThreshold(50, 255);
run("Convert to Mask");

open("C:\\Users\\EColi\\Desktop\\TEST\\14=17_9aCH4.roi");    // Here i want to use a Selection for a specific regionin the brain that i already selected.
roiManager("Add");														// Adding to Roi-Manager
run("Add to Manager"); 

run("Analyze Particles...", "size=25-Infinity circularity=0.00-1.00 show=[Overlay Outlines] display clear add");  		// Automatisches Auszählen und Ermittlung der Fläche der Plaqueregionen. 
roiManager("Show All with labels");												
roiManager("Show All");															
saveAs("Results", "C:\\Users\\EColi\\Desktop\\TEST\\14=17_9aCH4Plaque.roi");							// Speichern der Plaquefläche als .xls

roiManager("Select", 0);													// Saving Bluedot .roi
run("Select All");						
roiManager("Select", 0);
roiManager("Select", 0);
roiManager("Save", "C:\\Users\\EColi\\Desktop\\TEST\\14=17_9aCH4Plaque.roi.zip");							

selectWindow("14=17_9aCH4.tif");
run("Duplicate...", "title=14=17_9aCH4-2.tif duplicate channels=3");    // saving the selected regions with the picture for later control
roiManager("Open", "C:\\Users\\EColi\\Desktop\\TEST\\PlaqueregionenSet.zip");
open("C:\\Users\\EColi\\Desktop\\TEST\\14=17_9aCH4Plaque.roi.zip");
roiManager("Open", "C:\\Users\\EColi\\Desktop\\TEST\\14=17_9aCH4Plaque.roi.zip");
roiManager("Show All");
run("Flatten");
saveAs("Jpeg", "C:\\Users\\EColi\\Desktop\\TEST\\14=17_9aCH4-1PlaqueregionenKontrolle.jpg");

Part 2

open("C:\\Users\\EColi\\Desktop\\TEST\\14=17_9aCH4.tif");				
run("Make Composite");
Stack.setDisplayMode("color");
run("Duplicate...", "title=14=17_9aCH4-1.tif duplicate channels=1");		
open("regionenSet.zip");
roiManager("Open", "regionenSet.zip");
roiManager("Show All");
roiManager("Select", 0);
roiManager("Select", 0);
run("Enlarge...", "enlarge=50");
roiManager("Add");
roiManager("Select", 15);
roiManager("Select", 15);
roiManager("Rename", "1k");
roiManager("Select", 9);
roiManager("Select", 9);
run("Enlarge...", "enlarge=50");
roiManager("Add");
roiManager("Select", 16);
roiManager("Select", 16);
roiManager("Rename", "10K");
roiManager("Save", "RoiSet.zip");

run("8-bit");
setAutoThreshold("Default dark");
//run("Threshold...");

setThreshold(58, 255);
run("Convert to Mask");

roiManager("Select", 0);
roiManager("Select", 0);

run("Analyze Particles...", "size=0-Infinity pixel circularity=0.00-1.00 show=[Overlay Outlines] display clear summarize add");			

If there are more qustions, or if i have left out something, feel free to ask.
Best regards!


#2

Hi @E.COLI,

Welcome to the forums!

You’ll definitely need to read up on some macro programming. Even if somebody helps you out on the forums, you’ll need to understand the basics to be able to modify the code or work with us.

I would recommend reading and trying to implement the following:

  1. Introduction into Macro Programming
  2. How to apply a common operation to a complete directory

There is a lot of repetition in your code, I would try cleaning it up some more. Read those pages and understand the use of variables to allow flexible programming, then try to apply that to your code.

You can use variables to help with naming windows/files, selecting windows, opening files, saving files, selecting ROIs etc. - all very useful for your workflow.

Your task is very suitable as a first step in to macro programming, if you have any questions, come back to us!

Rob