Changeset 7996
- Timestamp:
- 05/03/12 19:10:47 (8 years ago)
- Location:
- trunk/projects/slim-plugin/src/main/java/loci/slim
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/projects/slim-plugin/src/main/java/loci/slim/SLIMProcessor.java
r7994 r7996 68 68 import loci.slim.process.IProcessor; 69 69 import loci.slim.process.Threshold; 70 import loci.slim.ui.DecayGraph; 70 71 import loci.slim.ui.ExcitationPanel; 72 import loci.slim.ui.IDecayGraph; 71 73 import loci.slim.ui.IUserInterfacePanel; 72 74 import loci.slim.ui.IUserInterfacePanelListener; … … 1081 1083 double yCount[]; 1082 1084 double yFitted[]; 1085 int photons = 0; 1083 1086 1084 1087 // loop over all channels or just the current one … … 1092 1095 1093 1096 // count photons and pixels 1094 int photons = 0;1095 1097 int pixels = 0; 1096 1098 … … 1132 1134 title += " Channel " + (_channel + 1); 1133 1135 } 1134 showDecayGraph(title, uiPanel, _fittingCursor, dataArray[visibleChannel]); 1136 showDecayGraph(title, uiPanel, _fittingCursor, 1137 dataArray[visibleChannel], photons); 1135 1138 uiPanel.setParameters(dataArray[visibleChannel].getParams()); 1136 1139 … … 1156 1159 double yCount[]; 1157 1160 double yFitted[]; 1161 int[] photons = new int[getRois().length]; 1162 for (int i = 0; i < photons.length; ++i) { 1163 photons[i] = 0; 1164 } 1158 1165 1159 1166 // loop over all channels or just the current one … … 1174 1181 ++pixels; 1175 1182 for (int b = 0; b < _bins; ++b) { 1176 yCount[b] += getData(_cursor, channel, x, y, b); 1183 double count = getData(_cursor, channel, x, y, b); 1184 yCount[b] += count; 1185 photons[roiNumber - 1] += count; 1177 1186 } 1178 1187 } … … 1215 1224 title += " Channel " + (_channel + 1); 1216 1225 } 1217 showDecayGraph(title, uiPanel, _fittingCursor, dataArray[dataIndex]); 1226 showDecayGraph(title, uiPanel, _fittingCursor, 1227 dataArray[dataIndex], photons[roiNumber - 1]); 1218 1228 double lifetime = dataArray[dataIndex].getParams()[3]; 1219 1229 if (lifetime < min) { … … 1305 1315 double yCount[]; 1306 1316 double yFitted[]; 1317 int photons = 0; 1307 1318 1308 1319 // loop over all channels or just the current one … … 1313 1324 location[2] = channel; 1314 1325 yCount = processor.getPixel(location); 1315 int photons = 0;1316 1326 for (int c = 0; c < _bins; ++c) { 1317 1327 photons += yCount[c]; … … 1354 1364 visibleChannel = _channel; 1355 1365 } 1356 showDecayGraph(title, uiPanel, _fittingCursor, dataArray[visibleChannel]); 1366 showDecayGraph(title, uiPanel, _fittingCursor, 1367 dataArray[visibleChannel], photons); 1357 1368 1358 1369 // update UI parameters … … 1749 1760 final IUserInterfacePanel uiPanel, 1750 1761 final FittingCursor fittingCursor, 1751 final ICurveFitData data) 1762 final ICurveFitData data, 1763 int photons) 1752 1764 { 1753 loci.slim.ui.IDecayGraph decayGraph = loci.slim.ui.DecayGraph.getInstance();1765 IDecayGraph decayGraph = DecayGraph.getInstance(); 1754 1766 JFrame frame = decayGraph.init(uiPanel.getFrame(), _bins, _timeRange); 1755 1767 decayGraph.setTitle(title); … … 1760 1772 decayGraph.setStartStop(transStart, dataStart, transStop); 1761 1773 decayGraph.setData(data); 1774 decayGraph.setPhotons(photons); 1762 1775 } 1763 1776 -
trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/AbstractBaseFittedImage.java
r7994 r7996 77 77 private HistogramDataGroup _histogramData; 78 78 private IColorizedFittedImage _fittedImage; 79 private Mask _mask; 79 80 80 81 public AbstractBaseFittedImage( … … 108 109 clear(_values); 109 110 HistogramDataNode histogramDataChannel 110 = new HistogramDataNode( _values);111 = new HistogramDataNode(this, _values); 111 112 dataChannelList.add(histogramDataChannel); 112 113 … … 227 228 redisplay(minMaxLUT); 228 229 } 230 231 public void redraw(Mask mask) { 232 if (mask != _mask) { 233 _mask = mask; 234 235 if (_histogramData.getAutoRange()) { 236 double[] minMaxLUT = _histogramData.getMinMaxLUT(); //TODO too much repeated code from "redisplay()" 237 minMaxLUT = PaletteFix.adjustMinMax(minMaxLUT[0], minMaxLUT[1]); 238 if (_colorizeGrayScale) { 239 // redraw all images with new LUT 240 for (IColorizedFittedImage fittedImage : _fittedImages) { 241 fittedImage.setMinAndMax(minMaxLUT[0], minMaxLUT[1]); //TODO we are redrawing all images anyway, then the current one again below... 242 } 243 } 244 else { 245 // when using a FloatProcessor the LUT belongs to entire stack 246 _fittedImage.setMinAndMax(minMaxLUT[0], minMaxLUT[1]); 247 } 248 } 249 250 for (int y = 0; y < _values[0].length; ++y) { 251 for (int x = 0; x < _values.length; ++x) { 252 double value = Double.NaN; 253 if (null == mask || mask.test(x, y)) { 254 value = _values[x][y]; 255 } 256 _fittedImage.draw(x, y, value); 257 } 258 } 259 260 //TODO 261 System.out.println("imagePlus.setProcessor etc."); 262 _imagePlus.setProcessor(_fittedImage.getImageProcessor().duplicate()); 263 } 264 } 229 265 230 266 //TODO MASK -
trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/IFittedImage.java
r7994 r7996 38 38 39 39 import loci.slim.histogram.HistogramDataGroup; 40 import loci.slim.mask.Mask; 40 41 41 42 /** … … 106 107 107 108 /** 108 * Redisplays the image .109 * Redisplays the image after a LUT change. 109 110 */ 110 111 public void redisplay(); 112 113 /** 114 * Redisplays the image after masking. 115 * 116 * @param mask 117 */ 118 public void redraw(Mask mask); 111 119 112 120 /** -
trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramDataNode.java
r7994 r7996 35 35 package loci.slim.histogram; 36 36 37 import loci.slim.fitting.images.IFittedImage; 37 38 import loci.slim.mask.IMaskGroup; 38 39 import loci.slim.mask.IMaskNode; … … 49 50 */ 50 51 public class HistogramDataNode { 52 private IFittedImage _fittedImage; 51 53 private double[][] _values; 52 54 private IMaskNode _maskNode; … … 65 67 * will be incorrect. 66 68 * 69 * @param fittedImage 67 70 * @param values 68 71 */ 69 public HistogramDataNode(double[][] values) { 72 public HistogramDataNode(IFittedImage fittedImage, double[][] values) { 73 _fittedImage = fittedImage; 70 74 _values = values; 71 75 } 72 76 77 /** 78 * Assigns a mask group. 79 * 80 * @param maskGroup 81 */ 73 82 public void setMaskGroup(IMaskGroup maskGroup) { 83 // create a new mask node that listens to the group 74 84 _maskNode = new MaskNode(maskGroup, new IMaskNodeListener () { 75 85 public void updateMask(Mask mask) { 76 86 System.out.println("HistogramDataNode.setMaskGroup IMaskNodeListener.updateMask " + mask); 87 if (null != mask) { 88 boolean[][] bits = mask.getBits(); 89 if (null != bits) { 90 System.out.println("mask excludes " + countBits(bits)); 91 } 92 } 77 93 setOtherMask(mask); 78 94 //TODO redraw, here or in setOtherMask() 95 _fittedImage.redraw(mask); 79 96 } 80 97 }); … … 111 128 _otherMask = mask; 112 129 if (null == _selfMask) { 130 // no self, so total mask is just other 113 131 _totalMask = mask; 114 132 } 115 133 else { 134 // total mask is self plus other 116 135 _totalMask = _selfMask.add(mask); 117 136 } … … 145 164 } 146 165 147 System.out.println("I am " + this + " setSelfMask, total mask excludes " + countBits(_totalMask.getBits())); 166 System.out.print("I am " + this); 167 if (null != _totalMask) System.out.print(" setSelfMask, total mask excludes " + countBits(_totalMask.getBits())); 168 System.out.println(); 148 169 } 149 170 -
trunk/projects/slim-plugin/src/main/java/loci/slim/mask/MaskGroup.java
r7994 r7996 68 68 @Override 69 69 public void updateMask(IMaskNode node, Mask mask) { 70 checkMask("incoming", mask); 70 71 // update map with given mask 71 72 _maskMap.put(node, mask); 72 73 73 // combine mask aand notify other nodes74 for (IMaskNode otherNode : _nodeList) {75 System.out.println("MaskGroup.updateMask, consider " + otherNode);74 // combine masks and notify other nodes 75 for (IMaskNode peerNode : _nodeList) { 76 System.out.println("MaskGroup.updateMask, consider " + peerNode); 76 77 // don't notify the caller 77 if ( otherNode != node) {78 if (peerNode != node) { 78 79 // don't combine the recipients mask 79 Mask combinedMask = Mask.addOtherMasks(mask, _maskMap.values()); 80 Mask peerMask = _maskMap.get(peerNode); 81 Mask combinedMask = Mask.addOtherMasks(peerMask, _maskMap.values()); 82 checkMask("combined", combinedMask); 80 83 System.out.println("MaskGroup.updateMask, notify " + combinedMask); 81 otherNode.updateOtherMask(combinedMask);84 peerNode.updateOtherMask(combinedMask); 82 85 } 86 else System.out.println("MaskGroup.updateMask, originating node " + node + " skipped"); 83 87 } 84 88 85 89 86 90 } 91 92 private void checkMask(String title, Mask mask) { 93 int trues = 0; 94 int falses = 0; 95 if (null == mask) { 96 System.out.println("Mask is null"); 97 return; 98 } 99 boolean[][] bits = mask.getBits(); 100 if (null == bits) { 101 System.out.println("mask has null bits"); 102 return; 103 } 104 for (int y = 0; y < bits[0].length; ++y) { 105 for (int x = 0; x < bits.length; ++x) { 106 if (bits[x][y]) { 107 ++trues; 108 } 109 else { 110 ++falses; 111 } 112 } 113 } 114 System.out.println(title + " mask has " + trues + " trues " + falses + " falses"); 115 } 87 116 } -
trunk/projects/slim-plugin/src/main/java/loci/slim/ui/DecayGraph.java
r7992 r7996 38 38 import java.awt.BasicStroke; 39 39 import java.awt.Color; 40 import java.awt.Container; 40 41 import java.awt.Dimension; 41 42 import java.awt.Graphics2D; 43 import java.awt.event.ItemEvent; 44 import java.awt.event.ItemListener; 42 45 import java.awt.event.MouseEvent; 43 46 import java.awt.geom.Ellipse2D; 44 47 import java.awt.geom.Rectangle2D; 45 48 import java.awt.BorderLayout; 49 import java.awt.FlowLayout; 50 import javax.swing.BoxLayout; 51 52 53 import javax.swing.JCheckBox; 46 54 import javax.swing.JComponent; 47 55 import javax.swing.JFrame; 56 import javax.swing.JLabel; 57 import javax.swing.JPanel; 58 import javax.swing.JTextField; 48 59 import javax.swing.SwingUtilities; 49 60 … … 114 125 XYSeriesCollection _residualDataset; 115 126 116 J FreeChart m_decayChart;117 J FreeChart m_residualsChart;127 JTextField _photonTextField; 128 JCheckBox _logCheckBox; 118 129 119 130 /** … … 179 190 // create a frame for the chart 180 191 _frame = new JFrame(); 181 _frame.getContentPane().add(layer); 192 Container container = _frame.getContentPane(); 193 container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS)); 194 container.add(layer); 195 196 JPanel miscPane = new JPanel(); 197 miscPane.setLayout(new FlowLayout()); 198 JLabel label = new JLabel("Photon count:"); 199 miscPane.add(label); 200 _photonTextField = new JTextField(7); 201 _photonTextField.setEditable(false); 202 miscPane.add(_photonTextField); 203 _logCheckBox = new JCheckBox("Logarithmic"); 204 _logCheckBox.setSelected(_logarithmic); 205 _logCheckBox.addItemListener(new ItemListener() { 206 public void itemStateChanged(ItemEvent e) { 207 _logarithmic = _logCheckBox.isSelected(); 208 NumberAxis photonAxis; 209 if (_logarithmic) { 210 photonAxis = new LogarithmicAxis(PHOTON_AXIS_LABEL); 211 } 212 else { 213 photonAxis = new NumberAxis(PHOTON_AXIS_LABEL); 214 } 215 _decaySubPlot.setRangeAxis(photonAxis); 216 } 217 }); 218 miscPane.add(_logCheckBox); 219 container.add(miscPane); 220 182 221 _frame.setSize(FRAME_SIZE); 183 222 _frame.pack(); … … 223 262 createDatasets(_bins, _timeInc, data); 224 263 264 } 265 266 /** 267 * Sets the displayed photon count. 268 * 269 * @param photons 270 */ 271 public void setPhotons(int photons) { 272 _photonTextField.setText("" + photons); 273 } 274 275 /* 276 * Sets whether vertical axis should be logarithmic. 277 * 278 * @param logarithmic 279 */ 280 public void setLogarithmic(boolean logarithmic) { 281 _logarithmic = logarithmic; 225 282 } 226 283 -
trunk/projects/slim-plugin/src/main/java/loci/slim/ui/IDecayGraph.java
r7930 r7996 75 75 76 76 /** 77 * Sets number of photons in fit. 78 * 79 * @param photons 80 */ 81 public void setPhotons(int photons); 82 83 /** 77 84 * Changes (or initializes) the start and stop vertical bars. 78 85 *
Note: See TracChangeset
for help on using the changeset viewer.