Help with Batch Processing (CZI > JPEG)

fiji
imagej
batch-processing
macro

#1

Hi all, I am looking for some help with batch processing in Fiji. I am very new to coding and using the software in general. I have accumulated hundreds of images using Neurolucida software and would like to covert them using Fiji (because I have noticed that the quality/resolution of the image is better compared to converting to PNG/JPEG in Neurolucida).

I am currently doing this manually by: opening the image (viewing with hyper stack and with the composite color mode, and telling the program to stitch all the tiles) > image > color > composite > save as JPEG

As you could image, this current process is pretty lengthy for the amount of images that I have.
I found a macro (below), however whenever I use it I have to manually select the Bio-Formats Import Options for each slide. Although this is easier than what I was doing before, I was wondering if anyone knew of a way to code for the computer to select the prompts that pop up? This prompt opens for every image. I would appreciate any help you can offer

dir1 = getDirectory("Choose Source Directory ");

dir2 = getDirectory("Choose Destination Directory ");
list = getFileList(dir1);
setBatchMode(true);

for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
open(dir1+list[i]);

saveAs(“JPEG”, dir2+list[i]);
close();
}


#2

I hope you are aware of the fact that JPG-compressed images are a no-no for any kind of scientific image analyses.

JPG-compression introduces artifacts that can’t be removed!

Regards

Herbie


#3

Hi Herbie, I am not aware of that. Thank you ! I should note that I am not trying to preform any analysis for these images - simply trying to use them for presentations (posters/powerpoints/ect).
What you recommend converting them into for this type of purpose?


#4

I should note that I am not trying to preform any analysis for these images - simply trying to use them for presentations (posters/powerpoints/ect).

JPG is valid for display purposes, publications, reports etc.

Go ahead

Herbie


#5

Hi there,

Have you come across the macro recorder? It can be launched via Plugins > Macro > Record… and I find it really helps in situations like this as it records what you do in FIJI as it would be written in a macro.

If you open a file that needs the using Bioformats plugin (which you are in this case as that’s why you get that window popping up) then you should get something that looks like the below:

So that means a line like that is needed in your macro. So I’ve inserted that into your macro and the code is below. I hope it works as you expect.

dir1 = getDirectory("Choose Source Directory ");
dir2 = getDirectory("Choose Destination Directory ");

list = getFileList(dir1);

setBatchMode(true);

for (i=0; i<list.length; i++) {
	showProgress(i+1, list.length);
	path = dir1 + list[i];
	run("Bio-Formats Importer", "open=[" + path  + "] color_mode=Composite rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");      
	
	saveAs("JPEG", dir2+list[i]);
	run("Close All");
}

Best,
Laura


#6

Hello there Laura,

Thank you so much! This helped the problem. The macro reader is very useful. I will use this in the future.

I appreciate you

Best,
Kiana