View Javadoc
1   package com.github.celldynamics.quimp.plugin.qanalysis;
2   
3   import java.io.File;
4   
5   import com.github.celldynamics.quimp.QColor;
6   import com.github.celldynamics.quimp.QParams;
7   import com.github.celldynamics.quimp.plugin.AbstractPluginOptions;
8   import com.github.celldynamics.quimp.utils.QuimpToolsCollection;
9   
10  /**
11   * Configuration class for Q_Analysis.
12   * 
13   * @author rtyson
14   *
15   */
16  public class Qp extends AbstractPluginOptions {
17  
18    /**
19     * snQP file.
20     */
21    public transient File snQPfile;
22    /**
23     * stQP file.
24     */
25    public transient File stQPfile;
26  
27    /**
28     * Full path to output file.
29     * 
30     * <p>Include {@link #filename}
31     */
32    public transient File outFile;
33  
34    /** The core of filename. */
35    public transient String filename;
36  
37    /** Pixel size in microns. */
38    public transient double scale = 1;
39  
40    /** The frame interval. */
41    public transient double frameInterval = 1;
42  
43    /** The start frame. */
44    transient int startFrame;
45  
46    /** The end frame. */
47    transient int endFrame;
48  
49    /**
50     * Frames per second.
51     * 
52     * <p>1/{@link #frameInterval}
53     */
54    public transient double fps = 1;
55  
56    /** The increment. */
57    public transient int increment = 1;
58  
59    /** The track color. */
60    public String trackColor = QColor.colourMaps[0];
61  
62    /** The outline plots. */
63    public transient String[] outlinePlots = { "Speed", "Fluorescence", "Convexity" };
64  
65    /** The outline plot. UI element. */
66    public String outlinePlot = outlinePlots[0];
67  
68    /** The sum cov. UI element. */
69    public double sumCov = 1;
70  
71    /** The avg cov. UI element. */
72    public double avgCov = 0;
73  
74    /** The map resolution. */
75    public int mapRes = 400;
76  
77    /** The channel. */
78    public transient int channel = 0; // TODO Remove
79  
80    /** The single image. */
81    transient boolean singleImage = false;
82  
83    /** If use dialog. */
84    transient boolean useDialog = true;
85  
86    /** The Constant Build3D. */
87    final transient boolean Build3D = false;
88  
89    /**
90     * Convexity to pixels.
91     */
92    void convexityToPixels() {
93      avgCov /= scale; // convert to pixels
94      sumCov /= scale;
95    }
96  
97    /**
98     * Convexity to units.
99     */
100   void convexityToUnits() {
101     avgCov *= scale; // convert to pixels
102     sumCov *= scale;
103   }
104 
105   /**
106    * Instantiates a new qp.
107    */
108   public Qp() {
109   }
110 
111   /**
112    * Allow to add file name to options.
113    * 
114    * <p>For convenient creation of {@link Q_Analysis} for API.
115    * 
116    * @param file file to add
117    */
118   public Qp(File file) {
119     paramFile = file.getPath();
120   }
121 
122   /**
123    * Copies selected data from QParams to this object.
124    * 
125    * @param qp General QuimP parameters object
126    */
127   public void setup(QParams qp) {
128     snQPfile = qp.getSnakeQP();
129     scale = qp.getImageScale();
130     frameInterval = qp.getFrameInterval();
131     filename = QuimpToolsCollection.removeExtension(snQPfile.getName());
132     outFile = new File(snQPfile.getParent() + File.separator + filename);
133     startFrame = qp.getStartFrame();
134     endFrame = qp.getEndFrame();
135     // File p = qp.paramFile;
136     fps = 1d / frameInterval;
137     singleImage = false;
138     useDialog = true;
139   }
140 
141   /*
142    * (non-Javadoc)
143    * 
144    * @see java.lang.Object#clone()
145    */
146   @Override
147   public Object clone() throws CloneNotSupportedException {
148     Qpldynamics/quimp/plugin/qanalysis/Qp.html#Qp">Qp cp = new Qp();
149     cp.paramFile = this.paramFile;
150     if (this.snQPfile != null && this.snQPfile.getPath() != null) {
151       cp.snQPfile = new File(this.snQPfile.getPath());
152     }
153     if (this.stQPfile != null && this.stQPfile.getPath() != null) {
154       cp.stQPfile = new File(this.stQPfile.getPath());
155     }
156     if (this.outFile != null && this.outFile.getPath() != null) {
157       cp.outFile = new File(this.outFile.getPath());
158     }
159     cp.filename = this.filename;
160     cp.scale = this.scale;
161     cp.frameInterval = this.frameInterval;
162     cp.startFrame = this.startFrame;
163     cp.endFrame = this.endFrame;
164     cp.fps = this.fps;
165     cp.increment = this.increment;
166     cp.trackColor = this.trackColor;
167     cp.outlinePlot = this.outlinePlot;
168     cp.sumCov = this.sumCov;
169     cp.avgCov = this.avgCov;
170     cp.mapRes = this.mapRes;
171     cp.channel = this.channel;
172     cp.singleImage = this.singleImage;
173     cp.useDialog = this.useDialog;
174 
175     return cp;
176   }
177 
178 }