Ignore:
Timestamp:
12/13/11 00:58:58 (8 years ago)
Author:
aivar
Message:

Shows fitted images. Needs work & buggy.

Location:
trunk/projects/slim-plugin/src/main/java
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/slim-plugin/src/main/java/imagej/slim/fitting/AbstractBaseFittedImage.java

    r7830 r7832  
    66package imagej.slim.fitting; 
    77 
    8 import ij.process.MyFloatProcessor; //TODO IJ hack; update to IJ2 ImgLib 
     8//import ij.process.MyFloatProcessor; //TODO IJ hack; update to IJ2 ImgLib 
    99import ij.ImagePlus; 
     10import ij.process.FloatProcessor; 
    1011 
    1112import imagej.slim.histogram.HistogramData; 
     
    2021    private double _values[][]; 
    2122    private HistogramData _histogramData; 
    22     private MyFloatProcessor _image; 
     23    private FloatProcessor _image; 
    2324    private ImagePlus _imagePlus; 
    2425     
     
    2829        int y = dimension[1]; 
    2930        _values = new double[x][y]; 
     31        //TODO need to handle multiple channels: 
     32        // _values c/b slice being drawn only; refer to Image for other slices 
    3033        HistogramDataChannel histogramDataChannel = new HistogramDataChannel(_values); 
    3134        HistogramDataChannel[] histogramDataChannels = new HistogramDataChannel[] { histogramDataChannel }; 
    3235        _histogramData = new HistogramData(title, histogramDataChannels); 
    33         _image = new MyFloatProcessor(x, y); 
     36        _image = new FloatProcessor(x, y); 
    3437        _imagePlus = new ImagePlus(title, _image); 
    3538        _imagePlus.show(); 
     
    8083     */ 
    8184    public void recalcHistogram() { 
    82         double[] minMax = _histogramData.getMinMax(); //TODO how about HistogramData.recalculate? 
     85        _histogramData.setAuto(true); //TODO KLUDGE!!! NOT HERE!!! WHERE DOES AUTO GET SET? 
     86        double[] minMax = _histogramData.getMinMax(); 
     87 
     88        if (null != minMax) { 
     89            // update palette bounds 
     90            _image.setMinAndMax(minMax[0], minMax[1]); 
     91        } 
    8392//        System.out.println("min max " + minMax[0] + " " + minMax[1]); 
    8493        // etc. 
  • trunk/projects/slim-plugin/src/main/java/imagej/slim/fitting/FittedImage.java

    r7829 r7832  
    66 
    77/** 
     8 * Simple image that just displays one of the input parameters. 
    89 * 
    9  * @author aivar 
     10 * @author Aivar Grislis 
    1011 */ 
    1112public class FittedImage extends AbstractBaseFittedImage { 
    1213    private int _parameterIndex; 
    13      
     14 
     15    /** 
     16     * Constructor, giving index of input parameter to display 
     17     * 
     18     * @param title 
     19     * @param dimension 
     20     * @param parameterIndex 
     21     */ 
    1422    public FittedImage(String title, int[] dimension, int parameterIndex) { 
    1523        super(title, dimension); 
  • trunk/projects/slim-plugin/src/main/java/imagej/slim/fitting/FractionalContributionImage.java

    r7829 r7832  
    88 * This class builds a fitted image that shows the fractional contribution. 
    99 *  
    10  * Fractional Intensity fi = Ai*Ti / sum of all Aj*Tj. 
     10 * Fractional Contribution fi = Ai*Ti / sum of all Aj*Tj. 
    1111 * 
    1212 * @author Aivar Grislis 
  • trunk/projects/slim-plugin/src/main/java/imagej/slim/fitting/config/Configuration.java

    r7811 r7832  
    4848 * Handles configuration specific to the SLIM Plugin. 
    4949 *  
    50  * A singleton so only one configuration per SLIM Plugin. 
     50 * A singleton so only one configuration for the SLIMPlugin.//TODO 
    5151 *  
    5252 * @author Aivar Grislis 
  • trunk/projects/slim-plugin/src/main/java/imagej/slim/histogram/HistogramTool.java

    r7828 r7832  
    3434 */ 
    3535public class HistogramTool { 
    36     private final static String HARDCODED_LUT =  "/Applications/ImageJ/luts/smart.lut"; //aivar6.lut"; // aivar6 is my five color blue/cyan/green/yellow/red spectral palette 
     36    private final static String HARDCODED_LUT =  "/Applications/ImageJ/luts/aivar6.lut"; // aivar6 is my five color blue/cyan/green/yellow/red spectral palette 
    3737    JFrame _frame; 
    3838    HistogramPanel _histogram; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/SLIMProcessor.java

    r7830 r7832  
    4747import java.awt.Rectangle; 
    4848import java.util.ArrayList; 
     49import java.util.List; 
    4950import java.util.prefs.Preferences; 
    5051 
     
    109110 */ 
    110111public class SLIMProcessor <T extends RealType<T>> { 
    111     private static boolean OLD_STYLE = false; // fully krausened, from God's Country in WI 
     112    private static boolean OLD_STYLE = false; 
    112113     
    113114    private imagej.slim.fitting.engine.IFittingEngine _fittingEngine; 
     
    964965     
    965966    //TODO This is the new version and "fitEachPixelX" is the old: 
     967    //TODO need to fit all channels 
     968    //TODO need to be a selfcontained function call 
     969    //  = gives you fitted images and a histogram tool 
     970 
    966971    private Image<DoubleType> fitEachPixel(IUserInterfacePanel uiPanel) { 
    967972        long start = System.nanoTime(); 
     
    10311036 
    10321037                // process the pixels 
    1033                 if (++pixelsToProcessCount >= PIXEL_COUNT || !pixelIterator.hasNext()) { 
     1038                if (++pixelsToProcessCount >= PIXEL_COUNT) { 
    10341039                    ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
     1040                    ChunkyPixel[] pixels = pixelList.toArray(new ChunkyPixel[0]); 
     1041                    processPixels(data, pixels, imageFitter); 
    10351042                    curveFitDataList.clear(); 
    1036                              
    1037                     if (null == _fittingEngine) { 
    1038                         _fittingEngine = Configuration.getInstance().getFittingEngine(); 
    1039                         _fittingEngine.setThreads(Configuration.getInstance().getThreads()); 
    1040                         _fittingEngine.setCurveFitter(Configuration.getInstance().getCurveFitter()); 
    1041                     }                                    
    1042                              
    1043                     IGlobalFitParams globalFitParams = new GlobalFitParams(); 
    1044                     globalFitParams.setFitAlgorithm(loci.curvefitter.ICurveFitter.FitAlgorithm.RLD_LMA); 
    1045                     globalFitParams.setFitFunction(loci.curvefitter.ICurveFitter.FitFunction.SINGLE_EXPONENTIAL); 
    1046                     globalFitParams.setXInc(m_timeRange); 
    1047                     globalFitParams.setPrompt(null); 
    1048                     if (null != m_excitationPanel) { 
    1049                         globalFitParams.setPrompt(m_excitationPanel.getValues(1)); 
    1050                     } 
    1051                     globalFitParams.setChiSquareTarget(data[0].getChiSquareTarget()); 
    1052                     globalFitParams.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
    1053                              
    1054                     java.util.List<ILocalFitParams> dataList = new ArrayList<ILocalFitParams>(); 
    1055                              
    1056                     for (ICurveFitData datum : data) { 
    1057                         ILocalFitParams localFitParams = new LocalFitParams(); 
    1058                         localFitParams.setY(datum.getYCount()); 
    1059                         localFitParams.setSig(datum.getSig()); 
    1060                         localFitParams.setParams(datum.getParams()); 
    1061                         localFitParams.setFitStart(m_startBin); 
    1062                         localFitParams.setFitStop(m_stopBin); 
    1063                         localFitParams.setYFitted(datum.getYFitted()); 
    1064                         dataList.add(localFitParams); 
    1065                     } 
    1066                              
    1067                     java.util.List<IFitResults> results = _fittingEngine.fit(globalFitParams, dataList); 
    1068                      
    1069                     for (int i = 0; i < results.size(); ++i) { 
    1070                         IFitResults result = results.get(i); 
    1071                         ChunkyPixel p = pixelList.get(i); 
    1072                         int[] location = { p.getX(), p.getY() }; 
    1073                         imageFitter.updatePixel(location, result.getParams()); 
    1074                     } 
    1075                  
    1076                     imageFitter.recalcHistogram(); 
    1077                      
    1078                     // done with these pixels 
     1043                    pixelList.clear(); 
    10791044                    pixelsToProcessCount = 0; 
    1080                     pixelList.clear(); 
    10811045                } 
    10821046            } 
     
    10891053            return null; 
    10901054        } 
    1091         imageFitter.endFit(); 
     1055        else { 
     1056            if (pixelsToProcessCount > 0) { 
     1057                ICurveFitData[] data = curveFitDataList.toArray(new ICurveFitData[0]); 
     1058                ChunkyPixel[] pixels = pixelList.toArray(new ChunkyPixel[0]); 
     1059                processPixels(data, pixels, imageFitter); 
     1060            } 
     1061            imageFitter.endFit(); 
     1062        } 
     1063 
    10921064         
    10931065        //TODO so the results are not getting saved to an Imglib Image 
     
    10961068         
    10971069        return null; 
     1070    } 
     1071 
     1072    private void processPixels(ICurveFitData[] data, ChunkyPixel[] pixels, FLIMImageFitter imageFitter) { 
     1073        if (null == _fittingEngine) { 
     1074            _fittingEngine = Configuration.getInstance().getFittingEngine(); 
     1075            _fittingEngine.setThreads(Configuration.getInstance().getThreads()); 
     1076            _fittingEngine.setCurveFitter(Configuration.getInstance().getCurveFitter()); 
     1077        } 
     1078 
     1079        IGlobalFitParams globalFitParams = new GlobalFitParams(); 
     1080        globalFitParams.setFitAlgorithm(loci.curvefitter.ICurveFitter.FitAlgorithm.RLD_LMA); 
     1081        globalFitParams.setFitFunction(loci.curvefitter.ICurveFitter.FitFunction.SINGLE_EXPONENTIAL); 
     1082        globalFitParams.setXInc(m_timeRange); 
     1083        globalFitParams.setPrompt(null); 
     1084        if (null != m_excitationPanel) { 
     1085            globalFitParams.setPrompt(m_excitationPanel.getValues(1)); 
     1086        } 
     1087        globalFitParams.setChiSquareTarget(data[0].getChiSquareTarget()); 
     1088 
     1089 
     1090        boolean[] free = { true, true, true }; 
     1091        globalFitParams.setFree(free); //TODO BAD! 
     1092      //TODO KLUDGE  globalFitParams.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
     1093 
     1094        List<ILocalFitParams> dataList = new ArrayList<ILocalFitParams>(); 
     1095 
     1096        for (ICurveFitData datum : data) { 
     1097            ILocalFitParams localFitParams = new LocalFitParams(); 
     1098            localFitParams.setY(datum.getYCount()); 
     1099            localFitParams.setSig(datum.getSig()); 
     1100            localFitParams.setParams(datum.getParams()); 
     1101            localFitParams.setFitStart(m_startBin); 
     1102            localFitParams.setFitStop(m_stopBin); 
     1103            localFitParams.setYFitted(datum.getYFitted()); 
     1104            dataList.add(localFitParams); 
     1105        } 
     1106 
     1107        List<IFitResults> results = _fittingEngine.fit(globalFitParams, dataList); 
     1108 
     1109        for (int i = 0; i < results.size(); ++i) { 
     1110            IFitResults result = results.get(i); 
     1111            ChunkyPixel p = pixels[i]; 
     1112            int[] location = { p.getX(), p.getY() }; 
     1113            imageFitter.updatePixel(location, result.getParams()); 
     1114        } 
     1115 
     1116        imageFitter.recalcHistogram(); 
    10981117    } 
    10991118  
  • trunk/projects/slim-plugin/src/main/java/loci/slim/colorizer/DataColorizer2.java

    r7825 r7832  
    3939import ij.process.LUT; 
    4040import ij.process.ColorProcessor; 
    41 import ij.process.MyFloatProcessor; 
     41import ij.process.FloatProcessor; 
    4242import ij.process.ImageProcessor; 
    4343 
     
    6969    ImagePlus m_imagePlus; 
    7070    //////ImageProcessor m_imageProcessor; 
    71     MyFloatProcessor m_imageProcessor; 
     71    FloatProcessor m_imageProcessor; 
    7272    double m_histogramData[]; 
    7373    int m_histogramDataIndex; 
     
    8686        m_width = width; 
    8787        m_height = height; 
    88         m_imageProcessor = new MyFloatProcessor(width, height); 
     88        m_imageProcessor = new FloatProcessor(width, height); 
    8989        m_imagePlus = new ImagePlus(title, m_imageProcessor); 
    9090        init(); 
     
    9898    public DataColorizer2(ImagePlus imagePlus, int foofle) { 
    9999        m_imagePlus = imagePlus; 
    100         m_imageProcessor = (MyFloatProcessor) imagePlus.getProcessor(); 
     100        m_imageProcessor = (FloatProcessor) imagePlus.getProcessor(); 
    101101        m_width = imagePlus.getWidth(); 
    102102        m_height = imagePlus.getHeight(); 
Note: See TracChangeset for help on using the changeset viewer.