Help with macro

imagej

#1

Hello everyone,
I am trying to run a macro which is used to calculate the ‘GP value’ which i got from this paper - http://www.nature.com/nprot/journal/v7/n1/full/nprot.2011.419.html. Here is the macro:

/* ImageJ macro for GP images analysis
   Quantitative Imaging of Membrane Lipid Order in Cells and Organisms
   Dylan M. Owen, Carles Rentero, Astrid Magenau, Ahmed Abu-Siniyeh and Katharina Gaus
   Nature Protocols 2011
   version July 2011
*/

/* This macro calculates GP images from Laurdan and di-4-ANEPPDHQ ratiometric images in
   bactch mode (whole chosen folder) obtained using a Leica microscope. The generation
   of HSB images of these GP images has been also implemented.
*/

print("\\Clear");

requires("1.44d");
closeAllImages();

// Select images folder
dir = getDirectory("Choose a Directory ");

// Inicialize choice variables
CHANNEL1 = newArray("none","ch00","ch01","ch02","ch03","ch04","ch05");
CHANNEL2 = newArray("ch00","ch01","ch02","ch03","ch04","ch05");
QUESTION = newArray("Yes","No");
Lut_Dir = getDirectory("luts");
lut = getFileList(Lut_Dir);

// Choose image channels and threshold value
Dialog.create("GP analysis parameters");
Dialog.addChoice("Acquisition ordered channel:  ", CHANNEL2, "ch00");
Dialog.addChoice("Acquisition disordered channel:  ", CHANNEL2, "ch01");
Dialog.addNumber("Lower Threshold Value for GP the mask:  ", 15);
Dialog.addChoice("Scale color for GP images:  ", lut, "Rainbow RGB.lut");
Dialog.addMessage("\n");
Dialog.addChoice("Immunofluorescence channel:  ", CHANNEL1, "none");
Dialog.addNumber("Lower Threshold Value for the IF mask:  ", 50);
Dialog.addMessage("\n");
Dialog.addNumber("G factor (1 if unknown):  ", 1);
Dialog.addChoice("Do you want to use G factor for GP image calculation?",QUESTION, "No");
Dialog.addMessage("\n");
Dialog.addChoice("Do you want to generate HSB images?",QUESTION, "Yes");
Dialog.addMessage("\n");
Dialog.show();

// Feeding variables from dialog choices
chA = Dialog.getChoice();
chB = Dialog.getChoice();
t = Dialog.getNumber();
lut = Dialog.getChoice();
chC = Dialog.getChoice();
tc = Dialog.getNumber();
Gf = Dialog.getNumber();
Ques = Dialog.getChoice();
HSB = Dialog.getChoice();

lut1= substring(lut,0,lengthOf(lut)-4);

time0 = getTime();
setBatchMode(true);

