Changeset 7663


Ignore:
Timestamp:
03/21/11 20:26:18 (9 years ago)
Author:
aivar
Message:

Export to text working.

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

Legend:

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

    r7658 r7663  
    578578     */ 
    579579    private Image<DoubleType> fitSummed(IUserInterfacePanel uiPanel) { 
     580        Image<DoubleType> fittedPixels = null; 
    580581        double params[] = uiPanel.getParameters(); //TODO go cumulative 
    581582         
     
    626627        yFitted = new double[m_timeBins]; 
    627628        curveFitData.setYFitted(yFitted); 
     629        //int nominalChannel = (-1 == m_channel) ? channel : 0; 
     630        curveFitData.setChannel(0); 
     631        curveFitData.setX(0); 
     632        curveFitData.setY(0); 
    628633        curveFitDataList.add(curveFitData); 
    629634 
     
    635640        showDecayGraph("Summed ", uiPanel, dataArray, 0); 
    636641        uiPanel.setParameters(dataArray[0].getParams()); 
    637         return null; 
     642 
     643        // get the results 
     644        //int channels = (-1 == m_channel) ? m_channels : 1; //TODO s/b summed for each channel, rather than summing all channels together??? 
     645        //fittedPixels = makeImage(channels, 1, 1, uiPanel.getParameterCount()); //TODO ImgLib bug if you use 1, 1, 1, 4; see "imglibBug()" below. 
     646        fittedPixels = makeImage(2, 2, 2, uiPanel.getParameterCount()); //TODO this is a workaround; unused pixels will remain NaNs 
     647        LocalizableByDimCursor<DoubleType> resultsCursor = fittedPixels.createLocalizableByDimCursor(); 
     648        setFittedParamsFromData(resultsCursor, dataArray); 
     649        return fittedPixels; 
    638650    } 
    639651 
     
    642654     */ 
    643655    private Image<DoubleType> fitROIs(IUserInterfacePanel uiPanel) { 
     656        Image<DoubleType> fittedPixels = null; 
    644657        double params[] = uiPanel.getParameters(); 
    645658         
     
    651664         
    652665        int roiNumber = 1; 
     666        int channel = (-1 == m_channel) ? 0 : m_channel; //TODO better than crashing; need a better channel strategy 
     667        int outputX = 0; 
    653668        for (Roi roi: getRois()) { 
    654669            curveFitData = new CurveFitData(); 
     
    662677                for (int y = 0; y < bounds.height; ++y) { 
    663678                    if (roi.contains(bounds.x + x, bounds.y + y)) { 
    664                         System.out.println("roi " + roiNumber + " x " + x + " Y " + y); 
    665679                        for (int b = 0; b < m_timeBins; ++b) { 
    666                             yCount[b] += getData(m_cursor, m_channel, x, y, b); 
     680                            yCount[b] += getData(m_cursor, channel, x, y, b); 
    667681                        } 
    668682                    } 
     
    672686            yFitted = new double[m_timeBins]; 
    673687            curveFitData.setYFitted(yFitted); 
     688            curveFitData.setChannel(0); 
     689            curveFitData.setX(outputX++); 
     690            curveFitData.setY(0); 
    674691            curveFitDataList.add(curveFitData); 
    675692            ++roiNumber; 
     
    722739        // update UI parameters 
    723740        uiPanel.setParameters(dataArray[0].getParams()); //TODO, just picked first ROI here! 
    724         return null; 
     741 
     742        // get the results 
     743        //int channels = (-1 == m_channel) ? m_channels : 1; //TODO need a proper channel strategy 
     744        //fittedPixels = makeImage(channels, 1, 1, uiPanel.getParameterCount()); //TODO ImgLib bug if you use 1, 1, 1, 4; see "imglibBug()" below. 
     745        fittedPixels = makeImage(2, getRois().length + 1, 2, uiPanel.getParameterCount()); //TODO this is a workaround; unused pixels will remain NaNs 
     746        LocalizableByDimCursor<DoubleType> resultsCursor = fittedPixels.createLocalizableByDimCursor(); 
     747        setFittedParamsFromData(resultsCursor, dataArray); 
     748        return fittedPixels; 
    725749    } 
    726750 
     
    736760        // build the data 
    737761        ArrayList<ICurveFitData> curveFitDataList = new ArrayList<ICurveFitData>(); 
    738         double params[] = uiPanel.getParameters(); //TODO NO NO NO 
     762        double params[] = uiPanel.getParameters(); //TODO wrong; params should possibly come from already fitted data 
    739763        ICurveFitData curveFitData; 
    740764        double yCount[]; 
     
    742766        for (int channel : getChannelIndices(m_channel, m_channels)) { 
    743767            curveFitData = new CurveFitData(); 
    744             curveFitData.setParams(params); //TODO NO NO NO s/b either from UI or fitted point or fitted whole image 
     768            curveFitData.setParams(params.clone()); //TODO NO NO NO s/b either from UI or fitted point or fitted whole image 
    745769            yCount = new double[m_timeBins]; 
    746770            for (int b = 0; b < m_timeBins; ++b) { 
     
    750774            yFitted = new double[m_timeBins]; 
    751775            curveFitData.setYFitted(yFitted); 
    752             int nominalChannel = (-1 == m_channel) ? channel : 1; 
     776            int nominalChannel = (-1 == m_channel) ? channel : 0; 
    753777            curveFitData.setChannel(nominalChannel); 
    754778            curveFitData.setX(0); 
     
    771795        //fittedPixels = makeImage(channels, 1, 1, uiPanel.getParameterCount()); //TODO ImgLib bug if you use 1, 1, 1, 4; see "imglibBug()" below. 
    772796        fittedPixels = makeImage(channels + 1, 2, 2, uiPanel.getParameterCount()); //TODO this is a workaround; unused pixels will remain NaNs 
    773  
    774797        LocalizableByDimCursor<DoubleType> resultsCursor = fittedPixels.createLocalizableByDimCursor();                
    775798        setFittedParamsFromData(resultsCursor, dataArray); 
     
    777800    } 
    778801 
     802    /* 
     803     * Demonstrates a bug with ImgLib: 
     804     * //TODO fix it! 
     805     */ 
    779806    private void imglibBug() { 
    780807        int dim[] = { 1, 1, 1, 4 }; 
  • trunk/projects/slim-plugin/src/main/java/loci/slim/analysis/plugins/ExportToText.java

    r7658 r7663  
    9393 
    9494                // write headers 
    95                 if (channels > 1) { 
     95                if (channels > 2) { //TODO s/b 1; workaround for ImgLib bug -> always get 2 channels 
    9696                    writeChannelHeader(); 
    9797                } 
     
    138138                            //TODO distinguish between not fitted and error in fit! 
    139139                            if (!Double.isNaN(paramArray[0])) { 
    140                                 if (channels > 1) { 
     140                                if (channels > 2) { //TODO see above; this is a hacky workaround for a bug; s/b " > 1" 
    141141                                    writeChannel(c + 1); 
    142142                                } 
     
    150150                                        writeROI(x + 1); 
    151151                                        writeParams(function, paramArray); 
     152                                        break; 
    152153                                    case EACH: 
    153154                                        writeXY(x, y); 
     
    247248 
    248249    private void writeROI(int roi) throws IOException { 
    249         m_fileWriter.write(roi + '\t'); 
     250        m_fileWriter.write("" + roi + '\t'); 
    250251    } 
    251252 
Note: See TracChangeset for help on using the changeset viewer.