//4d Viewer to Hyperstack macro // Create dialog to obtain input from user inputDir = getDirectory("Select a Directory"); // Get file list in input directory images = getFileList(inputDir); //Check for movie files in the selected directory //The 4d Viewer data structure is a series of movies with the name "FocalPlane" + n, where n is non--added number (")1,2...10...etc.). f = 0; for (i = 0; i < images.length; i++) { if ((indexOf(images[i], ".mov") > 0) || (indexOf(images[i], ".MOV") > 0)) { //print("Processing " + inputDir + images[i]); firstMovieName = images[i]; f = f + 1; } } if (f == 0) { showMessage("No movie files found."); exit; } //Ordinarily would need to pad filenames and run an array sort here, //but Bio-Formats is smart about this! //print("Movie files found: " + f); /* n = 0; for (i = 0; i < images.length; i++) { if ((indexOf(images[i], ".mov") > 0) || (indexOf(images[i], ".MOV") > 0)) { run("Bio-Formats Importer", "open=" + inputDir + images[i] + " color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT"); print("Processing " + images[i]); n = n + 1; if (n == 1) { selectWindow(images[i]); timePoints = nSlices; } } } */ /* n = 0; for (i = 0; i < f; i++) { fileName = inputDir + "FocalPlane" + (i+1) + ".mov"; //print("File name: " + fileName); run("Bio-Formats Importer", "open=[" + fileName + "] color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT"); print("Processing " + "FocalPlane" + (i+1) + ".mov"); n = n + 1; if (n == 1) { selectWindow("FocalPlane" + (i+1) + ".mov"); timePoints = nSlices; } } print("Focal planes = " + f); print("Time points = " + timePoints); print("Concatenating..."); //run("Concatenate...", " image1=FocalPlane1.mov image2=FocalPlane2.mov image3=FocalPlane3.mov image4=FocalPlane4.mov image5=FocalPlane5.mov image6=FocalPlane6.mov image7=FocalPlane7.mov image8=FocalPlane8.mov image9=FocalPlane9.mov image10=FocalPlane10.mov image11=FocalPlane11.mov image12=FocalPlane12.mov"); run("Concatenate...", "all_open"); print("Converting to Hyperstack..."); run("Stack to Hyperstack...", "order=xyctz channels=1 slices=" + f + " frames=" + timePoints); rename("Concatenated 4d"); setBatchMode(false); print("Complete."); */ run("Bio-Formats Importer", "open=" + inputDir + firstMovieName + " color_mode=Default group_files rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT use_virtual_stack dimensions axis_1_number_of_images=" + f + " axis_1_axis_first_image=1 axis_1_axis_increment=1 contains=[] name=" + firstMovieName + "-" + f + ".mov");