<< Main Manual

Tutorial #5. Auto-generated figures using Layouts

We were interested in providing a generalizable mechanism to dynamically generate complicated figures from multiple analyzed images as well as non-trivial charts. To this end, we added a Layout object to the PhysImage package that can be used to construct customized Layout templates and then, using the Python scripting console or scripts, we can combine images and charts to form complex figures that can be exported as .tif files, .eps files, or as PhysImage-readable .layout files for later manipulation. 

Example #1

Below is an example that takes a previously acquired time-series image, runs an ImageJ macro on it that generates several processed static images, then loads the 4 images into a previously saved Layout template. It also generates a chart from the time-series data, imports it into the template as well, and then saves the Layout as a PhysImage-readable .layout file and a .tif static image file.

>># Acquire the online dF/F and imaging time-series
>># runPlugIn("BeanShellRunner_", "Labjack_sequence.bsh")
>>
>># retrieve the acquired image
>>image = WindowManager.getCurrentImage()

>># get the "autonamed" name for the data
>>runName = image.getTitle()   
>>runName = runName[:runName.find(".")]

>># run an ImageJ analysis macro on the raw data
>>IJ.runMacroFile("HolographicAnalysis2_40x.txt")

>># get the resulting Composite image and
>>#      make an RGB image from it (the "Overlay" image)
>>ip = WindowManager.getImage("Composite")
>>ip2 = ImagePlus("Composite_RGB", ip.getBufferedImage())
>>ip2.show()

>># load a Layout template
>>layout = Layout("layouts" + os.sep + "HoloProtocol2.layout.template")
>>IJ.runMacro("selectWindow('Composite')")
>>IJ.run("Split Channels")
>>
>># load the layout with new images
>>layout.setLayoutComponent(0, WindowManager.getImage("C2-Composite"))
>>layout.setLayoutComponent(1, WindowManager.getImage("C3-Composite"))
>>layout.setLayoutComponent(2, WindowManager.getImage("C1-Composite"))
>>layout.setLayoutComponent(3, WindowManager.getImage("Composite_RGB"))
>>layout.repaint()
>>
>># load the dF/F data for a Chart
>>waveManager = WaveManager.getInstance()
>>waveManager.clear()
>>IJ.runMacro("selectWindow('"+str(Configuration_.getLastStreamLength())+"')")
>>waveManager.importWave()
>>waveManager.plot()
>>
>># load the Chart into the layout
>>charts = WindowManager.getCharts()
>>layout.setLayoutComponent(0, charts[0])
>>layout.repaint()
>>
>># add a label
>>layout.addText(runName, 25, 25)

>># autosave the layout as a .tif and a reloadable .layout file
>>layout.saveLayout(runName + "layout.layout")
>>layout.exportToTiff(runName + "layout.tif")
>>


After the data is in the WaveManager it got manipulated or plotted as a chart in the previously demonstrated ways.

<< Tutorial #4. Online acquisition of F/F data
>> Tutorial #6. Simplications for writing/using scripts

<< Main Manual