// Folder management
getDateAndTime(year, month, dayOfWeek, dayOfMonth, hour, minute, second, msec);
MonthNames = newArray("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
DayNames = newArray("Sun", "Mon","Tue","Wed","Thu","Fri","Sat");
if (hour<10) {hours = "0"+hour;}
else {hours=hour;}
if (minute<10) {minutes = "0"+minute;}
else {minutes=minute;}
if (month<10) {months = "0"+(month+1);}
else {months=month+1;}
if (dayOfMonth<10) {dayOfMonths = "0"+dayOfMonth;}
else {dayOfMonths=dayOfMonth;}

var Folder = 0;
results_Dir = dir + "Results "+year+"-"+months+"-"+dayOfMonths+" "+hours+"h"+minutes+ File.separator;
File.makeDirectory(results_Dir);

ordered_images_Dir = results_Dir + "Ordered Images" + File.separator;
Folder = ordered_images_Dir;
newFolder();
disordered_images_Dir = results_Dir + "Disordered Images" + File.separator;
Folder = disordered_images_Dir;
newFolder();
GP_images_Dir = results_Dir + "GP images" + File.separator;
Folder = GP_images_Dir;
newFolder();
histogramGP_Dir = GP_images_Dir + "Histograms" + File.separator;
Folder = histogramGP_Dir;
newFolder();
rawGP_images_Dir = results_Dir + "raw GP images" + File.separator;
Folder = rawGP_images_Dir;
newFolder();

IF_images_Dir = results_Dir + "Immunofluorescence Images" + File.separator;
GP_IF_images_Dir = results_Dir + "GP-IF images" + File.separator;
histogramIF_Dir = GP_IF_images_Dir + "Histograms" + File.separator;
HSB_Dir = results_Dir + "HSB images" + File.separator;

// Open and save images in 32bit format 
listDir = getFileList(dir);
var s = 0;
for (i = 0; i < listDir.length; i++) {
	if (endsWith(listDir[i], chA+".tif")) {
		open(dir + listDir[i]);
		prepareImage();
		saveAs("tiff", ordered_images_Dir + substring(s,0,lengthOf(s)-9) + "_chA_32bits");
		close(); }
	if (endsWith(listDir[i], chB+".tif")) {
		open(dir + listDir[i]);
		prepareImage();
		Gf1=Gf;
		if (Ques=="Yes") {
			run("Multiply...","value=" + Gf);
			Gf1=1; }
		saveAs("tiff", disordered_images_Dir + substring(s,0,lengthOf(s)-9) + "_chB_32bits");
		close(); }
}

// GP and GPc Arrays 
GP=newArray(256);
for (i=0; i<256; i++) {
	GP[i]=((i-127)/127); }

GPc=newArray(256);
for (i=0; i<256; i++) {
	GPc[i]=-(1+GP[i]+Gf1*GP[i]-Gf1)/(-1-GP[i]+Gf1*GP[i]-Gf1); }
		
// GP analysis
listOrd = getFileList(ordered_images_Dir);
listDisord = getFileList(disordered_images_Dir);

var histoDir=0;
for (h = 0, j = h; h < listDisord.length; h++, j++) {
	Name=newArray(listOrd.length);
	open(ordered_images_Dir+listOrd[h]);
	name = getTitle;
	Name[j] = substring(name,0,lengthOf(name)-15);
	rename("Image_1a.tif");
	run("Duplicate...","title=Image_1b.tif");
	open(disordered_images_Dir+listDisord[j]);
	rename("Image_2a.tif");
	run("Duplicate...","title=Image_2b.tif");
	imageCalculator("Substract create 32-bit", "Image_1a.tif", "Image_2a.tif");
	rename("Image_Subs.tif");
	imageCalculator("Add create 32-bit", "Image_1b.tif", "Image_2b.tif");
	rename("Image_Add.tif");
	imageCalculator("Divide create 32-bit", "Image_Subs.tif", "Image_Add.tif");
	saveAs("tiff", rawGP_images_Dir + Name[j] + "_preGP");
	rename("Image_preGP.tif");
	setMinAndMax(-1.0000, 1.0000);
	call("ij.ImagePlus.setDefault16bitRange", 0);
	selectImage("Image_Add.tif");
	setThreshold(t*2,510);
	run("Convert to Mask");
	run("Subtract...", "value=254");
	rename("Image_1bit.tif");
	imageCalculator("Multiply create", "Image_1bit.tif", "Image_preGP.tif");
	run(lut1);
	saveAs("tiff", GP_images_Dir + Name[j] + "_GP");

// Histogram generation
	histoDir=histogramGP_Dir;
	HistogramGeneration();
}

// If there is not fluorescent immunostaining
if (chC == "none") {
// HSB image generation
	if (HSB=="Yes") {
		HSBgeneration();
	}
// Print information
	listGP = getFileList(GP_images_Dir);
	time1 = getTime();
	TOTALtime = (time1-time0)/1000;
	printInfo();
}

// If there is fluorescent immunostaining
else {
// Folder management
	temp_Dir = getDirectory("temp");

	temp_IFmask_Dir = temp_Dir + "IF mask" + File.separator;
	Folder = temp_IFmask_Dir;
	newFolder();

	File.makeDirectory(IF_images_Dir);
	File.makeDirectory(GP_IF_images_Dir);
	File.makeDirectory(histogramIF_Dir);

// Create a 1-bit mask from Immunofluorescence image and save for each image
	listDir = getFileList(dir);
	Name=newArray(listDir.length);
	for (i = 0; i < listDir.length; i++) {
		if (endsWith(listDir[i], chC + ".tif")) {
			open(dir + listDir[i]);
			name = getTitle;
			Name[i]=substring(name,0,lengthOf(name)-9);
			run("32-bit");
			saveAs("tiff",IF_images_Dir + Name[i] + "_IF_32bits");
			run("8-bit");
			setThreshold(tc,255);
			run("Convert to Mask");
			run("Divide...","value=255");
			saveAs("tiff", temp_IFmask_Dir + Name[i] + "_GP-IF_1bit");
			close();
		}
	}

// GP-IF image
	listTempIF = getFileList(temp_IFmask_Dir);
//	listL = getFileList(GP_images_Dir);
	Name=newArray(listTempIF.length);
	for (h = 0, j = h; h < listTempIF.length; h++, j++) {
		open(temp_IFmask_Dir+listTempIF[h]);
		k = getTitle;
		Name[j]=substring(k,0,lengthOf(k)-15);
		open(GP_images_Dir + Name[j] + "_GP.tif");
		l = getTitle;
		run("8-bit");
		imageCalculator("Multiply create", k, l);
		run(lut1);
		saveAs("tiff", GP_IF_images_Dir + Name[j] + "_GP-IF");

// Histogram and Normal Distribution
		histoDir=histogramIF_Dir;
		HistogramGeneration();
	}

// Folder management
	listDel = getFileList(temp_IFmask_Dir);
	for (i = 0; i < listDel.length; i++) {
		File.delete(temp_IFmask_Dir+listDel[i]); }
	File.delete(temp_IFmask_Dir);

// HSB image generation
	if (HSB=="Yes") {
		HSBgeneration();
	}

// Print information
	listGP = getFileList(GP_images_Dir);
	time2 = getTime();
	TOTALtime = (time2-time0)/1000;
	printInfo();
}


///////////////// FUNCTIONS ////////////////////

function closeAllImages() {				// This function closes all images
	while (nImages>0) {
		selectImage(nImages);
		close(); }
}

function newFolder() {					// This function creates a folder, removing any existing file in a folder with the same name
	File.makeDirectory(Folder);
	listFolder = getFileList(Folder);
	for (i = 0; i < listFolder.length; i++) {
		File.delete(Folder+listFolder[i]); }
}

function prepareImage () {				// This funcion prepares each image for the analysis
	s=getTitle;
	run("8-bit");
	run("Grays");
	run("32-bit");
	return s;
}

function HistogramGeneration () {		// This funcion obtains the intensity frequency histogram of the images, makes it smoother,
										// calculates the normal average distribution and also includes the GP value (and GP value
										// corrected by the Gfactor) corresponding to each intensity. An MS Excel file is generated
										// with all this data
	Int=newArray(256);
	Cou=newArray(256);
	Smo=newArray(256);
	NAvDist=newArray(256);
	nBins = 256;

	getHistogram(values, counts, nBins);
	close();
	while (nImages>0) {
		selectImage(nImages);
		close(); }

	for (u=0; u<nBins; u++) {
		Int[u]=u;
		Cou[u]=counts[u];
		if (u<=1) {
			Smo[u]=0; }
		else if (u==255) {
			Smo[u]=0; }
		else {
			Smo[u]=(counts[u-1]+counts[u]+counts[u+1])/3;}
	}
	Array.getStatistics(Cou,min,max,mean,stdDev);
	Sa=(mean*256)-counts[0]-counts[255];
	d=File.open(histoDir + Name[j]+"_Histogram.xls");
	print(d, "Intensity	Counts	Smooth	Norm Av Dist	GP	GP corrected");
	for (k=0; k<256; k++) {
		NAvDist[k]=100*Smo[k]/Sa;
		print(d, Int[k]+"	"+Cou[k]+"	"+Smo[k]+"	"+NAvDist[k]+"	"+GP[k]+"	"+GPc[k]);
	}
	File.close(d);
}

function HSBgeneration() {				// This function generates the HSB image of the GP images as explained in the paper
	closeAllImages();
	setBatchMode(false);

// Select images folder
	listRAW = getFileList(rawGP_images_Dir);
	
	BRIGHTNESS = newArray("Order channel","Disorder channel","IF channel");
	BRIGHTNESSnoIF = newArray("Order channel","Disorder channel");

	HSB_Dir = results_Dir + "HSB images" + File.separator;
	Folder = HSB_Dir;
	newFolder();

	Lut_Dir = getDirectory("luts");
	lut = getFileList(Lut_Dir);

	Dialog.create("Choose images and LUT");
	Dialog.addChoice("Select Hue (GP) image: ", listRAW, "none");
	if (chC == "none") {
		Dialog.addChoice("Brightness folder: ", BRIGHTNESSnoIF, "Order channel");}
	else {
		Dialog.addChoice("Brightness folder: ", BRIGHTNESS, "Order channel");}
	Dialog.addMessage("\n");
	Dialog.addChoice("Select color LUT: ",lut, "Rainbow RGB.lut");
	Dialog.addMessage("\n");
	Dialog.addChoice("Do you want to convert the whole folder into HSB images?", QUESTION, "Yes");
	Dialog.show();

// Feeding variables from dialog choices
	H = Dialog.getChoice();
	BRIGHT = Dialog.getChoice();
	Lut = Dialog.getChoice();
	WholeDir=Dialog.getChoice();

	if (BRIGHT=="Order channel") {
		mark = "_chA_32bits.tif";
		brightness_Dir = results_Dir + "Ordered Images" + File.separator;
	}
	else if (BRIGHT=="Disorder channel") {
		mark = "_chB_32bits.tif";
		brightness_Dir = results_Dir + "Disordered Images" + File.separator;
	}
	else {
		mark = "_IF_32bits.tif";
		brightness_Dir = results_Dir + "Immunofluorescence Images" + File.separator;
	}

	run("Set Measurements...", "  min limit display redirect=None decimal=5");
	index2=indexOf(Lut,".lut");
	L=substring(Lut,0,index2);

	open(rawGP_images_Dir+H);
	name=getTitle();
	Name=substring(name,0,lengthOf(name)-10);
	run(L);
	rename("Hue");

	run("Brightness/Contrast...");
	waitForUser("set min & max","set min & max");
	getMinAndMax(min,max);
	time0 = getTime();

	open(brightness_Dir+Name+mark);
	Bri=getTitle();
	run("Enhance Contrast", "saturated=0.5 normalize");

	selectWindow("Hue");
	run("RGB Color");
	run("Split Channels");

	imageCalculator("Multiply create 32-bit", Bri,"Hue (red)");
	rename("bR");
	run("8-bit");

	imageCalculator("Multiply create 32-bit", Bri,"Hue (green)");
	rename("bG");
	run("8-bit");

	imageCalculator("Multiply create 32-bit", Bri,"Hue (blue)");
	rename("bB");
	run("8-bit");

	run("Merge Channels...", "red=bR green=bG blue=bB gray=*None*");
	saveAs("tiff", HSB_Dir + Name + "_HSB");

	closeAllImages();

// HSB whole folder processing
	if (WholeDir == "Yes") {
		for (j = 0; j < listRAW.length; j++) {
			open(rawGP_images_Dir+listRAW[j]);
			name1=getTitle();
			Name1=substring(name1,0,lengthOf(name1)-10);
			rename("Hue");
			run(L);
			setMinAndMax(min,max);

			open(brightness_Dir+Name1+mark);
			run("Enhance Contrast", "saturated=0.5 normalize");
			Bri=getTitle;

			selectWindow("Hue");
			run("RGB Color");
			run("Split Channels");

			imageCalculator("Multiply create 32-bit", Bri,"Hue (red)");
			rename("bR");
			run("8-bit");

			imageCalculator("Multiply create 32-bit", Bri,"Hue (green)");
			rename("bG");
			run("8-bit");

			imageCalculator("Multiply create 32-bit", Bri,"Hue (blue)");
			rename("bB");
			run("8-bit");

			run("Merge Channels...", "red=bR green=bG blue=bB gray=*None*");
			saveAs("tiff", HSB_Dir + Name1 + "_HSB");

			closeAllImages();
		}
	}

// Make HSB LUT bar
	newImage("Hue", "8-bit Ramp", 256, 256, 1);
	run(L);
	run("Duplicate...", "title=Brightness");
	run("Rotate 90 Degrees Left");
	run("32-bit");
	selectWindow("Hue");
	run("RGB Color");
	run("Split Channels");
	imageCalculator("Multiply create 32-bit", "Brightness","Hue (red)");
	rename("bR");
	run("8-bit");
	imageCalculator("Multiply create 32-bit", "Brightness","Hue (green)");
	rename("bG");
	run("8-bit");
	imageCalculator("Multiply create 32-bit", "Brightness","Hue (blue)");
	rename("bB");
	run("8-bit");
	run("Merge Channels...", "red=bR green=bG blue=bB gray=*None*");
	rename("HSB LUT");
	selectWindow("Hue (red)");
	close();
	selectWindow("Hue (green)");
	close();
	selectWindow("Hue (blue)");
	close();
	selectWindow("Brightness");
	close();

	selectWindow("HSB LUT");
	run("Rotate 90 Degrees Left");
	run("Size...", "width=32 height=256 interpolation=None");


// Copy LUT bar to the image
	run("Copy");
	newImage("Panel LUT", "RGB White", 70, 264, 1);
	setBatchMode(false);
	makeRectangle(4,4,32,256);
	run("Paste");
	run("Colors...", "foreground=black background=black selection=yellow");
	run("Line Width...", "line="+2);
	run("Draw");
	run("Select None");
	setFont("Arial", 12);
	setColor(0, 0, 0);
	drawString(d2s(max,2),39,15);
	drawString(d2s(min,2),39,264);
	run("Select None");

	if (WholeDir == "Yes") {
		saveAs("tiff", HSB_Dir + "Lut bar");
		close();
	}
	else {
		saveAs("tiff", HSB_Dir + Name + "_Lut bar");
		open(HSB_Dir + Name + "_HSB.tif");
	}
	closeAllImages();
}

function printInfo () {					// This function prints and saves a summary of the results of the macro
	print("\\Clear");
	print("GP images analysis macro");
	print("   Quantitative Imaging of Membrane Lipid Order in Cells and Organisms");
	print("   Dylan M. Owen, Carles Rentero, Astrid Magenau, Ahmed Abu-Siniyeh and Katharina Gaus");
	print("   Nature Protocols 2011");
	print("   version July 2011");
	print("\n");
	print("Ordered channel: " + chA);
	print("Disordered channel: " + chB);
	print("   Lower threshold value: " + t);
	if (chC != "none") {
		print("Channel IF: " + chC);
		print("   Lower threshold value IF mask: " + tc); }
	print("");
	print("GP images (" + (listGP.length-1) + ") saved at:");
	print("  " + GP_images_Dir);
	print("G factor: " + Gf);
	print("Scale color for GP images: " + lut1);
	print("");
	if (chC != "none") {
		listGP2 = getFileList(GP_IF_images_Dir);
		print("GP-IF images (" + (listGP2.length-1) + ") saved at:");
		print("  " + GP_IF_images_Dir);
		print(""); }
	if (HSB=="Yes") {
		print("HSB images saved at:");
		print("  " + HSB_Dir);
		print("");
	}
	print("");
	print("Execution time: " + d2s(TOTALtime,2) + " seg.");
	print("");
	print("Analysis date: "+DayNames[dayOfWeek]+", "+dayOfMonth+" "+MonthNames[month]+" "+year+" - "+hours+":"+minutes);
	print("ImageJ version " + getVersion());

	selectWindow("Log");
	saveAs("Text", results_Dir + "Log GP images generation "+year+"-"+months+"-"+dayOfMonths+" "+hours+"h"+minutes);

	setBatchMode("exit and display");	
}

But when i try this on my images, i get an error in line 126 of the macro (screenshot below)

Here is also an example of the images i am trying to run the macro on.1.zip (1.3 MB)
Any help would be appreciated!

Thanks,
-Praveen


#2

I have not ran you macro (the leading > do prevent me from performing copy&paste), but I think you will find the problem in the for loop that processes the file list. Gf1 is only set in the second if condition. If this will not evaluate to true, Gf1 is not defined, as the error message shows. Setting (initializing) Gf1 = 0, e.g. at line 101 should help.


#3

Hey,
Sorry about the formatting. I just edited it again so that one can try to run the macro. I tried to change the value to 0 but it still gives me the same error.


#4

From your screenshot, I can only speculate that Gf1 (that’s the variable highlighted by <> in the error message) is not defined, presumably because the if condition a few lines above is never met?!

if (endsWith(listDir[i], chB+".tif")) {
		open(dir + listDir[i]);
		prepareImage();
		Gf1=Gf;
		...

But the error messages should be clear enough to allow you debugging this yourself. Please don’t throw a thousand lines of code onto the forum and expect others to debug it for you.

If you want useful help, try to create a minimal, runnable example that reproduces the issue. In many cases, you’ll find the mistake already while trying to create this. :slight_smile:


#5

Sorry about that. I did what you told me but by running the macro part by part and i cant even make it save the images in 32-bit file format (which is the first part of the macro). Not sure if i am doing something wrong. Moroever i am not that good at writing/compiling big macros :frowning:


#6

Your best friend is the print function. It is the poor man’s debugging tool, but it is tried and true. Inject some print statements at key points to make sure the macro is working the way you think it is working. Double check your control flow (e.g., inside that if statement as @imagejan suggests) as well as the values of your variables.


#7

Hello @Praveen!
Did you finally find the solution to your problem? The same thing is happening to me and I don’t find the answer :slight_smile:
Thanks in advance!
Helene


#8

Hello @Helene
Yes i could get it working in the end. Here is the macro i used, try and see if this works.
-Praveen
Di-anepp macr.zip (4.7 KB)


#9

Thank you @Praveen ! I tried your macro, but I had the exact same problem as with the first one.
I’m starting with programming, coding and debugging, so maybe my problem is in fact very stupid.

So I have at first the same error as you did

The undefined variable here is Gf1; that is define in the first dialogue box that opens when I run the macro. So I decide to change Gf1 in the function by the value I asked first in the dialogue box (for exemple “1”, which is defined as the default Gf1).
By doing so, the macro is running and here is the answer:


The problem is that there’s nothing in the folders the macro creates, no results obtained either in imageJ. But because the macro is running apparently correctly, I don’t really know how to debugg it.

Then I decided to change stuffs in the dialogue box of the macro and I answered “yes” to “do you want to generate HSB images”. As it was said in the paper from Owen, a new dialogue box opened, I did the stuffs there and here the bug I had then.

But in fact I don’t know which file causes trouble here? The image I want to analyse? Or the image it’s supposed to generate? My two channels are saved as 8-bit grayscale.tiff format images (I tried together or in separate image (one channel/one image; but this one lead to another bug link to the image opening)) as they said in the paper. I also tried with 32-bit images but it gave me exactly the same bugs.

I’m sorry if my problem seems very naive, but I’m juste starting using imageJ. I’m eager to learn =)
Thanks in advance!


#10

Hi Helene,
Do you think you can upload the images from both the emission spectra here? I can have a look then.
-Praveen


#11

@Helene,
Ok i just remembered what the problem was with the macro. I replaced ‘TIFF’ to ‘tif’ in the lines between 102-117. I know this sounds silly but it worked for me =) I have already done this in the macro which i posted above, so you can just use this macro and see if it works. =) Here is a screenshot of the working macro

