My Plot Window (Plot Object) format.



Note that this section of my website has recently changed. My ImageJ plugins will still support the old pw file types, but I have updated the file format with a different header to support more plot window types. Files with extensions of pw or pw2 will be appropriately read by the new importers.

Many of my plugins rely on my version of the plot window to store and manipulate data. It is also useful to be able to save plots in their native format to preserve scaling, etc. for future viewing/analysis. In order to do this, simply click the save button at the bottom of one of my plot windows or go to Trajectory Tools>export plot jru v1 (should work for ImageJ plot windows as well) and save as file name.pw2. Then you can reimport into ImageJ using import plot jru v1. You can implement drag and drop by modifying your ImageJ\plugins\Input-Output\HandleExtraFileTypes.java code to include:

if(name.endsWith(".pw") || name.endsWith(".pw2"){
     return tryPlugIn("import_plot_jru_v1",path);
}

inside the tryOpen function. Here is an example. Then compile that code in ImageJ (nothing will happen) and it should then allow drag-and-drop of plot window files. You can download a precompiled version here. Note that I compiled this version from a recent ImageJ distribution. Be sure to back up your old version in case there are some old formats you need that the newer version doesn't support. If that is the case, you have no choice but to add the code manually and recompile.

If you are less resistant to change than me and are now using FIJI, life working with my file type is a bit harder but still workable. You have three basic options. The first is to always import my plot windows via the Plugins>Trajectory Tools>import plot jru v1. The second is to launch my new Plugins>File Tools>HEFT shortcut window jru v1. The resulting window will provide a drag-n-drop interface for my file types. If you are curious how I did this, check out the handleextrafiletypes_importer class in the jguis folder in the source code. The third option is to utilize my new LOCI Bioformats importer. To use this method, simply run Plugins>File Tools>register jay readers jru v1. This will tell the loci importer that it can use my importer to read pw and pw2 files. If you use my FIJI update site, it should give you an autorun macro that registers my importer when ImageJ starts. If you prefer not to do that, you can simply download it here and copy it to your Fiji.app folder under macros/AutoRun/. If you are curious how I implemented my loci reader, please see the loci_pw_reader_jru_v1 class in the source code. Basically it follows the vanilla FormatReader convention but sends loci a blank image. It then listens for when ImageJ loads the image and coopts it to display the plot window. My future plans on this project are to provide a utility plugin for my shortcut window so that you can easily add any format you want as long as there is a plugin to import it.

The Trajectory Tools submenu contains quite a few useful tools for manipulating plot windows. A few notable ones are trajectory calculator jru v1 (similar to the built-in image calculator), traj math jru v1 (similar to Process>Math), combine all trajectories jru v1, average trajectories jru v1 (can also calculate other statistics and errors), copy errors jru v1, edit plot sizes jru v1 (changes text and symbol sizes), and resample plot jru v1 (changes the x axis tick frequency).

Plot Window Macro Extensions.



I recently implemented macro extensions for my PlotWindows. The source code is available in the PlotWindow_Extensions_jru_v1.java file in Jay_Plugins2.jar if you want to see how I did it. To use them, start your macro with this command: run("PlotWindow Extensions jru v1");. In general I don't recommend the macro language for manipulation of large data sets and you may experience long delays in processing such data sets. In many cases, I would encourage the user to learn how to write plugins. Nevertheless, I understand that there is a barrier to learning java and hopefully the macro implementation gets people by if they are not willing to overcome that barrier. Below are the macro commands that I have implemented so far:

Ext.getNSeries(nseries): This command assignes nseries to number of plot series'.
Ext.selectSeries(selection): This command selects a plot series starting at zero (or none if the value is less than 0).
Ext.scalePlotCoords(x,y,xs,ys): This command scales the image coordinates given by x,y to plot coordinates given by xs,ys.
Ext.getLimits(xmin,xmax,ymin,ymax): This command gets the current plot display limits.
Ext.setLimits(xmin,xmax,ymin,ymax): This command sets the plot display limits.
Ext.setLogAxes(logx,logy): A value of 1 sets the axis to logarithmic (0 sets linear).
Ext.setXLabel(xlabel): Sets the x axis label text.
Ext.setYLabel(ylabel): Sets the y axis label text.
Ext.setGridWhiteness(whiteness): Sets the whiteness of the background grid between 0 (black) and 255 (white).
Ext.deleteSelected(): Deletes the selected series.
Ext.autoscaleX(): Autoscales the x axis (from min value to max value).
Ext.autoscaleY(): Autoscales the y axis (from min value to max value).
Ext.scaleROI(): Scales to the ROI drawn on the plot (rectangle).
Ext.setMagnification(magnification): Changes the size of the plot.
Ext.setMagRatio(magratio): Changes the plot aspect ratio.
Ext.getSelNpts(selnpts): Gets the number of points in the selected series.
Ext.getSelXYVals(index,x,y): Gets the x,y value pair for the index point in the selected series (index goes from 0 to selnpts-1).
Ext.addXYSeries(xdata,ydata): Adds a new series to the plot window from vectors xdata and ydata. If xdata is not the same size as y data it is ignored and x values go from 1 to ydata length. For quick plotting, you can replace xdata with newArray(0).
Ext.updateSelSeries(xdata,ydata): Changes the selected series to the data in xdata and ydata arrays.
Ext.createPlot(xlabel,ylabel,xdata,ydata): Creates a new plot window with xdata and ydata.
Ext.convertToPW4(): Converts a traditional ImageJ plot window into my plot window.
Ext.convertToPW(): Converts my plot window into a traditional ImageJ plot window.


PW file specification.



Below is the simple specification for the pw2 format. If someone has a good suggestion for a better (simple) format, I would be open to changing. The file format is binary and all data are stored in intel byte order.

All strings are written as an intel integer (32-bit) with the number of characters followed by the ascii text string (no unicode). All boolean flags are written as intel integers with false=0 and true=1

1. Write the string, "pw2_file_type"
2. Write the integer 0 (specifies a 2D plot)
3. Write the x axis label as string
4. Write the y axis label as string
5. Write the number of data series' as intel integer
6. Write the max number of points as intel integer
7. Write the x axis min value as intel float (32-bit)
8. Write the x axis max value as intel float
9. Write the y axis min value as intel float (32-bit)
10. Write the y axis max value as intel float (32-bit)
11. Write the boolean flag (1 or 0) for log x axis
12. Write the boolean flag (1 or 0) for log y axis
13. For each series write:
     a. number of data points (npts) as intel integer
     b. shape index as intel integer (0-4 denotes line,square,plus,x,triangle)
     c. color index as intel integer (0-7 denotes black,blue,green,red,magenta,cyan,yellow,orange)
     d. list of npts x values as intel floats
     e. list of npts y values as intel floats
This can be the end of the file if errors are not displayed. The file may also contain the following:
12. Boolean flag for show errors
13. For each series write:
     a. list of npts upper errors as intel floats
     b. list of npts lower errors as intel floats

Other plot types can also be stored in this file type including 1D and 2D histograms, column plots, and 3D plots and trajectories. These plot types are specified in the source code in the jguis package as the classes PlotHist, Plot2Dhist, PlotColumn, Plot3D, and Traj3D, respectively. They all have public methods entitled "saveplot2os" which indicate the file format details.