Trouble using Bioformats Macro Extensions

I currently use Bio-Formats Importer to open my Leica confocal *.lif files with a FOR loop with variable ‘s’ for the series. This allows me to open the series as long as I know the series number. Can I open a series with the series name?

Here is my code

//activate Bio-formats plugins");
run(“Bio-Formats Macro Extensions”);

// make file name usable on Mac or PC");
fs=File.separator;
//get source directory");
dir=getDirectory(“Choose a Directory”);

//generate file list");
list=getFileList(dir);

//Make a subdirectory called Results in the same directory to save images");
saveDir=dir+“Results”;
File.makeDirectory(saveDir);
//setBatchMode(true);

//open table and extract names of the files I want use
run("Table… ", “open=[D:/Local copy of data/Vi/Pixel shift/PixelShift.csv]”);
selectWindow(“PixelShift.csv”);
headings = split(Table.headings); // splits table headings from tab separated into an array
columnsInTable=lengthOf(headings);
rowsInTable=getValue(“results.count”);
Table.sort(“File name”);
checkFileName=Table.getColumn(“File name”);
checkSeriesName=Table.getColumn(“Series Name”);
pixelShiftValue=Table.getColumn(“PixelShift”);

// FIJI uses this format as the file name
checkNameStore=checkFileName[w]+" - "+checkSeriesName[w];

// I want to open the file titled checkNameStore without having to open each image of 10,000 frames in the file.
for (w = 0; w < rowsInTable; w++) { // look for each series in table
checkNameStore=checkFileName[w]+" - “+checkSeriesName[w];
print(“checkNameStore =”,checkNameStore);
for(i=0;i<list.length;i++){
//generate file path”);
filePath=dir+list[i];
Ext.setId(filePath);
Ext.getSeriesCount(seriesCount);
isThisCorrectFileName=“notYet”;
for (d = 0; d < list.length; d++) {
if(list[d]==checkFileName[w]){
i=d; //moves to the right fileName
print(" list = “+list[d]);
print(“fileName =”+checkFileName[w]);
print(“Right fileName”); // hooray
isThisCorrectFileName=“Yes”;
filePath=dir+list[i]; //updating the filePath variable
}
}
if (isThisCorrectFileName==“notYet”) {
print(“No such file name”);
}
//only open .lif files”);
if(endsWith(filePath, “.lif”)){
//loops for all series in select lif file ");
for(s=0;s<seriesCount;s++){
print("Processing LIF file “+(i+1)+” of “+list.length+” Series “+(s+1)+” of "+seriesCount);
roiManager(“reset”);
//setBatchMode(true);

//is there a way to use the Bio-Formats Importer to select the series by name rather than number?
//run(“Bio-Formats Importer”, “open=[”+filePath+"] autoscale color_mode=Default view=Hyperstack stack_order=XYCZT series_"+(s+1));

                            nameStore=getTitle();
			if (nameStore==checkNameStore) { // this loop looks to match the right file from the table
                                print("We have a match");
                            }

I have tried to use Ext.getSeriesName(seriesName); but it only gives the current series, not the whole series. If I could step through the series without opening every one. I have 25 in the current series and they have 10,000 frames in each.

Cheers

Tim

Hi Tim,

Do you know the command below?
Ext.setSeries(seriesNum)

You could use a loop to go through and set the series number and then use your
Ext.getSeriesName(seriesName) command

Does that help?

Laura

Edit: added below script that will print out an array of all the file names in a .LIF file.

run("Bio-Formats Macro Extensions");

filePath = File.openDialog("Choose a LIF file");
Ext.setId(filePath);
Ext.getSeriesCount(seriesCount);

print(filePath + " has " + seriesCount + " files");

seriesList = newArray;

for (s = 0; s < seriesCount; s++){
	Ext.setSeries(s);
	Ext.getSeriesName(seriesName);
	seriesList = Array.concat(seriesList, seriesName);
}

Array.show(seriesList);
1 Like

Hi Laura

Thanks, that is a great solution.

Cheers

Tim

1 Like