Changeset 7605


Ignore:
Timestamp:
01/27/11 23:59:41 (9 years ago)
Author:
aivar
Message:

I had inverted the image to correspond with SLIMPlotter, but the natural way up corresponds to TRI2. There was a bug, it was colorizing based on the wrong parameter. The array that defined which parameters are free (vs. fixed) needed to be translated from UI order to SLIMCurve order.

File:
1 edited

Legend:

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

    r7597 r7605  
    138138    private LocalizableByDimCursor<T> m_cursor; 
    139139 
    140     // Actual data values, dimensioned [channel][row][column][bin] //TODO DEPRECATE 
    141     protected int[][][][] Xm_data; 
    142  
    143140    private ImageProcessor m_grayscaleImageProcessor; 
    144141    private Canvas m_grayscaleCanvas; 
     
    713710        yCount = new double[m_timeBins]; 
    714711        for (int b = 0; b < m_timeBins; ++b) { 
    715             yCount[b] = getData(m_cursor, m_channel, x, m_height - y - 1, b); 
     712            yCount[b] = getData(m_cursor, m_channel, x, y, b); 
    716713        } 
    717714        curveFitData.setYCount(yCount); 
     
    816813                        curveFitter.fitData(data, m_startBin, m_stopBin); 
    817814                        setFittedParamsFromData(resultsCursor, data); 
    818                         colorizePixels(dataColorizer, m_height, m_channel, data, pixelList.toArray(new ChunkyPixel[0])); 
     815                        colorizePixels(dataColorizer, m_channel, data, pixelList.toArray(new ChunkyPixel[0])); 
    819816                        pixelList.clear(); 
    820817                    } 
     
    828825                curveFitter.fitData(data, m_startBin, m_stopBin); 
    829826                setFittedParamsFromData(resultsCursor, data); 
    830                 colorizePixels(dataColorizer, m_height, m_channel, data, pixelList.toArray(new ChunkyPixel[0])); 
     827                colorizePixels(dataColorizer, m_channel, data, pixelList.toArray(new ChunkyPixel[0])); 
    831828            } 
    832829        } 
     
    10251022     * @param pixels parallel list of rectangles with which to draw the fitted pixel 
    10261023     */ 
    1027     void colorizePixels(DataColorizer dataColorizer, int height, int channel, ICurveFitData data[], ChunkyPixel pixels[]) { 
     1024    void colorizePixels(DataColorizer dataColorizer, int channel, ICurveFitData data[], ChunkyPixel pixels[]) { 
    10281025 
    10291026        // draw as you go; 'chunky' pixels get smaller as the overall fit progresses 
    10301027        for (int i = 0; i < pixels.length; ++i) { 
    10311028            ChunkyPixel pixel = pixels[i]; 
    1032             double lifetime = data[i].getParams()[1]; 
     1029            //TODO tau is 3, 1 is C double lifetime = data[i].getParams()[1]; 
     1030            double lifetime = data[i].getParams()[3]; 
    10331031 
    10341032            //TODO quick fix 
     
    10631061                for (int y = pixel.getY(); y < pixel.getY() + pixel.getHeight(); ++y) { 
    10641062                    if (wantFitted(channel, x, y)) { 
    1065                         // (flip vertically) 
    1066                         dataColorizer.setData(firstTime, x, height - y - 1 , lifetime); 
     1063                        dataColorizer.setData(firstTime, x, y , lifetime); 
    10671064                        firstTime = false; 
    10681065                    } 
     
    10941091     */ 
    10951092    boolean aboveThreshold(int channel, int x, int y) { 
    1096         return (m_threshold <= m_grayScaleImage.getPixel(channel, x, m_height - y - 1)); 
     1093        return (m_threshold <= m_grayScaleImage.getPixel(channel, x, y)); 
    10971094    } 
    10981095 
     
    12461243        curveFitter.setFitFunction(fitFunction); 
    12471244        curveFitter.setXInc(m_timeRange); 
    1248         curveFitter.setFree(uiPanel.getFree()); 
     1245        curveFitter.setFree(translateFree(uiPanel.getFunction(), uiPanel.getFree())); 
    12491246        return curveFitter; 
     1247    } 
     1248 
     1249    /* 
     1250     * Handles reordering the array that describes which fit parameters are 
     1251     * free (vs. fixed). 
     1252     */ 
     1253    private boolean[] translateFree(FitFunction fitFunction, boolean free[]) { 
     1254        boolean translated[] = new boolean[free.length]; 
     1255        switch (fitFunction) { 
     1256            case SINGLE_EXPONENTIAL: 
     1257                // incoming UI order is A, T, C 
     1258                // SLIMCurve wants C, A, T 
     1259                translated[0] = free[2]; 
     1260                translated[1] = free[0]; 
     1261                translated[2] = free[1]; 
     1262                break; 
     1263            case DOUBLE_EXPONENTIAL: 
     1264                // incoming UI order is A1 T1 A2 T2 C 
     1265                // SLIMCurve wants C A1 T1 A2 T2 
     1266                translated[0] = free[4]; 
     1267                translated[1] = free[0]; 
     1268                translated[2] = free[1]; 
     1269                translated[3] = free[2]; 
     1270                translated[4] = free[3]; 
     1271                break; 
     1272            case TRIPLE_EXPONENTIAL: 
     1273                // incoming UI order is A1 T1 A2 T2 A3 T3 C 
     1274                // SLIMCurve wants C A1 T1 A2 T2 A3 T3 
     1275                translated[0] = free[6]; 
     1276                translated[1] = free[0]; 
     1277                translated[2] = free[1]; 
     1278                translated[3] = free[2]; 
     1279                translated[4] = free[3]; 
     1280                translated[5] = free[4]; 
     1281                translated[6] = free[5]; 
     1282                break; 
     1283            case STRETCHED_EXPONENTIAL: 
     1284                // incoming UI order is A T H C 
     1285                // SLIMCurve wants C A T H 
     1286                translated[0] = free[3]; 
     1287                translated[1] = free[0]; 
     1288                translated[2] = free[1]; 
     1289                translated[3] = free[2]; 
     1290                break; 
     1291        } 
     1292        return translated; 
    12501293    } 
    12511294 
Note: See TracChangeset for help on using the changeset viewer.