<< Main Manual

Tutorial #6. Simplifications for writing/using scripts

The previous example gets a little unnecessarily verbose in places, so the script/JythonStartup.py script provides a few convenience functions.

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 #5. Auto-generated figures using Layouts
>> Tutorial #7. Controlling Micro-Manager through scripts

<< Main Manual