Ignore:
Timestamp:
02/13/12 09:55:09 (8 years ago)
Author:
aivar
Message:

Fixed some channel bugs; started Estimator.

Location:
trunk/projects/slim-plugin/src/main/java/loci/slim
Files:
14 added
5 edited
38 copied

Legend:

Unmodified
Added
Removed
  • trunk/projects/slim-plugin/src/main/java/loci/slim/DecayImageWrapper.java

    r7887 r7889  
    55package loci.slim; 
    66 
    7 import imagej.slim.fitting.IDecayImage; 
     7import loci.slim.fitting.IDecayImage; 
     8import loci.slim.process.IProcessor; 
    89 
    910import mpicbg.imglib.container.planar.PlanarContainerFactory; 
     
    8182    } 
    8283     
     84    /** 
     85     * Specifies a source IProcessor to be chained to this one. 
     86     *  
     87     * @param processor  
     88     */ 
    8389    @Override 
    84     public boolean fitThisPixel(int[] location) { 
    85         return true; //TODO FOR NOW ONLY!! 
     90    public void chain(IProcessor processor) { 
     91        throw new UnsupportedOperationException("Can't chain to DecayImageWrapper"); 
    8692    } 
    8793     
  • trunk/projects/slim-plugin/src/main/java/loci/slim/OutputImageWrapper.java

    r7887 r7889  
    55package loci.slim; 
    66 
    7 import imagej.slim.fitting.IFittedImage; 
     7import loci.slim.fitting.IFittedImage; 
    88 
    99import mpicbg.imglib.container.planar.PlanarContainerFactory; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/SLIMProcessor.java

    r7887 r7889  
    6666import loci.slim.binning.SLIMBinning; 
    6767import loci.slim.colorizer.DataColorizer; 
    68  import loci.slim.colorizer.DataColorizer2; 
    69  
     68import loci.slim.colorizer.DataColorizer2; 
     69import loci.slim.process.IProcessor; 
     70import loci.slim.process.Threshold; 
    7071import loci.slim.ui.ExcitationPanel; 
    7172import loci.slim.ui.IStartStopListener; 
     
    8384 
    8485// Kludge in the new stuff: 
    85 import imagej.slim.fitting.FitInfo; 
    86 import imagej.slim.fitting.IDecayImage; 
    87 import imagej.slim.fitting.IFittedImage; 
    88 import imagej.slim.fitting.images.ColorizedImageParser; 
    89 import imagej.slim.fitting.params.IGlobalFitParams; 
    90 import imagej.slim.fitting.params.LocalFitParams; 
    91 import imagej.slim.fitting.params.GlobalFitParams; 
    92 import imagej.slim.fitting.engine.IFittingEngine; 
    93 import imagej.slim.fitting.params.ILocalFitParams; 
    94 import imagej.slim.fitting.params.IFitResults; 
    95 import imagej.slim.fitting.config.Configuration; 
    96 import imagej.slim.fitting.FitInfo; 
    97 import imagej.slim.fitting.images.ColorizedImageFitter; 
    98 import imagej.slim.fitting.images.ColorizedImageFitter.ColorizedImageType; 
    99 import imagej.slim.histogram.HistogramTool; 
     86import loci.slim.fitting.FitInfo; 
     87import loci.slim.fitting.IDecayImage; 
     88import loci.slim.fitting.IFittedImage; 
     89import loci.slim.fitting.images.ColorizedImageParser; 
     90import loci.slim.fitting.params.IGlobalFitParams; 
     91import loci.slim.fitting.params.LocalFitParams; 
     92import loci.slim.fitting.params.GlobalFitParams; 
     93import loci.slim.fitting.engine.IFittingEngine; 
     94import loci.slim.fitting.params.ILocalFitParams; 
     95import loci.slim.fitting.params.IFitResults; 
     96import loci.slim.fitting.config.Configuration; 
     97import loci.slim.fitting.FitInfo; 
     98import loci.slim.fitting.images.ColorizedImageFitter; 
     99import loci.slim.fitting.images.ColorizedImageFitter.ColorizedImageType; 
     100import loci.slim.heuristics.Estimator; 
     101import loci.slim.heuristics.IEstimator; 
     102import loci.slim.histogram.HistogramTool; 
    100103 
    101104import loci.curvefitter.ICurveFitter.FitAlgorithm; 
     
    142145    private static final Character SUB_3  = '\u2083'; 
    143146 
    144     private static final double[] DEFAULT_SINGLE_EXP_PARAMS  = { 0.0, 0.5, 100.0, 0.5 };                      // 0 C A T 
    145     private static final double[] DEFAULT_DOUBLE_EXP_PARAMS  = { 0.0, 0.5, 50.0, 0.5, 50, 0.25 };             // 0 C A1 T1 A2 T2 
    146     private static final double[] DEFAULT_TRIPLE_EXP_PARAMS  = { 0.0, 0.5, 40.0, 0.5, 30.0, 0.25, 30, 0.10 }; // 0 C A1 T1 A2 T2 A3 T3 
    147     private static final double[] DEFAULT_STRETCH_EXP_PARAMS = { 0.0, 0.5, 100.0, 0.5, 0.5 };                 // 0 C A T H 
    148  
    149147    private Object m_synchFit = new Object(); 
    150148    private volatile boolean m_quit; 
     
    270268     */ 
    271269    private void doFits() { 
     270        // heuristics 
     271        IEstimator estimator = new Estimator(); 
     272         
    272273        // show the UI; do fits 
    273274        final IUserInterfacePanel uiPanel = new UserInterfacePanel(USE_TAU, m_analysis.getChoices(), m_binning.getChoices()); 
    274275        uiPanel.setX(0); 
    275276        uiPanel.setY(0); 
    276         uiPanel.setStart(m_bins / 2, false); //TODO hokey 
    277         uiPanel.setStop(m_bins - 1, false); 
    278         uiPanel.setThreshold(100); 
    279         uiPanel.setChiSquareTarget(1.5); 
    280         uiPanel.setFunctionParameters(0, DEFAULT_SINGLE_EXP_PARAMS); 
    281         uiPanel.setFunctionParameters(1, DEFAULT_DOUBLE_EXP_PARAMS); 
    282         uiPanel.setFunctionParameters(2, DEFAULT_TRIPLE_EXP_PARAMS); 
    283         uiPanel.setFunctionParameters(3, DEFAULT_STRETCH_EXP_PARAMS); 
     277        uiPanel.setStart(estimator.getStart(m_bins), false); 
     278        uiPanel.setStop(estimator.getStop(m_bins), false); 
     279        uiPanel.setThreshold(estimator.getThreshold()); 
     280        uiPanel.setChiSquareTarget(estimator.getChiSquareTarget()); 
     281        uiPanel.setFunctionParameters(0, estimator.getParameters(1, false)); 
     282        uiPanel.setFunctionParameters(1, estimator.getParameters(2, false)); 
     283        uiPanel.setFunctionParameters(2, estimator.getParameters(3, false)); 
     284        uiPanel.setFunctionParameters(3, estimator.getParameters(0, true)); 
    284285        uiPanel.setListener( 
    285286            new IUserInterfacePanelListener() { 
     
    682683                case EACH: 
    683684                    // fit every pixel 
    684                     fittedImage = fitImage(uiPanel); ///TODO WAS OLD VERSION: fitAllPixels(uiPanel); 
     685                    fittedImage = fitImage(uiPanel); 
    685686                    break; 
    686687            } 
    687688        } 
    688         System.out.println("fitted iage is " + fittedImage); 
    689689        if (null != fittedImage) { 
    690             System.out.println("not null"); 
    691690            for (String analysis : uiPanel.getAnalysisList()) { 
    692                 System.out.println("analsysis " + analysis); 
    693691                m_analysis.doAnalysis(analysis, fittedImage, uiPanel.getRegion(), uiPanel.getFunction()); //TODO get from uiPanel or get from global?  re-evaluate approach here 
    694692            } 
     
    715713        fitInfo.setParameterCount(uiPanel.getParameterCount()); 
    716714        fitInfo.setParameters(uiPanel.getParameters()); 
    717         fitInfo.setFree(uiPanel.getFree()); 
     715        fitInfo.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree()));; 
    718716        fitInfo.setRefineFit(uiPanel.getRefineFit()); 
    719717        return fitInfo; 
     
    751749        IFittedImage newImage = new OutputImageWrapper(width, height, channels, parameters); 
    752750         
     751        // set up preprocessor chain 
     752        IProcessor processor = decayImage; 
     753        if (fitInfo.getThreshold() > 0) { 
     754            IProcessor threshold = new Threshold(fitInfo.getStartDecay(), fitInfo.getStopDecay(), fitInfo.getThreshold()); 
     755            threshold.chain(processor); 
     756            processor = threshold; 
     757        } 
     758         
    753759        // create a fitting engine to use 
    754760        IFittingEngine fittingEngine = Configuration.getInstance().getFittingEngine(); 
     
    756762        fittingEngine.setCurveFitter(curveFitter); 
    757763         
    758         return fitImage(fittingEngine, fitInfo, decayImage, previousImage, newImage); 
     764        return fitImage(fittingEngine, fitInfo, decayImage, processor, previousImage, newImage); 
    759765 
    760766    } 
     
    774780            FitInfo fitInfo, 
    775781            IDecayImage decayImage, 
     782            IProcessor processor, //TODO ARG really need both decayImage & processor?  Processor is a poor name 
    776783            IFittedImage previousImage, 
    777784            IFittedImage newImage) { 
     
    801808            int components = fitInfo.getComponents(); 
    802809            boolean stretched = fitInfo.getStretched(); 
    803             ColorizedImageParser parser = new ColorizedImageParser(outputs, components, stretched); 
     810            ColorizedImageParser parser = 
     811                    new ColorizedImageParser(outputs, components, stretched, 
     812                            fitInfo.getFree()); 
    804813            ColorizedImageType[] outputImages = parser.getColorizedImages(); 
    805814            imageColorizer = new ColorizedImageFitter(); 
     
    822831        globalFitParams.setStopPrompt(fitInfo.getStopPrompt()); 
    823832        globalFitParams.setChiSquareTarget(fitInfo.getChiSquareTarget()); 
    824         globalFitParams.setFree(fitInfo.getFree()); //TODO translateFree(uiPanel.getFunction(), uiPanel.getFree()));; 
     833        globalFitParams.setFree(fitInfo.getFree()); 
    825834      
    826835        // initialize class used for 'chunky pixel' effect 
     
    846855                int[] outputLocation = new int[] { x, y, fitAllChannels ? c : 0 }; 
    847856 
    848                 double[] decay = decayImage.getPixel(inputLocation); 
     857                double[] decay = processor.getPixel(inputLocation); 
     858                 
    849859                // fit this pixel? 
    850860                if (null != decay) { 
     
    888898        else { 
    889899            if (pixelsToProcessCount > 0) { 
    890                 System.out.println("finishing up " + pixelsToProcessCount + " pixels"); 
    891900                ChunkyPixel[] pixelArray = pixelList.toArray(new ChunkyPixel[0]); 
    892901                ILocalFitParams[] localFitParamsArray = localFitParamsList.toArray(new ILocalFitParams[0]); 
     
    932941        for (int i = 0; i < resultsList.size(); ++i) { 
    933942            IFitResults result = resultsList.get(i); 
     943            double[] results = result.getParams(); 
    934944            ChunkyPixel p = pixels[i]; 
    935945            int[] location = p.getOutputLocation(); 
    936             double[] results = result.getParams(); 
     946          
    937947            // if producing colorized images, feed this pixel to colorizer 
    938948            if (null != imageColorizer) { 
     
    12361246        } 
    12371247    } 
    1238      
    1239     //TODO This fitImages is the new version and "fitEachPixelXYZ" is the old: 
    1240     //TODO need to fit all channels 
    1241     //TODO need to be a selfcontained function call 
    1242     //  = gives you fitted images and a histogram tool 
    1243  
    1244     private Image<DoubleType> fitImagesDEFUNCT(IUserInterfacePanel uiPanel) { 
    1245          
    1246          
    1247          
    1248         // loop over all channels 
    1249         int startChannel; 
    1250         int stopChannel; 
    1251         if (m_fitAllChannels) { 
    1252             startChannel = 0; 
    1253             stopChannel = m_channels; 
    1254         } 
    1255         else { 
    1256             startChannel = m_channel; 
    1257             stopChannel = m_channel + 1; 
    1258         } 
    1259         for (int channel = startChannel; channel < stopChannel; ++channel) { 
    1260              
    1261         } 
    1262          
    1263         long start = System.nanoTime(); 
    1264         int pixelCount = 0; 
    1265         int totalPixelCount = totalPixelCount(m_width, m_height, m_channels, m_fitAllChannels); 
    1266         int pixelsToProcessCount = 0; 
    1267  
    1268         Image<T> workImage = m_image; 
    1269         if (!SLIMBinning.NONE.equals(uiPanel.getBinning())) { 
    1270             workImage = m_binning.doBinning(uiPanel.getBinning(), m_image); 
    1271         } 
    1272         LocalizableByDimCursor<T> pixelCursor = workImage.createLocalizableByDimCursor(); 
    1273  
    1274         ICurveFitter curveFitterX = getCurveFitter(uiPanel); //TODO where is this used? 
    1275         double params[] = uiPanel.getParameters(); 
    1276  
    1277         boolean useFittedParams; 
    1278         LocalizableByDimCursor<DoubleType> resultsCursor = null; 
    1279         if (null == m_fittedImage || uiPanel.getParameterCount() != m_fittedParameterCount) { 
    1280             // can't use previous results 
    1281             useFittedParams = false; 
    1282             m_fittedParameterCount = uiPanel.getParameterCount(); 
    1283             m_fittedImage = makeImage(m_channels, m_width, m_height, m_fittedParameterCount); 
    1284         } 
    1285         else { 
    1286             // ask UI whether to use previous results 
    1287             useFittedParams = uiPanel.getRefineFit(); 
    1288         } 
    1289         resultsCursor = m_fittedImage.createLocalizableByDimCursor(); 
    1290          
    1291         // build the data 
    1292         ArrayList<ICurveFitData> curveFitDataList = new ArrayList<ICurveFitData>(); 
    1293         ArrayList<ChunkyPixel> pixelList = new ArrayList<ChunkyPixel>(); 
    1294         ICurveFitData curveFitData; 
    1295         double yCount[]; 
    1296         double yFitted[]; 
    1297  
    1298         ChunkyPixelEffectIterator pixelIterator = new ChunkyPixelEffectIterator(new ChunkyPixelTableImpl(), m_width, m_height); 
    1299          
    1300         //TODO new style code starts only here: 
    1301         ColorizedImageFitter imageFitter = new ColorizedImageFitter(); 
    1302         int components = 0; 
    1303         boolean stretched = false; 
    1304         switch (uiPanel.getFunction()) { 
    1305             case SINGLE_EXPONENTIAL: 
    1306                 components = 1; 
    1307                 break; 
    1308             case DOUBLE_EXPONENTIAL: 
    1309                 components = 2; 
    1310                 break; 
    1311             case TRIPLE_EXPONENTIAL: 
    1312                 components = 3; 
    1313                 break; 
    1314             case STRETCHED_EXPONENTIAL: 
    1315                 stretched = true; 
    1316                 break; 
    1317         } 
    1318         String outputs = uiPanel.getFittedImages(); 
    1319         ColorizedImageParser parser = new ColorizedImageParser(outputs, components, stretched); 
    1320          
    1321         ColorizedImageType[] outputImages = parser.getColorizedImages(); 
    1322         imageFitter.setUpFit(outputImages, new int[] { m_width, m_height }, null, components); 
    1323         imageFitter.beginFit(); 
    1324          
    1325         IGlobalFitParams globalFitParams = new GlobalFitParams(); 
    1326         globalFitParams.setFitAlgorithm(FitAlgorithm.SLIMCURVE_RLD_LMA); ///uiPanel.getAlgorithm()); //loci.curvefitter.ICurveFitter.FitAlgorithm.RLD_LMA); 
    1327         globalFitParams.setFitFunction(FitFunction.SINGLE_EXPONENTIAL); //uiPanel.getFunction()); 
    1328         globalFitParams.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
    1329         globalFitParams.setNoiseModel(NoiseModel.MAXIMUM_LIKELIHOOD); //uiPanel.getNoiseModel()); 
    1330         globalFitParams.setChiSquareTarget(uiPanel.getChiSquareTarget()); 
    1331         ///globalFitParams.setFitFunction(loci.curvefitter.ICurveFitter.FitFunction.SINGLE_EXPONENTIAL); 
    1332         ///globalFitParams.setNoiseModel(loci.curvefitter.ICurveFitter.NoiseModel.MAXIMUM_LIKELIHOOD); 
    1333         globalFitParams.setXInc(m_timeRange); 
    1334         globalFitParams.setPrompt(null); 
    1335         if (null != m_excitationPanel) { 
    1336             globalFitParams.setPrompt(m_excitationPanel.getValues(1)); 
    1337         } 
    1338         ////globalFitParams.setChiSquareTarget(data[0].getChiSquareTarget()); 
    1339  
    1340  
    1341         boolean[] free = { true, true, true }; 
    1342         globalFitParams.setFree(free); //TODO BAD! s/n/b hardcoded here 
    1343       //TODO KLUDGE  globalFitParams.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
    1344          
    1345          
    1346          
    1347  
    1348         while (!m_cancel && pixelIterator.hasNext()) { 
    1349             IJ.showProgress(++pixelCount, totalPixelCount); 
    1350             ChunkyPixel pixel = pixelIterator.next(); 
    1351             if (wantFitted(m_channel, pixel.getX(), pixel.getY())) { 
    1352                 curveFitData = new CurveFitData(); 
    1353                 curveFitData.setChannel(m_channel); 
    1354                 curveFitData.setX(pixel.getX()); 
    1355                 curveFitData.setY(pixel.getY()); 
    1356                 curveFitData.setParams( 
    1357                     useFittedParams ? 
    1358                         getFittedParams(resultsCursor, m_channel, pixel.getX(), pixel.getY(), m_fittedParameterCount) : 
    1359                             params.clone()); 
    1360                 yCount = new double[m_bins]; 
    1361                 for (int b = 0; b < m_bins; ++b) { 
    1362                     yCount[b] = getData(pixelCursor, m_channel, pixel.getX(), pixel.getY(), b); //binnedData[m_channel][pixel.getY()][pixel.getX()][b]; 
    1363                 } 
    1364                 curveFitData.setYCount(yCount); 
    1365                 yFitted = new double[m_bins]; 
    1366                 curveFitData.setYFitted(yFitted); 
    1367                 curveFitDataList.add(curveFitData); 
    1368                 pixelList.add(pixel); 
    1369  
    1370                 // process the pixels 
    1371                 if (++pixelsToProcessCount >= PIXEL_COUNT) { 
    1372                     ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1373                     ChunkyPixel[] pixels = pixelList.toArray(new ChunkyPixel[0]); 
    1374                     processPixelsXYZ(data, pixels, imageFitter); 
    1375                     curveFitDataList.clear(); 
    1376                     pixelList.clear(); 
    1377                     pixelsToProcessCount = 0; 
    1378                 } 
    1379             } 
    1380         } 
    1381          
    1382         if (m_cancel) { 
    1383             IJ.showProgress(0, 0); 
    1384             cancelImageFit(); 
    1385             imageFitter.cancelFit(); 
    1386             return null; 
    1387         } 
    1388         else { 
    1389             if (pixelsToProcessCount > 0) { 
    1390                 ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1391                 ChunkyPixel[] pixels = pixelList.toArray(new ChunkyPixel[0]); 
    1392                 processPixelsXYZ(data, pixels, imageFitter); 
    1393             } 
    1394             imageFitter.endFit(); 
    1395         } 
    1396  
    1397          
    1398         //TODO so the results are not getting saved to an Imglib Image 
    1399         //TODO this technique of building an array of ICurveFitData, then breaking that down into 
    1400         // IGlobalFitParams and ILocalFitParams seems over-complicated 
    1401          
    1402         return null; 
    1403     } 
    1404      
    1405      
    1406     /* 
    1407      * Helper function that processes an array of pixels.  Histogram and images 
    1408      * are updated at the end of this function. 
    1409      */ 
    1410     private void processPixelsDEFUNCT(ICurveFitData[] data, ChunkyPixel[] pixels, ColorizedImageFitter imageFitter) { 
    1411         if (null == _fittingEngine) { 
    1412             _fittingEngine = Configuration.getInstance().getFittingEngine(); 
    1413             _fittingEngine.setThreads(Configuration.getInstance().getThreads()); 
    1414             _fittingEngine.setCurveFitter(Configuration.getInstance().getCurveFitter()); 
    1415         } 
    1416  
    1417         IGlobalFitParams globalFitParams = new GlobalFitParams(); 
    1418         globalFitParams.setFitAlgorithm(FitAlgorithm.SLIMCURVE_RLD_LMA); 
    1419         globalFitParams.setFitFunction(FitFunction.SINGLE_EXPONENTIAL); 
    1420         globalFitParams.setNoiseModel(NoiseModel.MAXIMUM_LIKELIHOOD); 
    1421         globalFitParams.setXInc(m_timeRange); 
    1422         globalFitParams.setPrompt(null); 
    1423         if (null != m_excitationPanel) { 
    1424             globalFitParams.setPrompt(m_excitationPanel.getValues(1)); 
    1425         } 
    1426         globalFitParams.setChiSquareTarget(data[0].getChiSquareTarget()); 
    1427  
    1428  
    1429         boolean[] free = { true, true, true }; 
    1430         globalFitParams.setFree(free); //TODO BAD! s/n/b hardcoded here 
    1431       //TODO KLUDGE  globalFitParams.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
    1432  
    1433         List<ILocalFitParams> dataList = new ArrayList<ILocalFitParams>(); 
    1434  
    1435         for (ICurveFitData datum : data) { 
    1436             ILocalFitParams localFitParams = new LocalFitParams(); 
    1437             localFitParams.setY(datum.getYCount()); 
    1438             localFitParams.setSig(datum.getSig()); 
    1439             localFitParams.setParams(datum.getParams()); 
    1440             localFitParams.setFitStart(m_startBin); 
    1441             localFitParams.setFitStop(m_stopBin); 
    1442             localFitParams.setYFitted(datum.getYFitted()); 
    1443             dataList.add(localFitParams); 
    1444         } 
    1445  
    1446         List<IFitResults> results = _fittingEngine.fit(globalFitParams, dataList); 
    1447  
    1448         for (int i = 0; i < results.size(); ++i) { 
    1449             IFitResults result = results.get(i); 
    1450             ChunkyPixel p = pixels[i]; 
    1451             int[] location = { p.getX(), p.getY() }; 
    1452             imageFitter.updatePixel(location, result.getParams()); 
    1453         } 
    1454  
    1455         imageFitter.recalcHistogram(); 
    1456     } 
    1457      
    1458     //TODO This XYZ is the new version and "fitEachPixelX" is the old: 
    1459     //TODO need to fit all channels 
    1460     //TODO need to be a selfcontained function call 
    1461     //  = gives you fitted images and a histogram tool 
    1462      
    1463     private Image<DoubleType> fitEachPixelLatestDEFUNCT(IUserInterfacePanel uiPanel) { 
    1464          
    1465         // we need to generate the following for fitEachPixel nowadays: 
    1466          
    1467         // note that every fit type needs these, not just images 
    1468          
    1469         IFittingEngine fittingEngine = Configuration.getInstance().getFittingEngine(); // still have a _fittingEngine global also 
    1470             fittingEngine.setThreads(Configuration.getInstance().getThreads()); 
    1471             fittingEngine.setCurveFitter(Configuration.getInstance().getCurveFitter()); 
    1472         ChunkyPixel[] pixels;  
    1473         IGlobalFitParams globalFitParams; 
    1474         List<ILocalFitParams> localFitParams = new ArrayList<ILocalFitParams>(); 
    1475         ColorizedImageFitter imageFitter; //it's confusing to have both an imageFitter and a fittingEngine 
    1476        
    1477         return null; 
    1478     } 
    1479  
    1480     private Image<DoubleType> fitAllPixelsDEFUNCT(IUserInterfacePanel uiPanel) { 
    1481         long start = System.nanoTime(); 
    1482         int pixelCount = 0; 
    1483         int totalPixelCount = totalPixelCount(m_width, m_height, m_channels, m_fitAllChannels); 
    1484         int pixelsToProcessCount = 0; 
    1485  
    1486         Image<T> workImage = m_image; 
    1487         if (!SLIMBinning.NONE.equals(uiPanel.getBinning())) { 
    1488             workImage = m_binning.doBinning(uiPanel.getBinning(),  m_image); 
    1489         } 
    1490         LocalizableByDimCursor<T> pixelCursor = workImage.createLocalizableByDimCursor(); 
    1491  
    1492         ICurveFitter curveFitter = getCurveFitter(uiPanel); //TODO where is this used? 
    1493         double params[] = uiPanel.getParameters(); 
    1494  
    1495         boolean useFittedParams; 
    1496         LocalizableByDimCursor<DoubleType> resultsCursor = null; 
    1497         if (null == m_fittedImage || uiPanel.getParameterCount() != m_fittedParameterCount) { 
    1498             // can't use previous results 
    1499             useFittedParams = false; 
    1500             m_fittedParameterCount = uiPanel.getParameterCount(); 
    1501             m_fittedImage = makeImage(m_channels, m_width, m_height, m_fittedParameterCount); 
    1502         } 
    1503         else { 
    1504             // ask UI whether to use previous results 
    1505             useFittedParams = uiPanel.getRefineFit(); 
    1506         } 
    1507         resultsCursor = m_fittedImage.createLocalizableByDimCursor(); 
    1508          
    1509         // build the data 
    1510         ArrayList<ICurveFitData> curveFitDataList = new ArrayList<ICurveFitData>(); 
    1511         ArrayList<ChunkyPixel> pixelList = new ArrayList<ChunkyPixel>(); 
    1512         ICurveFitData curveFitData; 
    1513         double yCount[]; 
    1514         double yFitted[]; 
    1515  
    1516         ChunkyPixelEffectIterator pixelIterator = new ChunkyPixelEffectIterator(new ChunkyPixelTableImpl(), m_width, m_height); 
    1517          
    1518         //TODO new style code starts only here: 
    1519         ColorizedImageFitter imageFitter = new ColorizedImageFitter(); 
    1520         int components = 0; 
    1521         boolean stretched = false; 
    1522         switch (uiPanel.getFunction()) { 
    1523             case SINGLE_EXPONENTIAL: 
    1524                 components = 1; 
    1525                 break; 
    1526             case DOUBLE_EXPONENTIAL: 
    1527                 components = 2; 
    1528                 break; 
    1529             case TRIPLE_EXPONENTIAL: 
    1530                 components = 3; 
    1531                 break; 
    1532             case STRETCHED_EXPONENTIAL: 
    1533                 stretched = true; 
    1534                 break; 
    1535         } 
    1536         String outputs = uiPanel.getFittedImages(); 
    1537         ColorizedImageParser parser = new ColorizedImageParser(outputs, components, stretched); 
    1538          
    1539         ColorizedImageType[] colorizedImages = parser.getColorizedImages(); 
    1540         imageFitter.setUpFit(colorizedImages, new int[] { m_width, m_height }, null, components); 
    1541         imageFitter.beginFit();        
    1542  
    1543         while (!m_cancel && pixelIterator.hasNext()) { 
    1544             IJ.showProgress(++pixelCount, totalPixelCount); 
    1545             ChunkyPixel pixel = pixelIterator.next(); 
    1546             if (wantFitted(m_channel, pixel.getX(), pixel.getY())) { 
    1547                 curveFitData = new CurveFitData(); 
    1548                 curveFitData.setChannel(m_channel); 
    1549                 curveFitData.setX(pixel.getX()); 
    1550                 curveFitData.setY(pixel.getY()); 
    1551                 curveFitData.setParams( 
    1552                     useFittedParams ? 
    1553                         getFittedParams(resultsCursor, m_channel, pixel.getX(), pixel.getY(), m_fittedParameterCount) : 
    1554                             params.clone()); 
    1555                 yCount = new double[m_bins]; 
    1556                 for (int b = 0; b < m_bins; ++b) { 
    1557                     yCount[b] = getData(pixelCursor, m_channel, pixel.getX(), pixel.getY(), b); //binnedData[m_channel][pixel.getY()][pixel.getX()][b]; 
    1558                 } 
    1559                 curveFitData.setYCount(yCount); 
    1560                 yFitted = new double[m_bins]; 
    1561                 curveFitData.setYFitted(yFitted); 
    1562                 curveFitDataList.add(curveFitData); 
    1563                 pixelList.add(pixel); 
    1564  
    1565                 // process the pixels 
    1566                 if (++pixelsToProcessCount >= PIXEL_COUNT) { 
    1567                     ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1568                     ChunkyPixel[] pixels = pixelList.toArray(new ChunkyPixel[0]); 
    1569                     processPixelsXYZ(data, pixels, imageFitter); 
    1570                     curveFitDataList.clear(); 
    1571                     pixelList.clear(); 
    1572                     pixelsToProcessCount = 0; 
    1573                 } 
    1574             } 
    1575         } 
    1576          
    1577         if (m_cancel) { 
    1578             IJ.showProgress(0, 0); 
    1579             cancelImageFit(); 
    1580             imageFitter.cancelFit(); 
    1581             return null; 
    1582         } 
    1583         else { 
    1584             if (pixelsToProcessCount > 0) { 
    1585                 ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1586                 ChunkyPixel[] pixels = pixelList.toArray(new ChunkyPixel[0]); 
    1587                 processPixelsXYZ(data, pixels, imageFitter); 
    1588             } 
    1589             imageFitter.endFit(); 
    1590         } 
    1591  
    1592          
    1593         //TODO so the results are not getting saved to an Imglib Image 
    1594         //TODO this technique of building an array of ICurveFitData, then breaking that down into 
    1595         // IGlobalFitParams and ILocalFitParams seems over-complicated 
    1596          
    1597         return null; 
    1598     } 
    1599     /* 
    1600      * Helper function that processes an array of pixels.  Histogram and images 
    1601      * are updated at the end of this function. 
    1602      */ 
    1603      
    1604      
    1605  
    1606    
    1607     // copied 1/12 to modify into "processPixels" above: 
    1608     private void processPixelsXYZhuhuhDEFUNCT(ICurveFitData[] data, ChunkyPixel[] pixels, ColorizedImageFitter imageFitter) { 
    1609         if (null == _fittingEngine) { 
    1610             _fittingEngine = Configuration.getInstance().getFittingEngine(); 
    1611             _fittingEngine.setThreads(Configuration.getInstance().getThreads()); 
    1612             _fittingEngine.setCurveFitter(Configuration.getInstance().getCurveFitter()); 
    1613         } 
    1614  
    1615         IGlobalFitParams globalFitParams = new GlobalFitParams(); 
    1616         globalFitParams.setFitAlgorithm(FitAlgorithm.SLIMCURVE_RLD_LMA); 
    1617         globalFitParams.setFitFunction(FitFunction.SINGLE_EXPONENTIAL); 
    1618         globalFitParams.setNoiseModel(NoiseModel.MAXIMUM_LIKELIHOOD); 
    1619         globalFitParams.setXInc(m_timeRange); 
    1620         globalFitParams.setPrompt(null); 
    1621         if (null != m_excitationPanel) { 
    1622             globalFitParams.setPrompt(m_excitationPanel.getValues(1)); 
    1623         } 
    1624         globalFitParams.setChiSquareTarget(data[0].getChiSquareTarget()); 
    1625  
    1626  
    1627         boolean[] free = { true, true, true }; 
    1628         globalFitParams.setFree(free); //TODO BAD! s/n/b hardcoded here 
    1629       //TODO KLUDGE  globalFitParams.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
    1630  
    1631         List<ILocalFitParams> dataList = new ArrayList<ILocalFitParams>(); 
    1632  
    1633         for (ICurveFitData datum : data) { 
    1634             ILocalFitParams localFitParams = new LocalFitParams(); 
    1635             localFitParams.setY(datum.getYCount()); 
    1636             localFitParams.setSig(datum.getSig()); 
    1637             localFitParams.setParams(datum.getParams()); 
    1638             localFitParams.setFitStart(m_startBin); 
    1639             localFitParams.setFitStop(m_stopBin); 
    1640             localFitParams.setYFitted(datum.getYFitted()); 
    1641             dataList.add(localFitParams); 
    1642         } 
    1643  
    1644         List<IFitResults> results = _fittingEngine.fit(globalFitParams, dataList); 
    1645  
    1646         for (int i = 0; i < results.size(); ++i) { 
    1647             IFitResults result = results.get(i); 
    1648             ChunkyPixel p = pixels[i]; 
    1649             int[] location = { p.getX(), p.getY() }; 
    1650             imageFitter.updatePixel(location, result.getParams()); 
    1651         } 
    1652  
    1653         imageFitter.recalcHistogram(); 
    1654     } 
    1655   
    1656     /* 
    1657      * Helper function that processes an array of pixels.  Histogram and images 
    1658      * are updated at the end of this function. 
    1659      */ 
    1660     // THis is only called from defunct image fitters. 
    1661     private void processPixelsXYZ(ICurveFitData[] data, ChunkyPixel[] pixels, ColorizedImageFitter imageFitter) { 
    1662         if (null == _fittingEngine) { 
    1663             _fittingEngine = Configuration.getInstance().getFittingEngine(); 
    1664             _fittingEngine.setThreads(Configuration.getInstance().getThreads()); 
    1665             _fittingEngine.setCurveFitter(Configuration.getInstance().getCurveFitter()); 
    1666         } 
    1667  
    1668         IGlobalFitParams globalFitParams = new GlobalFitParams(); 
    1669         globalFitParams.setFitAlgorithm(FitAlgorithm.SLIMCURVE_RLD_LMA); 
    1670         globalFitParams.setFitFunction(FitFunction.SINGLE_EXPONENTIAL); 
    1671         globalFitParams.setNoiseModel(NoiseModel.MAXIMUM_LIKELIHOOD); 
    1672         globalFitParams.setXInc(m_timeRange); 
    1673         globalFitParams.setPrompt(null); 
    1674         if (null != m_excitationPanel) { 
    1675             globalFitParams.setPrompt(m_excitationPanel.getValues(1)); 
    1676         } 
    1677         globalFitParams.setChiSquareTarget(data[0].getChiSquareTarget()); 
    1678  
    1679  
    1680         boolean[] free = { true, true, true }; 
    1681         globalFitParams.setFree(free); //TODO BAD! s/n/b hardcoded here 
    1682       //TODO KLUDGE  globalFitParams.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
    1683  
    1684         List<ILocalFitParams> dataList = new ArrayList<ILocalFitParams>(); 
    1685  
    1686         for (ICurveFitData datum : data) { 
    1687             ILocalFitParams localFitParams = new LocalFitParams(); 
    1688             localFitParams.setY(datum.getYCount()); 
    1689             localFitParams.setSig(datum.getSig()); 
    1690             localFitParams.setParams(datum.getParams()); 
    1691             localFitParams.setFitStart(m_startBin); 
    1692             localFitParams.setFitStop(m_stopBin); 
    1693             localFitParams.setYFitted(datum.getYFitted()); 
    1694             dataList.add(localFitParams); 
    1695         } 
    1696  
    1697         List<IFitResults> results = _fittingEngine.fit(globalFitParams, dataList); 
    1698  
    1699         for (int i = 0; i < results.size(); ++i) { 
    1700             IFitResults result = results.get(i); 
    1701             ChunkyPixel p = pixels[i]; 
    1702             int[] location = { p.getX(), p.getY() }; 
    1703             imageFitter.updatePixel(location, result.getParams()); 
    1704         } 
    1705  
    1706         imageFitter.recalcHistogram(); 
    1707     } 
    1708   
    1709     /* 
    1710      * Fits each and every pixel.  This is the most complicated fit. 
    1711      * 
    1712      * If a channel is visible it is fit first and drawn incrementally. 
    1713      * 
    1714      * Results of the fit go to VisAD for analysis. 
    1715      */ 
    1716     //TODO this is the old version 
    1717     private Image<DoubleType> fitEachPixelXDEFUNCT(IUserInterfacePanel uiPanel) { 
    1718         long start = System.nanoTime(); 
    1719         int pixelCount = 0; 
    1720         int totalPixelCount = totalPixelCount(m_width, m_height, m_channels, m_fitAllChannels); 
    1721         int pixelsToProcessCount = 0; 
    1722  
    1723         Image<T> workImage = m_image; 
    1724         if (!SLIMBinning.NONE.equals(uiPanel.getBinning())) { 
    1725             workImage = m_binning.doBinning(uiPanel.getBinning(),  m_image); 
    1726         } 
    1727         LocalizableByDimCursor<T> pixelCursor = workImage.createLocalizableByDimCursor(); 
    1728  
    1729         ICurveFitter curveFitter = getCurveFitter(uiPanel);      
    1730         double params[] = uiPanel.getParameters(); 
    1731  
    1732         boolean useFittedParams; 
    1733         LocalizableByDimCursor<DoubleType> resultsCursor = null; 
    1734         if (null == m_fittedImage || uiPanel.getParameterCount() != m_fittedParameterCount) { 
    1735             // can't use previous results 
    1736             useFittedParams = false; 
    1737             m_fittedParameterCount = uiPanel.getParameterCount(); 
    1738             m_fittedImage = makeImage(m_channels, m_width, m_height, m_fittedParameterCount); 
    1739         } 
    1740         else { 
    1741             // ask UI whether to use previous results 
    1742             useFittedParams = uiPanel.getRefineFit(); 
    1743         } 
    1744         resultsCursor = m_fittedImage.createLocalizableByDimCursor(); 
    1745          
    1746         // build the data 
    1747         ArrayList<ICurveFitData> curveFitDataList = new ArrayList<ICurveFitData>(); 
    1748         ArrayList<ChunkyPixel> pixelList = new ArrayList<ChunkyPixel>(); 
    1749         ICurveFitData curveFitData; 
    1750         double yCount[]; 
    1751         double yFitted[]; 
    1752  
    1753         // special handling for visible channel 
    1754         if (m_visibleFit) { 
    1755             // show colorized image 
    1756             DataColorizer2 dataColorizer = new DataColorizer2(m_width, m_height, m_algorithm + " Fitted Lifetimes"); 
    1757  
    1758             ChunkyPixelEffectIterator pixelIterator = new ChunkyPixelEffectIterator(new ChunkyPixelTableImpl(), m_width, m_height); 
    1759  
    1760             while (!m_cancel && pixelIterator.hasNext()) { 
    1761                 if (m_cancel) { 
    1762                     IJ.showProgress(0, 0); //TODO kludgy to have this here and also below; get rid of this but make the dataColorizer go away regardless 
    1763                     dataColorizer.quit(); 
    1764                     cancelImageFit(); 
    1765                     return null; 
    1766                 } 
    1767                 IJ.showProgress(++pixelCount, totalPixelCount); 
    1768                 ChunkyPixel pixel = pixelIterator.next(); 
    1769                 if (wantFitted(m_channel, pixel.getX(), pixel.getY())) { 
    1770                     curveFitData = new CurveFitData(); 
    1771                     curveFitData.setChannel(m_channel); 
    1772                     curveFitData.setX(pixel.getX()); 
    1773                     curveFitData.setY(pixel.getY()); 
    1774                     curveFitData.setParams( 
    1775                             useFittedParams ? 
    1776                                 getFittedParams(resultsCursor, m_channel, pixel.getX(), pixel.getY(), m_fittedParameterCount) : 
    1777                                 params.clone()); 
    1778                     yCount = new double[m_bins]; 
    1779                     for (int b = 0; b < m_bins; ++b) { 
    1780                         yCount[b] = getData(pixelCursor, m_channel, pixel.getX(), pixel.getY(), b); //binnedData[m_channel][pixel.getY()][pixel.getX()][b]; 
    1781                     } 
    1782                     curveFitData.setYCount(yCount); 
    1783                     yFitted = new double[m_bins]; 
    1784                     curveFitData.setYFitted(yFitted); 
    1785                     curveFitDataList.add(curveFitData); 
    1786                     pixelList.add(pixel); 
    1787  
    1788                     // process the pixels 
    1789                     if (++pixelsToProcessCount >= PIXEL_COUNT) { 
    1790                         if (OLD_STYLE) { 
    1791                             pixelsToProcessCount = 0; 
    1792                             ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1793                             curveFitDataList.clear(); 
    1794                             curveFitter.fitData(data, m_startBin, m_stopBin); 
    1795                             setFittedParamsFromData(resultsCursor, data); 
    1796                             colorizePixels(dataColorizer, m_channel, data, pixelList.toArray(new ChunkyPixel[0])); 
    1797                             pixelList.clear(); 
    1798                         } 
    1799                         else { 
    1800                             pixelsToProcessCount = 0; 
    1801                             ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1802                             curveFitDataList.clear(); 
    1803                              
    1804                             if (null == _fittingEngine) { 
    1805                                 _fittingEngine = Configuration.getInstance().getFittingEngine(); 
    1806                                 _fittingEngine.setThreads(Configuration.getInstance().getThreads()); 
    1807                                 _fittingEngine.setCurveFitter(Configuration.getInstance().getCurveFitter()); 
    1808                             } 
    1809                                                          
    1810                              
    1811                             IGlobalFitParams globalFitParams = new GlobalFitParams(); 
    1812                             globalFitParams.setFitAlgorithm(FitAlgorithm.SLIMCURVE_RLD_LMA); 
    1813                             globalFitParams.setFitFunction(FitFunction.SINGLE_EXPONENTIAL); 
    1814                             globalFitParams.setXInc(m_timeRange); 
    1815                             globalFitParams.setPrompt(null); 
    1816                             if (null != m_excitationPanel) { 
    1817                                 globalFitParams.setPrompt(m_excitationPanel.getValues(1)); 
    1818                             } 
    1819                             globalFitParams.setChiSquareTarget(data[0].getChiSquareTarget()); 
    1820                             globalFitParams.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
    1821                              
    1822                             java.util.List<ILocalFitParams> dataList = new ArrayList<ILocalFitParams>(); 
    1823                              
    1824                             for (ICurveFitData datum : data) { 
    1825                                 ILocalFitParams localFitParams = new LocalFitParams(); 
    1826                                 localFitParams.setY(datum.getYCount()); 
    1827                                 localFitParams.setSig(datum.getSig()); 
    1828                                 localFitParams.setParams(datum.getParams()); 
    1829                                 localFitParams.setFitStart(m_startBin); 
    1830                                 localFitParams.setFitStop(m_stopBin); 
    1831                                 localFitParams.setYFitted(datum.getYFitted()); 
    1832                                 dataList.add(localFitParams); 
    1833                             } 
    1834                              
    1835                             java.util.List<IFitResults> results = _fittingEngine.fit(globalFitParams, dataList); 
    1836                              
    1837                             double[] lifetimes = new double[pixelList.size()]; 
    1838                             for (int i = 0; i < pixelList.size(); ++i) { 
    1839                                 lifetimes[i] = results.get(i).getParams()[3]; 
    1840                             } 
    1841  
    1842                            //TODO ARG setFittedParamsFromData(resultsCursor, data); 
    1843                             colorizePixelsII(dataColorizer, m_channel, lifetimes, pixelList.toArray(new ChunkyPixel[0])); 
    1844                             pixelList.clear(); 
    1845                              
    1846                             //TODO so the results are not getting saved to an Imglib Image 
    1847                             //TODO this technique of building an array of ICurveFitData, then breaking that down into 
    1848                             // IGlobalFitParams and ILocalFitParams 
    1849  
    1850                         } 
    1851  
    1852                     } 
    1853                 } 
    1854             } 
    1855             // handle any leftover pixels 
    1856             if (!m_cancel && pixelsToProcessCount > 0) { 
    1857                 if (OLD_STYLE) { 
    1858                     pixelsToProcessCount = 0; 
    1859                     ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1860                     curveFitDataList.clear(); 
    1861                     curveFitter.fitData(data, m_startBin, m_stopBin); 
    1862                     setFittedParamsFromData(resultsCursor, data); 
    1863                     colorizePixels(dataColorizer, m_channel, data, pixelList.toArray(new ChunkyPixel[0])); 
    1864   
    1865                 } 
    1866                 else { 
    1867                             pixelsToProcessCount = 0; 
    1868                             ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1869                             curveFitDataList.clear(); 
    1870                              
    1871                             if (null == _fittingEngine) { 
    1872                                 _fittingEngine = Configuration.getInstance().getFittingEngine(); 
    1873                                 _fittingEngine.setThreads(Configuration.getInstance().getThreads()); 
    1874                                 _fittingEngine.setCurveFitter(Configuration.getInstance().getCurveFitter()); 
    1875                             } 
    1876                                                          
    1877                              
    1878                             IGlobalFitParams globalFitParams = new GlobalFitParams(); 
    1879                             globalFitParams.setFitAlgorithm(FitAlgorithm.SLIMCURVE_RLD_LMA); 
    1880                             globalFitParams.setFitFunction(FitFunction.SINGLE_EXPONENTIAL); 
    1881                             globalFitParams.setXInc(m_timeRange); 
    1882                             globalFitParams.setPrompt(null); 
    1883                             if (null != m_excitationPanel) { 
    1884                                 globalFitParams.setPrompt(m_excitationPanel.getValues(1)); 
    1885                             } 
    1886                             globalFitParams.setChiSquareTarget(data[0].getChiSquareTarget()); 
    1887                             globalFitParams.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
    1888                              
    1889                             java.util.List<ILocalFitParams> dataList = new ArrayList<ILocalFitParams>(); 
    1890                              
    1891                             for (ICurveFitData datum : data) { 
    1892                                 ILocalFitParams localFitParams = new LocalFitParams(); 
    1893                                 localFitParams.setY(datum.getYCount()); 
    1894                                 localFitParams.setSig(datum.getSig()); 
    1895                                 localFitParams.setParams(datum.getParams()); 
    1896                                 localFitParams.setFitStart(m_startBin); 
    1897                                 localFitParams.setFitStop(m_stopBin); 
    1898                                 localFitParams.setYFitted(datum.getYFitted()); 
    1899                                 dataList.add(localFitParams); 
    1900                             } 
    1901                              
    1902                             java.util.List<IFitResults> results = _fittingEngine.fit(globalFitParams, dataList); 
    1903                              
    1904                             double[] lifetimes = new double[pixelList.size()]; 
    1905                             for (int i = 0; i < pixelList.size(); ++i) { 
    1906                                 lifetimes[i] = results.get(i).getParams()[3]; 
    1907                             } 
    1908  
    1909                            //TODO ARG setFittedParamsFromData(resultsCursor, data); 
    1910                             colorizePixelsII(dataColorizer, m_channel, lifetimes, pixelList.toArray(new ChunkyPixel[0])); 
    1911  
    1912                 } 
    1913             } 
    1914         } 
    1915         if (m_cancel) { 
    1916             IJ.showProgress(0, 0); //TODO the code below s/b showing progress also 
    1917            // dataColorizer.quit(); //TODO no longer visible in this code 
    1918             cancelImageFit(); 
    1919             return null; 
    1920         } 
    1921   
    1922         // any channels still to be fitted? 
    1923         for (int channel : channelIndexArray(m_channel, m_channels, m_visibleFit, m_fitAllChannels)) { 
    1924             for (int y = 0; y < m_height; ++y) { 
    1925                 for (int x = 0; x < m_width; ++x) { 
    1926                     if (m_visibleFit) { 
    1927                         IJ.showProgress(++pixelCount, totalPixelCount); 
    1928                     } 
    1929   
    1930                     if (wantFitted(channel, x, y)) { 
    1931                          ++pixelsToProcessCount; 
    1932                          curveFitData = new CurveFitData(); 
    1933                          curveFitData.setChannel(channel); 
    1934                          curveFitData.setX(x); 
    1935                          curveFitData.setY(y); 
    1936                          curveFitData.setParams( 
    1937                              useFittedParams ? 
    1938                                  getFittedParams(resultsCursor, channel, x, y, m_fittedParameterCount) : 
    1939                                  params.clone()); 
    1940                          yCount = new double[m_bins]; 
    1941                          for (int b = 0; b < m_bins; ++b) { 
    1942                              yCount[b] = getData(pixelCursor, channel, x, y, b); //binnedData[channel][y][x][b]; 
    1943                          } 
    1944                          curveFitData.setYCount(yCount); 
    1945                          yFitted = new double[m_bins]; 
    1946                          curveFitData.setYFitted(yFitted); 
    1947                          curveFitDataList.add(curveFitData); 
    1948                     } 
    1949                      
    1950                     if (m_cancel) { 
    1951                         cancelImageFit(); 
    1952                         return null; 
    1953                     } 
    1954                 } 
    1955                 // every row, process pixels as needed 
    1956                 if (pixelsToProcessCount >= PIXEL_COUNT) { 
    1957                     pixelsToProcessCount = 0; 
    1958                     ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1959                     curveFitDataList.clear(); 
    1960                     curveFitter.fitData(data, m_startBin, m_stopBin); 
    1961                     setFittedParamsFromData(resultsCursor, data); 
    1962                 } 
    1963             } 
    1964         } 
    1965         // handle any leftover pixels 
    1966         if (pixelsToProcessCount > 0) { 
    1967             ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
    1968             curveFitter.fitData(data, m_startBin, m_stopBin); 
    1969             setFittedParamsFromData(resultsCursor, data); 
    1970         } 
    1971  
    1972  
    1973         uiPanel.setFittedParameterCount(m_fittedParameterCount); //TODO kind of strange since I got that info from uiPanel earlier...  This s/b reset(true) or something Also, it doesn't really do anything in uiPanel 
    1974  
    1975         long elapsed = System.nanoTime() - start; 
    1976         System.out.println("nanoseconds " + elapsed); 
    1977         showRunningAverage(elapsed); 
    1978  
    1979         return m_fittedImage; 
    1980     } 
    19811248 
    19821249    static int s_avgIndex; 
     
    21131380 
    21141381    private void setFittedParamsFromData(LocalizableByDimCursor<DoubleType> cursor, ICurveFitData dataArray[]) { 
    2115         int x, y; 
    2116         double[] params; 
    2117         for (ICurveFitData data : dataArray) { 
    2118             setFittedParams(cursor, data.getChannel(), data.getX(), data.getY(), data.getParams()); 
    2119         } 
    2120     } 
    2121      
    2122     private void setFittedParamsFromDataII(LocalizableByDimCursor<DoubleType> cursor, ICurveFitData dataArray[]) { 
    21231382        int x, y; 
    21241383        double[] params; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/analysis/plugins/Display.java

    r7875 r7889  
    244244        } 
    245245        dialog.showDialog(); 
    246         formulas = formulasMap.get(dialog.getNextChoice()); 
     246        String nextChoice = dialog.getNextChoice(); 
     247        System.out.println("nextChoice is " + nextChoice); 
     248        formulas = formulasMap.get(nextChoice); //dialog.getNextChoice()); 
    247249        if (channels > 1) { 
    248250            combineMinMax = dialog.getNextBoolean(); 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/FitInfo.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.fitting; 
     5package loci.slim.fitting; 
    66 
    77import java.awt.image.IndexColorModel; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/IDecayImage.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.fitting; 
     5package loci.slim.fitting; 
     6 
     7import loci.slim.process.IProcessor; 
    68 
    79import mpicbg.imglib.image.Image; 
     
    1315 * @author Aivar Grislis 
    1416 */ 
    15 public interface IDecayImage<T extends RealType<T>> { 
     17public interface IDecayImage<T extends RealType<T>> extends IProcessor { 
    1618     
    1719    /** 
     
    4143     */ 
    4244    public int getBins(); 
    43  
     45     
    4446    /** 
    45      * Gets whether or not to fit this pixel. 
     47     * Specifies a source IProcessor to be chained to this one. 
    4648     *  
    47      * @param x 
    48      * @param y 
    49      * @param channel 
    50      * @return  
     49     * @param processor  
    5150     */ 
    52     public boolean fitThisPixel(int[] location); 
    53     
     51    public void chain(IProcessor processor); 
     52     
    5453    /** 
    5554     * Gets input pixel value. 
     
    5857     * @param y 
    5958     * @param channel 
    60      * @return  
     59     * @return null or pixel value 
    6160     */ 
    6261    public double[] getPixel(int[] location); 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/IFittedImage.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.fitting; 
     5package loci.slim.fitting; 
    66 
    77import mpicbg.imglib.image.Image; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/callable/FittingEngineCallable.java

    r7875 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.callable; 
     35package loci.slim.fitting.callable; 
    3636 
    37 import imagej.slim.fitting.params.FitResults; 
    38 import imagej.slim.fitting.params.ILocalFitParams; 
    39 import imagej.slim.fitting.params.IGlobalFitParams; 
    40 import imagej.slim.fitting.params.IFitResults; 
     37import loci.slim.fitting.params.FitResults; 
     38import loci.slim.fitting.params.ILocalFitParams; 
     39import loci.slim.fitting.params.IGlobalFitParams; 
     40import loci.slim.fitting.params.IFitResults; 
    4141 
    4242import loci.curvefitter.CurveFitData; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/callable/IFittingEngineCallable.java

    r7811 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.callable; 
     35package loci.slim.fitting.callable; 
    3636 
    37 import imagej.slim.fitting.params.ILocalFitParams; 
    38 import imagej.slim.fitting.params.IGlobalFitParams; 
    39 import imagej.slim.fitting.params.IFitResults; 
     37import loci.slim.fitting.params.ILocalFitParams; 
     38import loci.slim.fitting.params.IGlobalFitParams; 
     39import loci.slim.fitting.params.IFitResults; 
    4040import loci.curvefitter.ICurveFitter; 
    4141 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/config/Configuration.java

    r7832 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.config; 
     35package loci.slim.fitting.config; 
    3636 
    37 import imagej.slim.fitting.callable.IFittingEngineCallable; 
    38 import imagej.slim.fitting.callable.FittingEngineCallable; 
    39 import imagej.slim.fitting.cursor.LameCursorEstimator; 
    40 import imagej.slim.fitting.cursor.ICursorEstimator; 
    41 import imagej.slim.fitting.engine.IFittingEngine; 
    42 import imagej.slim.fitting.engine.ThreadedFittingEngine; 
     37import loci.slim.fitting.callable.IFittingEngineCallable; 
     38import loci.slim.fitting.callable.FittingEngineCallable; 
     39import loci.slim.fitting.cursor.LameCursorEstimator; 
     40import loci.slim.fitting.cursor.ICursorEstimator; 
     41import loci.slim.fitting.engine.IFittingEngine; 
     42import loci.slim.fitting.engine.ThreadedFittingEngine; 
    4343 
    4444import loci.curvefitter.ICurveFitter; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/config/ConfigurationHelper.java

    r7805 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.config; 
     35package loci.slim.fitting.config; 
    3636 
    3737/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/cursor/Cursor.java

    r7805 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.cursor; 
     35package loci.slim.fitting.cursor; 
    3636 
    3737/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/cursor/ICursor.java

    r7805 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.cursor; 
     35package loci.slim.fitting.cursor; 
    3636 
    3737/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/cursor/ICursorEstimator.java

    r7805 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.cursor; 
     35package loci.slim.fitting.cursor; 
    3636 
    3737/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/cursor/LameCursorEstimator.java

    r7805 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.cursor; 
     35package loci.slim.fitting.cursor; 
    3636 
    3737/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/engine/IFittingEngine.java

    r7864 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.engine; 
     35package loci.slim.fitting.engine; 
    3636 
    37 import imagej.slim.fitting.params.ILocalFitParams; 
    38 import imagej.slim.fitting.params.IGlobalFitParams; 
    39 import imagej.slim.fitting.params.IFitResults; 
     37import loci.slim.fitting.params.ILocalFitParams; 
     38import loci.slim.fitting.params.IGlobalFitParams; 
     39import loci.slim.fitting.params.IFitResults; 
    4040 
    4141import java.util.List; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/engine/ThreadedFittingEngine.java

    r7811 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.engine; 
     35package loci.slim.fitting.engine; 
    3636 
    37 import imagej.slim.fitting.params.ILocalFitParams; 
    38 import imagej.slim.fitting.params.IGlobalFitParams; 
    39 import imagej.slim.fitting.params.IFitResults; 
    40 import imagej.slim.fitting.callable.IFittingEngineCallable; 
    41 import imagej.slim.fitting.config.Configuration; 
     37import loci.slim.fitting.params.ILocalFitParams; 
     38import loci.slim.fitting.params.IGlobalFitParams; 
     39import loci.slim.fitting.params.IFitResults; 
     40import loci.slim.fitting.callable.IFittingEngineCallable; 
     41import loci.slim.fitting.config.Configuration; 
    4242 
    4343import loci.curvefitter.ICurveFitter; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/AbstractBaseColorizedImage.java

    r7887 r7889  
    44 */ 
    55 
    6 package imagej.slim.fitting.images; 
     6package loci.slim.fitting.images; 
    77 
    88import java.awt.event.FocusEvent; 
     
    1616import ij.process.FloatProcessor; 
    1717 
    18 import imagej.slim.histogram.HistogramData; 
    19 import imagej.slim.histogram.HistogramDataChannel; 
    20 import imagej.slim.histogram.HistogramTool; 
    21 import imagej.slim.histogram.PaletteFix; 
     18import loci.slim.histogram.HistogramData; 
     19import loci.slim.histogram.HistogramDataChannel; 
     20import loci.slim.histogram.HistogramTool; 
     21import loci.slim.histogram.PaletteFix; 
    2222 
    2323import loci.slim.MyStackWindow; 
     
    8080        _stackWindow.addFocusListener(new FocusListener() { 
    8181            public void focusGained(FocusEvent e) { 
     82                int channelIndex = _stackWindow.getSlice() - 1; 
     83                _histogramData.setChannelIndex(channelIndex); 
     84                System.out.println("focusGained channel " + channelIndex); 
    8285                HistogramTool.getInstance().setHistogramData(_histogramData); 
    8386            } 
     
    143146    public void recalcHistogram() { 
    144147        double[] minMaxLUT = _histogramData.recalcHistogram(); 
     148         
     149        System.out.println("RecalcHistogram to " + minMaxLUT[0] + " " + minMaxLUT[1]); 
    145150 
    146151        if (null != minMaxLUT) { 
     
    181186        int y       = location[1]; 
    182187        int channel = location[2]; 
    183         System.out.println("updatePixel(" + x + " " + y + " " + channel + " prev channel is " + _channel); 
     188        //System.out.println("updatePixel(" + x + " " + y + " " + channel + " prev channel is " + _channel); 
    184189         
    185190        if (_channel != channel) { 
     
    188193            _values = _histogramDataChannels[channel].getValues(); 
    189194             
    190             System.out.println("values is " + _values + " " + _values.hashCode()); 
     195            //System.out.println("values is " + _values + " " + _values.hashCode()); 
    191196             
    192197            _imageProcessor = (FloatProcessor) _imageStack.getProcessor(channel + 1); 
    193             System.out.println("ImageProc for " + channel + " is " + _imageProcessor.toString() + " hash " + _imageProcessor.hashCode()); 
     198            //System.out.println("ImageProc for " + channel + " is " + _imageProcessor.toString() + " hash " + _imageProcessor.hashCode()); 
    194199        } 
    195200         
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/ColorizedImage.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.fitting.images; 
     5package loci.slim.fitting.images; 
    66 
    77import java.awt.image.IndexColorModel; 
    88 
    9 import imagej.slim.fitting.images.AbstractBaseColorizedImage; 
     9import loci.slim.fitting.images.AbstractBaseColorizedImage; 
    1010 
    1111/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/ColorizedImageFactory.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.fitting.images; 
     5package loci.slim.fitting.images; 
    66 
    77import java.awt.image.IndexColorModel; 
    88 
    9 import imagej.slim.fitting.images.IColorizedImage; 
    10 import imagej.slim.fitting.images.ColorizedImage; 
    11 import imagej.slim.fitting.images.FractionalIntensityImage; 
    12 import imagej.slim.fitting.images.FractionalContributionImage; 
    13 import imagej.slim.fitting.images.ColorizedImageFitter.ColorizedImageType; 
     9import loci.slim.fitting.images.IColorizedImage; 
     10import loci.slim.fitting.images.ColorizedImage; 
     11import loci.slim.fitting.images.FractionalIntensityImage; 
     12import loci.slim.fitting.images.FractionalContributionImage; 
     13import loci.slim.fitting.images.ColorizedImageFitter.ColorizedImageType; 
    1414 
    1515/** 
     
    7070                break; 
    7171            case CHISQ: 
    72                 fittedImage = new ColorizedImage("ChiSquare", dimension, 
     72                fittedImage = new ColorizedImage("X2", dimension, 
    7373                        indexColorModel, ColorizedImageFitter.CHISQ_INDEX); 
    7474                break; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/ColorizedImageFitter.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.fitting.images; 
     5package loci.slim.fitting.images; 
    66 
    77import java.awt.image.IndexColorModel; 
     
    99import java.util.List; 
    1010 
    11 import imagej.slim.histogram.HistogramTool; 
     11import loci.slim.histogram.HistogramTool; 
    1212 
    1313/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/ColorizedImageParser.java

    r7865 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.fitting.images; 
     5package loci.slim.fitting.images; 
    66 
    7 import imagej.slim.fitting.images.ColorizedImageFitter.ColorizedImageType; 
     7import loci.slim.fitting.images.ColorizedImageFitter.ColorizedImageType; 
    88 
    99import java.util.ArrayList; 
     
    2222    private static final String TAU_STRING = "" + TAU; 
    2323    private static final String CHI_SQ_STRING = "" + CHI + SQUARE; 
     24    private static final int Z_INDEX = 0; 
     25    private static final int A1_INDEX = 1; 
     26    private static final int T1_INDEX = 2; 
     27    private static final int A2_INDEX = 3; 
     28    private static final int H_INDEX = 3; 
     29    private static final int T2_INDEX = 4; 
     30    private static final int A3_INDEX = 5; 
     31    private static final int T3_INDEX = 6; 
     32    private static final int MAX_INDEX = 6; 
    2433    private String _input; 
    2534    private int _components; 
    2635    private boolean _stretched; 
     36    private boolean[] _free; 
    2737 
    2838    /** 
    2939     * Creates an instance for a given input string, etc. 
    3040     *  
    31      * @param input 
    32      * @param components 
    33      * @param stretched  
     41     * @param input string with colorized images to produce 
     42     * @param components number of exponential fit components 
     43     * @param stretched whether it's a stretched exponential 
     44     * @param free whether each parameter is free or fixed 
    3445     */ 
    35     public ColorizedImageParser(String input, int components, boolean stretched) { 
     46    public ColorizedImageParser(String input, int components, boolean stretched, 
     47            boolean[] free) { 
    3648        _input = input; 
    3749        _components = components; 
    3850        _stretched = stretched; 
     51        if (null == free) { 
     52            _free = new boolean[MAX_INDEX + 1]; 
     53            for (int i = 0; i < _free.length; ++i) { 
     54                _free[i] = true; 
     55            } 
     56        } 
     57        else { 
     58            _free = free; 
     59        } 
    3960    } 
    4061 
     
    5374                switch (_components) { 
    5475                    case 1: 
    55                         list.add(ColorizedImageType.A1); 
     76                        if (_free[A1_INDEX]) { 
     77                            list.add(ColorizedImageType.A1); 
     78                        } 
    5679                        break; 
    5780                    case 2: 
    58                         list.add(ColorizedImageType.A1); 
    59                         list.add(ColorizedImageType.A2); 
     81                        if (_free[A1_INDEX]) { 
     82                            list.add(ColorizedImageType.A1); 
     83                        } 
     84                        if (_free[A2_INDEX]) { 
     85                            list.add(ColorizedImageType.A2); 
     86                        } 
    6087                        break; 
    6188                    case 3: 
    62                         list.add(ColorizedImageType.A1); 
    63                         list.add(ColorizedImageType.A2); 
    64                         list.add(ColorizedImageType.A3); 
     89                        if (_free[A1_INDEX]) { 
     90                            list.add(ColorizedImageType.A1); 
     91                        } 
     92                        if (_free[A2_INDEX]) { 
     93                            list.add(ColorizedImageType.A2); 
     94                        } 
     95                        if (_free[A3_INDEX]) { 
     96                            list.add(ColorizedImageType.A3); 
     97                        } 
    6598                        break; 
    6699               } 
     
    69102                switch (_components) { 
    70103                    case 1: 
    71                         list.add(ColorizedImageType.T1); 
     104                        if (_free[T1_INDEX]) { 
     105                            list.add(ColorizedImageType.T1); 
     106                        } 
    72107                        break; 
    73108                    case 2: 
    74                         list.add(ColorizedImageType.T1); 
    75                         list.add(ColorizedImageType.T2); 
     109                        if (_free[T1_INDEX]) { 
     110                            list.add(ColorizedImageType.T1); 
     111                        } 
     112                        if (_free[T2_INDEX]) { 
     113                            list.add(ColorizedImageType.T2); 
     114                        } 
    76115                        break; 
    77116                    case 3: 
    78                         list.add(ColorizedImageType.T1); 
    79                         list.add(ColorizedImageType.T2); 
    80                         list.add(ColorizedImageType.T3); 
     117                        if (_free[T1_INDEX]) { 
     118                            list.add(ColorizedImageType.T1); 
     119                        } 
     120                        if (_free[T2_INDEX]) { 
     121                            list.add(ColorizedImageType.T2); 
     122                        } 
     123                        if (_free[T3_INDEX]) { 
     124                            list.add(ColorizedImageType.T3); 
     125                        } 
    81126                        break; 
    82127               } 
    83128            } 
    84129            else if ("Z".equals(token)) { 
    85                 list.add(ColorizedImageType.Z); 
     130                if (_free[Z_INDEX]) { 
     131                    list.add(ColorizedImageType.Z); 
     132                } 
    86133            } 
    87134            else if ("X2".equals(token) || CHI_SQ_STRING.equals(token)) { 
     
    90137            else if ("H".equals(token)) { 
    91138                if (_stretched) { 
    92                     list.add(ColorizedImageType.H); 
     139                    if (_free[H_INDEX]) { 
     140                        list.add(ColorizedImageType.H); 
     141                    } 
    93142                } 
    94143            } 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/FractionalContributionImage.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.fitting.images; 
     5package loci.slim.fitting.images; 
    66 
    77import java.awt.image.IndexColorModel; 
    88 
    9 import imagej.slim.fitting.images.AbstractBaseColorizedImage; 
     9import loci.slim.fitting.images.AbstractBaseColorizedImage; 
    1010 
    1111/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/FractionalIntensityImage.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.fitting.images; 
     5package loci.slim.fitting.images; 
    66 
    77import java.awt.image.IndexColorModel; 
    88 
    9 import imagej.slim.fitting.images.AbstractBaseColorizedImage; 
     9import loci.slim.fitting.images.AbstractBaseColorizedImage; 
    1010 
    1111/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/images/IColorizedImage.java

    r7865 r7889  
    44 */ 
    55 
    6 package imagej.slim.fitting.images; 
     6package loci.slim.fitting.images; 
    77 
    88import java.awt.image.IndexColorModel; 
    99 
    10 import imagej.slim.histogram.HistogramData; 
     10import loci.slim.histogram.HistogramData; 
    1111 
    1212/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/params/FitResults.java

    r7811 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.params; 
     35package loci.slim.fitting.params; 
    3636 
    3737/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/params/GlobalFitParams.java

    r7862 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.params; 
     35package loci.slim.fitting.params; 
    3636 
    3737import loci.curvefitter.ICurveFitter.FitAlgorithm; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/params/IFitResults.java

    r7811 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.params; 
     35package loci.slim.fitting.params; 
    3636 
    3737/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/params/IGlobalFitParams.java

    r7862 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.params; 
     35package loci.slim.fitting.params; 
    3636 
    3737import loci.curvefitter.ICurveFitter.FitAlgorithm; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/params/ILocalFitParams.java

    r7811 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.params; 
     35package loci.slim.fitting.params; 
    3636 
    3737/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/fitting/params/LocalFitParams.java

    r7811 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.fitting.params; 
     35package loci.slim.fitting.params; 
    3636 
    3737/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/ColorBarPanel.java

    r7847 r7889  
    3333*/ 
    3434 
    35 package imagej.slim.histogram; 
     35package loci.slim.histogram; 
    3636 
    3737import java.awt.Color; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/DoubleFormatter.java

    r7847 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.histogram; 
     5package loci.slim.histogram; 
    66 
    77import java.math.BigDecimal; 
     
    4747     */ 
    4848    public String getText() { 
     49        int index = _text.indexOf("-"); 
     50        if (index > 0) { 
     51            if ('E' != _text.charAt(index - 1)) { 
     52                ij.IJ.log("Funny text " + _text); 
     53            } 
     54        } 
    4955        return _text; 
    5056    } 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramData.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.histogram; 
    6  
    7 import imagej.slim.fitting.images.IColorizedImage; 
     5package loci.slim.histogram; 
     6 
     7import loci.slim.fitting.images.IColorizedImage; 
    88 
    99/** 
     
    4343        _channel = channel; 
    4444        _autoRange = true; 
    45         _combineChannels = true; 
    46         _displayChannels = true; 
     45        _combineChannels = hasChannels(); 
     46        _displayChannels = hasChannels(); 
    4747        _channelIndex = 0; 
    48         _minView = _maxView = 0.0f; 
    49         _minLUT = _maxLUT = 0.0f; 
    50         _minData = _maxData = 0.0f; 
     48        _minView = _maxView = 0.0; 
     49        _minLUT  = _maxLUT  = 0.0; 
     50        _minData = _maxData = 0.0; 
    5151        _minDataCurrent = _maxDataCurrent = 0.0; 
    5252        _listener = null; 
     
    141141    public void setDisplayChannels(boolean displayChannels) { 
    142142        _displayChannels = displayChannels; 
     143    } 
     144 
     145    /** 
     146     * Returns whether or not histogram has channels. 
     147     *  
     148     * @return  
     149     */ 
     150    public boolean hasChannels() { 
     151        return _channel.length > 1; 
    143152    } 
    144153 
     
    288297            minMaxData = _channel[_channelIndex].findMinMax(); 
    289298            minData = minDataCurrent = minMaxData[0]; 
    290             maxData = minDataCurrent = minMaxData[1]; 
     299            maxData = maxDataCurrent = minMaxData[1]; 
    291300        } 
    292301 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramDataChannel.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.histogram; 
     5package loci.slim.histogram; 
    66 
    77/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramPanel.java

    r7886 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.histogram; 
     5package loci.slim.histogram; 
    66 
    77import java.awt.Color; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramTool.java

    r7886 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.histogram; 
     5package loci.slim.histogram; 
    66 
    77import java.awt.BorderLayout; 
     
    155155         
    156156        _histogramPanel.setBins(histogramData.binValues(WIDTH)); 
    157         System.out.println("minMaxLUT is " + minMaxLUT[0] + " " + minMaxLUT[1]); 
    158         System.out.println("so cursosr are " + cursorPixelFromValue(false, minMaxLUT[0]) + " " + cursorPixelFromValue(false, minMaxLUT[1])); 
    159157        _histogramPanel.setCursors(cursorPixelFromValue(false, minMaxLUT[0]), cursorPixelFromValue(false, minMaxLUT[1])); //TODO ARG true, maxLUT)); in this case adding 1 to max is too much! 
    160158  
     
    162160        _uiPanel.setCombineChannels(histogramData.getCombineChannels()); 
    163161        _uiPanel.setDisplayChannels(histogramData.getDisplayChannels()); 
     162        _uiPanel.enableChannels(histogramData.hasChannels());         
    164163        _uiPanel.setMinMaxLUT(minMaxLUT[0], minMaxLUT[1]); 
    165164         
     
    198197            double max = minMaxView[1]; 
    199198            int pixel = (int)(PaletteFix.getSize() * (value - min) / (max - min)); 
    200             System.out.println("valueToPixel(" + value + ") -> " + pixel); 
    201199            return pixel; 
    202200        } 
     
    267265        public void setMinMaxLUTPixels(int min, int max) { 
    268266            killTimer(); 
    269  System.out.println("setMinMaxLUTPixels(" + min + "," + max + ")"); 
     267 
    270268            // get new minimum and maximum values for LUT 
    271269            double minLUT = pixelToValue(min); 
    272270            double maxLUT = pixelToValue(max + 1); 
    273              
    274  System.out.println("setMinMaxLUTPixels values are " + minLUT + " " + maxLUT); 
    275   
    276  System.out.println("maxLut for max + 1 would be " + pixelToValue(max + 1)); 
    277  System.out.println("minLUT for min = 0 would be " + pixelToValue(0)); 
    278271             
    279272            // set min and max on UI panel 
     
    438431            synchronized (_synchObject) { 
    439432                _histogramData.setDisplayChannels(displayChannels); 
     433                 
     434                // get updated histogram data and show it                  
     435                int[] bins = _histogramData.binValues(PaletteFix.ADJUSTED_SIZE); 
     436                _histogramPanel.setBins(bins); 
    440437            } 
    441438            //TODO 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/IHistogramDataListener.java

    r7838 r7889  
    44 */ 
    55 
    6 package imagej.slim.histogram; 
     6package loci.slim.histogram; 
    77 
    88/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/IHistogramPanelListener.java

    r7847 r7889  
    44 */ 
    55 
    6 package imagej.slim.histogram; 
     6package loci.slim.histogram; 
    77 
    88/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/IUIPanelListener.java

    r7847 r7889  
    44 */ 
    55 
    6 package imagej.slim.histogram; 
     6package loci.slim.histogram; 
    77 
    88/** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/PaletteFix.java

    r7879 r7889  
    44 */ 
    55 
    6 package imagej.slim.histogram; 
     6package loci.slim.histogram; 
    77 
    88import java.awt.Color; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/UIPanel.java

    r7887 r7889  
    33 * and open the template in the editor. 
    44 */ 
    5 package imagej.slim.histogram; 
     5package loci.slim.histogram; 
    66 
    77import java.awt.event.ActionEvent; 
     
    136136 
    137137        _displayChannelsCheckBox = 
    138             new JCheckBox("Display Channels", _displayChannels); 
     138            new JCheckBox("Display All Channels", _displayChannels); 
    139139        _displayChannelsCheckBox.addItemListener( 
    140140            new ItemListener() { 
     
    184184        _displayChannelsCheckBox.setSelected(displayChannels); 
    185185    } 
     186     
     187    public void enableChannels(boolean enable) { 
     188        _combineChannelsCheckBox.setEnabled(enable); 
     189        _displayChannelsCheckBox.setEnabled(enable); 
     190    } 
    186191 
    187192    /** 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/ui/UserInterfacePanel.java

    r7886 r7889  
    11171117     */ 
    11181118    public String getFittedImages() { 
     1119        StringBuffer returnValue = new StringBuffer(); 
    11191120        String selected = (String) m_fittedImagesComboBox.getSelectedItem(); 
    1120         return selected; 
     1121        System.out.println("selected is " + selected); 
     1122        String[] fittedImages = selected.split(" "); 
     1123        for (String fittedImage : fittedImages) { 
     1124            boolean fit = true; 
     1125            if ("A".equals(fittedImage)) { 
     1126                 
     1127            } 
     1128            else if ("T".equals(fittedImage)) { 
     1129                 
     1130            } 
     1131            else if ("Z".equals(fittedImage)) { 
     1132                 
     1133            } 
     1134            if (fit) { 
     1135                returnValue.append(fittedImage); 
     1136                returnValue.append(' '); 
     1137            } 
     1138        } 
     1139        System.out.println("changes to " + returnValue); 
     1140        return returnValue.toString(); 
    11211141    } 
    11221142 
Note: See TracChangeset for help on using the changeset viewer.