Changeset 7989


Ignore:
Timestamp:
04/19/12 10:38:34 (8 years ago)
Author:
aivar
Message:

SLIM Plugin: Prompts working much better.

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

Legend:

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

    r7970 r7989  
    400400                     
    401401                    double chiSqTarget = m_uiPanel.getChiSquareTarget(); 
     402//                    System.out.println("prompt is " + prompt + " and fitting cursor thinks prompt " + _fittingCursor.getHasPrompt()); 
    402403                    if (null != prompt && _fittingCursor.getHasPrompt()) { 
    403404                        double[] results = CursorEstimator.estimateCursors 
     
    573574    private boolean updateExcitation(IUserInterfacePanel uiPanel, Excitation excitation) { 
    574575        boolean success = false; 
    575         System.out.println("###update excitation " + excitation); 
     576//        System.out.println("###update excitation " + excitation); 
    576577        if (null != excitation) { 
    577578            if (null != m_excitationPanel) { 
     
    643644        m_path = dialog.getDirectory(); 
    644645        m_file = dialog.getFileName(); 
    645         System.out.println("directory is " + dialog.getDirectory()); 
    646         System.out.println("file is " + dialog.getFileName()); 
     646//        System.out.println("directory is " + dialog.getDirectory()); 
     647//        System.out.println("file is " + dialog.getFileName()); 
    647648        return true; 
    648649    } 
     
    12661267        m_startBin = fittingCursor.getDataStartBin(); 
    12671268        m_stopBin = fittingCursor.getTransientStopBin(); 
    1268         System.out.println("m_startBin is " + m_startBin + " m_stopBin " + m_stopBin); 
    1269         System.out.println("_fittingCursor " + _fittingCursor.getTransientStartValue() + " " + _fittingCursor.getTransientStartBin() + " " + _fittingCursor.getTransientStopValue()); 
     1269//        System.out.println("m_startBin is " + m_startBin + " m_stopBin " + m_stopBin); 
     1270//        System.out.println("FYI FWIW prompt delay is " + _fittingCursor.getPromptDelay()); 
     1271//        System.out.println("prompt start is " + _fittingCursor.getPromptStartValue() + " stop " + _fittingCursor.getPromptStopValue()); 
     1272//        System.out.println("_fittingCursor start value " + _fittingCursor.getTransientStartValue() + " bin " + _fittingCursor.getTransientStartBin() + " stop value " + _fittingCursor.getTransientStopValue() + " bin " + _fittingCursor.getTransientStopBin()); 
    12701273        return fitPixel(uiPanel, x, y); 
    12711274    } 
     
    13001303                photons += yCount[c]; 
    13011304            } 
    1302             System.out.println("PHOTONS " + photons); 
     1305//            System.out.println("PHOTONS " + photons); 
    13031306             
    13041307            curveFitData.setYCount(yCount); 
     
    13091312            curveFitData.setDataStartIndex(dataStartIndex); 
    13101313            curveFitData.setTransEndIndex(transStopIndex); 
    1311             System.out.println("uiPanel.getFunction is " + uiPanel.getAlgorithm() + " SLIMCURVE_RLD_LMA is " + FitAlgorithm.SLIMCURVE_RLD_LMA); 
     1314//            System.out.println("uiPanel.getFunction is " + uiPanel.getAlgorithm() + " SLIMCURVE_RLD_LMA is " + FitAlgorithm.SLIMCURVE_RLD_LMA); 
    13121315            
    13131316            yFitted = new double[m_bins]; 
     
    13291332         
    13301333        // show decay graph for visible channel 
    1331         String title = "Pixel " + x + " " + y; 
     1334        String title = "Fitted Pixel " + x + " " + y; 
    13321335        if (1 < m_channels) { 
    13331336            title += " Channel " + (m_channel + 1); 
     
    14571460        Image<DoubleType> image = null; 
    14581461 
    1459         System.out.println("channels width height params " + channels + " " + width + " " + height + " " + parameters); 
     1462//        System.out.println("channels width height params " + channels + " " + width + " " + height + " " + parameters); 
    14601463         
    14611464        // create image object 
     
    16701673            }             
    16711674            curveFitter.setInstrumentResponse(excitation); 
    1672         } 
     1675//            System.out.println("$$$ EXCITATION $$$"); 
     1676        } 
     1677//        else System.out.println("$$$ NO EXCITATION $$$"); 
    16731678        return curveFitter; 
    16741679    } 
     
    17651770             
    17661771            // look for changes, current vs. saved cursor values 
    1767             boolean refit = false; 
    17681772            if (null == _transStart 
    17691773                    || null == _dataStart 
     
    17781782                    || promptStop     != _promptStop 
    17791783                    || promptBaseline != _promptBaseline) { 
    1780                 refit = true; 
    1781             } 
    1782              
    1783             // trigger refit 
    1784             if (refit) {    
     1784                 
     1785                // trigger refit 
     1786                System.out.append("*** REFIT ***"); 
     1787   
    17851788                // update saved cursor values for next time 
    17861789                _transStart     = transStart; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/heuristics/CursorEstimator.java

    r7970 r7989  
    147147     */ 
    148148    public static int[] estimateDecayCursors(double xInc, double[] decay) { 
     149//        System.out.println("estimateDecayCursors"); 
    149150        int maxIndex = findMax(decay); 
    150151        double[] diffed = new double[maxIndex]; 
     
    175176    public static double[] estimateCursors(double xInc, double[] prompt, 
    176177            double[] decay, double chiSqTarget) { 
    177         System.out.println("xInc " + xInc + " prompt " + prompt + " decay " + decay + " chiSqTarget " + chiSqTarget); 
     178//        System.out.println("xInc " + xInc + " prompt " + prompt + " decay " + decay + " chiSqTarget " + chiSqTarget); 
    178179        double[] returnValue = new double[6]; 
    179180        double baseline; 
     
    269270        } 
    270271 
    271         System.out.println("steepest prompt " + steepp + " steepest transient " + steept); 
    272         System.out.println("startt is " + startt); 
    273         System.out.println("   startp " + startp + " endp " + endp + " baseline " + baseline); 
     272 //       System.out.println("steepest prompt " + steepp + " steepest transient " + steept); 
     273 //       System.out.println("startt is " + startt); 
     274 //       System.out.println("   startp " + startp + " endp " + endp + " baseline " + baseline); 
    274275 
    275276        // "Now we've got estimates we can do some Marquardt fitting to fine-tune 
     
    290291            returnValue[DATA_START]      = startt; 
    291292            returnValue[TRANSIENT_STOP]  = transEndIndex; 
    292              
     293            dump(returnValue); 
    293294            return returnValue; //TODO "do_estimate_resets; do_estimate_frees; " 
    294295        } 
    295296 
    296         System.out.println("prompt " + prompt.length + " decay " + decay.length); 
     297//        System.out.println("prompt " + prompt.length + " decay " + decay.length); 
    297298         
    298299        double[] adjustedPrompt = adjustPrompt(prompt, startp*xInc, endp*xInc, baseline, xInc); 
     
    301302 
    302303            transFitStartIndex = transStartIndex; 
    303             System.out.println("transStartIndex " + transStartIndex + " transFitStartIndex " + transFitStartIndex + " transEndIndex " + transEndIndex); 
     304//            System.out.println("transStartIndex " + transStartIndex + " transFitStartIndex " + transFitStartIndex + " transEndIndex " + transEndIndex); 
    304305 
    305306            int fitStart = transFitStartIndex - transStartIndex; // e.g. always zero 
    306307            int fitStop = transEndIndex - transStartIndex; 
    307308            int nData = transEndIndex - transStartIndex; 
    308             System.out.println("  fitStart " + fitStart + " fitStop " + fitStop + " nData " + nData); 
     309//            System.out.println("  fitStart " + fitStart + " fitStop " + fitStop + " nData " + nData); 
    309310 
    310311            CurveFitData curveFitData = new CurveFitData(); 
     
    338339            } 
    339340             
    340             System.out.println("i " + i + " Z " + param[1] + " A " + param[2] + " T " + param[3]); 
     341//            System.out.println("i " + i + " Z " + param[1] + " A " + param[2] + " T " + param[3]); 
    341342             
    342343            curveFitter.setFitAlgorithm(FitAlgorithm.SLIMCURVE_LMA); 
     
    345346 
    346347            if (ret >= 0) { 
    347                 System.out.println("for start " + fitStart + " stop " + fitStop + " chiSq is " + data[0].getChiSquare()); 
     348//                System.out.println("for start " + fitStart + " stop " + fitStop + " chiSq is " + data[0].getChiSquare()); 
    348349                chiSqTable[i] = data[0].getParams()[0]; //TODO ARG s/b same or better yet not kept in two places: data[0].getChiSquare(); 
    349350            } 
    350351            else { 
    351                 System.out.println("ret from fitData is " + ret); 
     352//                System.out.println("ret from fitData is " + ret); 
    352353                chiSqTable[i] = 1e10f; // "silly value" 
    353354            } 
     
    356357        // "Find the minimum chisq in this range" 
    357358        index = findMin(chiSqTable, 2 * ATTEMPTS + 1); 
    358         System.out.println("min chisq index is " + index + " value " + chiSqTable[index]); 
     359//        System.out.println("min chisq index is " + index + " value " + chiSqTable[index]); 
    359360         
    360361        if (chiSqTable[index] > 9e9f) {  // "no luck here..." 
    361             System.out.println("no luck here return"); 
    362             for (double chiSq : chiSqTable) { 
    363                 System.out.println("chiSq is " + chiSq); 
    364             } 
    365             System.out.println("index is " + index); 
     362//            System.out.println("no luck here return"); 
     363//            for (double chiSq : chiSqTable) { 
     364//                System.out.println("chiSq is " + chiSq); 
     365//            } 
     366//            System.out.println("index is " + index); 
    366367 
    367368            returnValue[PROMPT_START]    = startp; 
     
    371372            returnValue[DATA_START]      = startt; 
    372373            returnValue[TRANSIENT_STOP]  = transEndIndex; 
    373             System.out.print("1 "); 
     374//            System.out.print("1 "); 
    374375            dump(returnValue); 
    375376            return returnValue; //TODO do estimate resets/frees??? 
     
    392393        returnValue[DATA_START]      = transFitStartIndex; 
    393394        returnValue[TRANSIENT_STOP]  = transEndIndex; 
    394         System.out.print("2 "); 
     395//        System.out.print("2 "); 
    395396        dump(returnValue); 
    396397        return returnValue; 
     
    398399     
    399400    private static void dump(double[] value) { 
    400         System.out.print("prompt "); 
    401         System.out.print("start " + value[PROMPT_START]); 
    402         System.out.print("end " + value[PROMPT_STOP]); 
    403         System.out.print("transient "); 
    404         System.out.print("start " + value[TRANSIENT_START]); 
    405         System.out.print("data start " + value[DATA_START]); 
    406         System.out.println("end " + value[TRANSIENT_STOP]); 
     401//        System.out.print("prompt "); 
     402//        System.out.print("start " + value[PROMPT_START]); 
     403//        System.out.print("end " + value[PROMPT_STOP]); 
     404//        System.out.print("transient "); 
     405//        System.out.print("start " + value[TRANSIENT_START]); 
     406//        System.out.print("data start " + value[DATA_START]); 
     407//        System.out.println("end " + value[TRANSIENT_STOP]); 
     408        if (value[DATA_START] < value[TRANSIENT_START]) { 
     409            if (value[DATA_START] < 0.0) { 
     410                System.out.println("Calculated data start is less than zero!!!"); 
     411                value[DATA_START] = 0.0; 
     412                 
     413            } 
     414            double tmp = value[DATA_START]; 
     415            value[DATA_START] = value[TRANSIENT_START]; 
     416            value[TRANSIENT_START] = tmp; 
     417        } 
    407418    } 
    408419 
     
    423434        int startIndex = (int) Math.ceil(start / inc); 
    424435        int stopIndex = (int) Math.floor(stop / inc) + 1; 
    425         System.out.println("stop is " + stop + " stopIndex " + stopIndex); 
     436//        System.out.println("stop is " + stop + " stopIndex " + stopIndex); 
    426437        int length = stopIndex - startIndex; 
    427438        if (length <= 0) { 
     
    441452            adjusted[i - startIndex] = (prompt[i] - baseline) / scaling; 
    442453        } 
    443         System.out.println("adjusted " + adjusted[0] + " " + adjusted[1] + " " + adjusted[2]); 
     454//        System.out.println("adjusted " + adjusted[0] + " " + adjusted[1] + " " + adjusted[2]); 
    444455        return adjusted; 
    445456    } 
     
    570581    private static int findMax(double[] values, int startIndex, int endIndex) { 
    571582        if (endIndex > values.length) { 
    572             System.out.println("CursorEstimator.findMax endIndex is " + endIndex + " values.length is " + values.length); 
     583 //           System.out.println("CursorEstimator.findMax endIndex is " + endIndex + " values.length is " + values.length); 
    573584            endIndex = values.length; 
    574585        } 
    575586        if (startIndex > values.length) { 
    576             System.out.println("CursorEstimator.findMax startIndex is " + startIndex + " values.length is " + values.length); 
     587 //           System.out.println("CursorEstimator.findMax startIndex is " + startIndex + " values.length is " + values.length); 
    577588            startIndex = values.length; 
    578589        } 
    579590        if (values.length == 0) { 
    580             System.out.println("CursorEstimator.findMax but values is length zero"); 
     591 //           System.out.println("CursorEstimator.findMax but values is length zero"); 
    581592            return startIndex; 
    582593        } 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/ui/UserInterfacePanel.java

    r7983 r7989  
    660660                    String selectedItem = (String) _promptComboBox.getSelectedItem(); 
    661661                    boolean isExcitationLoaded = false; 
    662                     if (EXCITATION_NONE.equals(selectedItem)) { 
    663                         if (null != _listener) { 
    664                             _listener.cancelExcitation(); 
    665                         } 
    666                     } 
    667                     else if (EXCITATION_FILE.equals(selectedItem)) { 
     662                    if (EXCITATION_FILE.equals(selectedItem)) { 
    668663                        OpenDialog dialog = new OpenDialog("Load Excitation File", ""); 
    669664                        String directory = dialog.getDirectory(); 
     
    693688                        _promptBaselineField.setText("0.0"); 
    694689                        enablePromptCursors(false); 
     690                        if (null != _listener) { 
     691                            _listener.cancelExcitation(); 
     692                        } 
    695693                    } 
    696694                } 
Note: See TracChangeset for help on using the changeset viewer.