Changeset 3316


Ignore:
Timestamp:
10/26/07 08:52:48 (12 years ago)
Author:
melissa
Message:

Reorganized MetadataStore population logic - calls to setLogicalChannel need to happen *after* call to setPixels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/ImarisHDFReader.java

    r3311 r3316  
    7070  private byte[][][] previousImage; 
    7171  private int previousImageNumber; 
    72   private String[] channelParameters; 
     72  private Vector channelParameters; 
    7373 
    7474  // -- Constructor -- 
     
    150150    previousImageNumber = -1; 
    151151    MetadataStore store = getMetadataStore(); 
     152    store.setImage(currentId, null, null, null); 
    152153 
    153154    try { 
     
    166167    findGroup("DataSet", "root", "dataSet"); 
    167168 
    168     channelParameters = new String[8]; 
     169    channelParameters = new Vector(); 
    169170 
    170171    try { 
     
    189190 
    190191    FormatTools.populatePixels(store, this); 
     192 
     193    for (int i=0; i<core.sizeC[0]; i++) { 
     194      String[] params = (String[]) channelParameters.get(i); 
     195 
     196      Float gainValue = null; 
     197      try { gainValue = new Float(params[0]); } 
     198      catch (NumberFormatException e) { } 
     199      catch (NullPointerException e) { } 
     200      Integer pinholeValue = null, emWaveValue = null, exWaveValue = null; 
     201      try { pinholeValue = new Integer(params[5]); } 
     202      catch (NumberFormatException e) { } 
     203      catch (NullPointerException e) { } 
     204      try { emWaveValue = new Integer(params[1]); } 
     205      catch (NumberFormatException e) { } 
     206      catch (NullPointerException e) { } 
     207      try { exWaveValue = new Integer(params[2]); } 
     208      catch (NumberFormatException e) { } 
     209      catch (NullPointerException e) { } 
     210 
     211      store.setLogicalChannel(i, params[6], null, 
     212        null, null, null, null, null, null, null, gainValue, null, 
     213        pinholeValue, null, params[7], null, null, null, null, 
     214        null, emWaveValue, exWaveValue, null, null, null); 
     215 
     216      Double minValue = null, maxValue = null; 
     217      try { minValue = new Double(params[4]); } 
     218      catch (NumberFormatException exc) { } 
     219      catch (NullPointerException exc) { } 
     220      try { maxValue = new Double(params[3]); } 
     221      catch (NumberFormatException exc) { } 
     222      catch (NullPointerException exc) { } 
     223 
     224      if (minValue != null && maxValue != null) { 
     225        store.setChannelGlobalMinMax(i, minValue, maxValue, null); 
     226      } 
     227    } 
    191228  } 
    192229 
     
    254291      r.exec("attributes = group.getAttributes()"); 
    255292      List l = (List) r.getVar("attributes"); 
     293      String[] params = new String[8]; 
    256294      for (int j=0; j<l.size(); j++) { 
    257295        r.setVar("attr", l.get(j)); 
     
    260298        String v = getValue("group", (String) r.getVar("name")); 
    261299        if (groupName.startsWith("Channel_")) { 
    262           if (name.equals("Gain")) channelParameters[0] = v; 
    263           else if (name.equals("LSMEmissionWavelength")) { 
    264             channelParameters[1] = v; 
    265           } 
    266           else if (name.equals("LSMExcitationWavelength")) { 
    267             channelParameters[2] = v; 
    268           } 
    269           else if (name.equals("Max")) channelParameters[3] = v; 
    270           else if (name.equals("Min")) channelParameters[4] = v; 
    271           else if (name.equals("Pinhole")) channelParameters[5] = v; 
    272           else if (name.equals("Name")) channelParameters[6] = v; 
    273           else if (name.equals("MicroscopyMode")) channelParameters[7] = v; 
     300          if (name.equals("Gain")) params[0] = v; 
     301          else if (name.equals("LSMEmissionWavelength")) params[1] = v; 
     302          else if (name.equals("LSMExcitationWavelength")) params[2] = v; 
     303          else if (name.equals("Max")) params[3] = v; 
     304          else if (name.equals("Min")) params[4] = v; 
     305          else if (name.equals("Pinhole")) params[5] = v; 
     306          else if (name.equals("Name")) params[6] = v; 
     307          else if (name.equals("MicroscopyMode")) params[7] = v; 
    274308        } 
    275309      } 
     
    277311      if (groupName.indexOf("/Channel_") != -1) { 
    278312        for (int j=0; j<6; j++) { 
    279           if (channelParameters[j] != null) { 
    280             if (channelParameters[j].indexOf(" ") != -1) { 
    281               channelParameters[j] = channelParameters[j].substring( 
    282                 channelParameters[j].indexOf(" ") + 1); 
     313          if (params[j] != null) { 
     314            if (params[j].indexOf(" ") != -1) { 
     315              params[j] = params[j].substring(params[j].indexOf(" ") + 1); 
    283316            } 
    284             if (channelParameters[j].indexOf("-") != -1) { 
    285               int idx = channelParameters[j].indexOf("-"); 
    286               float a = 
    287                 Float.parseFloat(channelParameters[j].substring(0, idx)); 
    288               float b = 
    289                 Float.parseFloat(channelParameters[j].substring(idx + 1)); 
    290               channelParameters[j] = "" + ((int) (b - a)); 
     317            if (params[j].indexOf("-") != -1) { 
     318              int idx = params[j].indexOf("-"); 
     319              float a = Float.parseFloat(params[j].substring(0, idx)); 
     320              float b = Float.parseFloat(params[j].substring(idx + 1)); 
     321              params[j] = "" + ((int) (b - a)); 
    291322            } 
    292             if (channelParameters[j].indexOf(".") != -1) { 
    293               channelParameters[j] = channelParameters[j].substring(0, 
    294                 channelParameters[j].indexOf(".")); 
     323            if (params[j].indexOf(".") != -1) { 
     324              params[j] = params[j].substring(0, params[j].indexOf(".")); 
    295325            } 
    296326          } 
    297327        } 
    298328 
    299         Float gainValue = null; 
    300         try { gainValue = new Float(channelParameters[0]); } 
    301         catch (NumberFormatException e) { } 
    302         catch (NullPointerException e) { } 
    303         Integer pinholeValue = null, emWaveValue = null, exWaveValue = null; 
    304         try { pinholeValue = new Integer(channelParameters[5]); } 
    305         catch (NumberFormatException e) { } 
    306         catch (NullPointerException e) { } 
    307         try { emWaveValue = new Integer(channelParameters[1]); } 
    308         catch (NumberFormatException e) { } 
    309         catch (NullPointerException e) { } 
    310         try { exWaveValue = new Integer(channelParameters[2]); } 
    311         catch (NumberFormatException e) { } 
    312         catch (NullPointerException e) { } 
    313  
    314         MetadataStore store = getMetadataStore(); 
    315         store.setLogicalChannel(core.sizeC[0], channelParameters[6], null, 
    316           null, null, null, null, null, null, null, gainValue, null, 
    317           pinholeValue, null, channelParameters[7], null, null, null, null, 
    318           null, emWaveValue, exWaveValue, null, null, null); 
    319  
    320         Double minValue = null, maxValue = null; 
    321         try { minValue = new Double(channelParameters[4]); } 
    322         catch (NumberFormatException exc) { } 
    323         catch (NullPointerException exc) { } 
    324         try { maxValue = new Double(channelParameters[3]); } 
    325         catch (NumberFormatException exc) { } 
    326         catch (NullPointerException exc) { } 
    327  
    328         store.setChannelGlobalMinMax(core.sizeC[0], minValue, maxValue, null); 
    329  
     329        channelParameters.add(params); 
    330330        core.sizeC[0]++; 
    331331      } 
Note: See TracChangeset for help on using the changeset viewer.