Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
software:fiji_mvr [2019/07/16 20:50]
Jon Daniels added script
software:fiji_mvr [2019/07/27 18:19] (current)
Jon Daniels [Fiji MVR scripts]
Line 90: Line 90:
 // Open MultiView Application // Open MultiView Application
 IJ.run("MultiView Reconstruction Application", "select_xml=["+xml_file.getAbsolutePath()+"]"); IJ.run("MultiView Reconstruction Application", "select_xml=["+xml_file.getAbsolutePath()+"]");
 +
 +</code>
 +
 +This script did some other pre-processing:
 +
 +<code groovy>
 +
 +
 +#@File main_folder (label="Main Folder", style="directory")
 +
 +// Iterate and find all files
 +import static groovy.io.FileType.FILES
 +import ij.IJ
 +import ij.plugin.ChannelSplitter
 +import ij.io.Opener
 +
 +import groovyx.gpars.GParsPool
 +
 +
 +def save_folder = new File(main_folder, "exploded_channels_views")
 +save_folder.mkdir()
 +
 +
 +def opener = new Opener()
 +// Find all files.
 +def all_files = []
 +main_folder.eachFile(FILES) { file ->
 +    if(file.getName().endsWith(".tif") && !file.getName().contains("_1")) {
 +    all_files.add(file)
 +    //println(file)
 +    }
 +}
 +
 +Collections.reverse(all_files)  // reverse order
 +
 +
 +//all_files = all_files.take(1)
 +
 +//GParsPool.withPool(10) {
 + //all_files.eachParallel{ file ->
 + all_files.each { file ->
 +     //def temp_image = opener.openTiff(file.getParent()+File.separator, file.getName())
 +
 + println("starting " + file)
 +
 +     def temp_image = IJ.openImage(file.getAbsolutePath())
 +
 +     def images = ChannelSplitter.split(temp_image)
 +
 +     // 0 is ch1 view 1
 +     // 1 is ch1 view 2
 +     // 2 is ch2 view 1
 +     // 3 is ch2 view 2
 +     
 +     //resave all
 +     def image_name = file.name.take(file.name.lastIndexOf('.'))
 +     IJ.saveAsTiff(images[0], new File(save_folder, sprintf("%s_Ch%d_Angle%d.tif",image_name, 1, 0)).getAbsolutePath())
 +     IJ.saveAsTiff(images[1], new File(save_folder, sprintf("%s_Ch%d_Angle%d.tif",image_name, 1, 90)).getAbsolutePath())
 +     IJ.saveAsTiff(images[2], new File(save_folder, sprintf("%s_Ch%d_Angle%d.tif",image_name, 2, 0)).getAbsolutePath())
 +     IJ.saveAsTiff(images[3], new File(save_folder, sprintf("%s_Ch%d_Angle%d.tif",image_name, 2, 90)).getAbsolutePath())
 +     images.each{it.close()}
 +     
 +     temp_image.close()
 +
 +     println("finished " + file)
 + }
 +//}
  
 </code> </code>