-Praveen


#12

I’m so sorry @Praveen, I still have the exact same bugs even with your macro. I also modified the one I was working with as you said in your last messages, but it didn’t change anything…

Here ( https://www.dropbox.com/s/greisgkn9s96d4i/CTL-Laurdan-L1-1.1-1.tif?dl=0 ) a image in 8 bits grayscale; I keep both channels together and not in separate images because it cause further bugs, but I’m not sure that’s the way to do it.

Thanks a lot for helping me! It’s really nice =)


#13

Hey Helene,
I just ran the macro on your images. It works fine for me atleast =) I just saved the files from both the channels as A.ch00 and A.ch01 and ran the macro. Here is the GP image the macro generated.

What naming did you follow while saving these files?

-Praveen


#14

Oh good that’s great!!!
In fact I was saving them ch00 and ch01 as they said in the paper. I see that putting the “A.” before change the format of the image (?), and I didn’t have any bug with the opening of the images as before.

However, I still have exactly the same problems as I explained in the precedent posts… I’m probably cursed (or very bad at this XD ).

Which version of imageJ are you using? I’ve upgraded mine to 1.50i today. Maybe I don’t have a pluggin or something that you do…

Did you use the macro you’ve posted before without changing a thing? (I tried with yours too, by the way, same results…)

