/* Olympus viewer sometimes imports Stream vsi with blue-green-red channel order, this macro fixes that v200407: 1st version PJL National High Magnetic Field Laboratory v210920: Works for original 3 channel import */ macroL = "Import_Olympus_VSI_Stream_Image_v210921.ijm"; Dialog.create("Select file for import"); Dialog.addFile("TIFF file save location:",File.directory); Dialog.show; openPath = Dialog.getString(); run("Bio-Formats", "open=["+openPath+"] color_mode=Default rois_import=[ROI manager] view=[Standard ImageJ] stack_order=Default series_1"); setBatchMode(true); getDimensions(width, height, channels, slices, frames); ti = getTitle; extPos = lastIndexOf(ti,"."); fixed = false; if (extPos>0) { extension = substring(ti, extPos); ti = substring(ti, 0, extPos); } else extension = ""; rename("temp"); /* have not figured out how to handle odd filenames in Merge command */ if (channels==1 && slices==1){ run("Split Channels"); run("Merge Channels...", "c1=[temp \(blue\)] c2=[temp \(green\)] c3=[temp \(red\)]"); fixed = true; } else if (channels==3 && slices==1){ run("Arrange Channels...", "new=321"); run("Merge Channels...", "c1=temp c2=temp c3=temp"); rename(ti + "_ch321" + extension); fixed = true; } getDimensions(width, height, channels2, slices2, frames2); if (channels2==1 && slices2==3){ if (bitDepth()==24) run("8-bit"); else if (bitDepth()==32) run("16-bit"); run("Stack to RGB"); fixed = true; } if (!fixed) exit("Sorry, not expecting channels = " + channels + ", slices = " + slices + ", frames = " + frames); rename(ti + "_ch321" + extension); setBatchMode("exit and display"); beep();wait(300);beep();wait(900);beep(); call("java.lang.System.gc"); showStatus(macroL + "completed");