What GP analysis parameters did you use? I used the following

(I didn’t generate HSB images because it lead to another bug).

To be sure here every steps of my process to run the macro:
-I save the macro in the folder macro from imageJ
-I install it in imageJ (plugins>macros>install) and then run it
-I select the folder where my images are
-The dialogue box oppens and I choose the parameters as I showed you above

I also run the macro from the edit (pluggins>macros>edit…> …) box and I have the same results.

I tried 5 variations of the macro:
-the original
-the original with Gf1 replaced by 1
-the original with Gf1 replaced by 1 and tiff by tif
-yours
-yours with Gf1 replaced by 1

I don’t know what else could play here…

Again, thank you for the time spent helping me!!!


#15

@Helene are you using Fiji or just plain ImageJ1? I think @Praveen’s macro requires Fiji as it relies on the plugins that are available in Fiji.


#16

@imagejan I use the “basic” ImageJ (so I suppose ImageJ1). In the paper, they said that it is a macro for imageJ, and the one Praveen sent seems to be the same with some modifications.

(I’m trying with Fiji now!)

Edit: I have the same problems with Fiji. I have to admit, I’m probably doing something wrong XD


#17

Hi Helene,
Dont worry, we are all here to help each other :slight_smile:
Like @imagejan mentioned I use Fiji for everything i do. I will mention how i run my macro.

  1. First i created a folder (for the first image - A) . Then save my 8-bit images in there, A.ch00 and A.ch01.
  2. Then i just drag and drop the macro file which i uploaded in my previous posts to Fiji and run it.
  3. I guide the macro to the folder i created in Step 1 and here are my GP analysis parameters. The G factor values for my experiments are calculated everytime (like mentioned in the paper). The rest of my values are always the same.

I dont generate HSB images either, cause i dont really need them at this stage. You dont have to save or install the macro in the folder/Fiji. You can just drag and drop the macro file onto Fiji and run it. I also did not change the Gf1 values in the macro like you mentioned. All i did was change ‘TIFF’ to ‘tif’ in the original macro… If it still does not work for you, i can help you out by team viewer or something?

Let me know…
Praveen


#18

It’s woooorking!
The problem comes from the format of the saved images! As I said earlier, when saving both chanels putting A.ch00 change the format and the image was A and the format ch00; and even if I choose first to save as tiff. I found that weird so I wrote A.ch00.tiff instead and it’s working perfectly!!

Thank you so much for your help! I learned a lot!

-Hélène


#19

Hello @Praveen @Helene, Have you produced a HSB image? I have been trying but always encounter the following error. I’ve tried plain Imagej and Fiji, adding new LUTS, and looking for bugs in the code but I haven’t found any.

Thanks!


#20

Hey @Reyn !
Could you please detail the steps of your process?
I try today and it does not work, probably because I do not know what I should choose in the second dialogue box “choose images and LUT”. I can only choose A_preGP.tif for “select Hue (GP) image” for exemple. But I have the same problem and the same message. I do not know what to do either because I do not understand the message…