Changeset 3078


Ignore:
Timestamp:
08/10/07 16:05:44 (12 years ago)
Author:
curtis
Message:
  • Fix bug in dimension swapper with incorrect OME-XML Pixels population.
  • Throw IllegalArgumentException if invalid dimension order is specified.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/DimensionSwapper.java

    r3015 r3078  
    9090  public void swapDimensions(String order) { 
    9191    FormatTools.assertId(getCurrentFile(), true, 2); 
    92     if (order == null) return; 
     92 
     93    if (order == null) throw new IllegalArgumentException("order is null"); 
    9394 
    9495    String oldOrder = getDimensionOrder(); 
     96    if (order.equals(oldOrder)) return; 
    9597 
    96     if (order.equals(oldOrder)) return; 
     98    if (order.length() != 5) { 
     99      throw new IllegalArgumentException("order is unexpected length (" + 
     100        order.length() + ")"); 
     101    } 
     102 
     103    int newX = order.indexOf("X"); 
     104    int newY = order.indexOf("Y"); 
     105    int newZ = order.indexOf("Z"); 
     106    int newC = order.indexOf("C"); 
     107    int newT = order.indexOf("T"); 
     108 
     109    if (newX < 0) throw new IllegalArgumentException("X does not appear"); 
     110    if (newY < 0) throw new IllegalArgumentException("Y does not appear"); 
     111    if (newZ < 0) throw new IllegalArgumentException("Z does not appear"); 
     112    if (newC < 0) throw new IllegalArgumentException("C does not appear"); 
     113    if (newT < 0) throw new IllegalArgumentException("T does not appear"); 
     114 
     115    if (newX > 1) { 
     116      throw new IllegalArgumentException("X in unexpected position (" + 
     117        newX + ")"); 
     118    } 
     119    if (newY > 1) { 
     120      throw new IllegalArgumentException("Y in unexpected position (" + 
     121        newY + ")"); 
     122    } 
    97123 
    98124    int[] dims = new int[5]; 
    99125 
    100     int xndx = oldOrder.indexOf("X"); 
    101     int yndx = oldOrder.indexOf("Y"); 
    102     int zndx = oldOrder.indexOf("Z"); 
    103     int cndx = oldOrder.indexOf("C"); 
    104     int tndx = oldOrder.indexOf("T"); 
     126    int oldX = oldOrder.indexOf("X"); 
     127    int oldY = oldOrder.indexOf("Y"); 
     128    int oldZ = oldOrder.indexOf("Z"); 
     129    int oldC = oldOrder.indexOf("C"); 
     130    int oldT = oldOrder.indexOf("T"); 
    105131 
    106     dims[xndx] = getSizeX(); 
    107     dims[yndx] = getSizeY(); 
    108     dims[zndx] = getSizeZ(); 
    109     dims[cndx] = getSizeC(); 
    110     dims[tndx] = getSizeT(); 
     132    dims[oldX] = getSizeX(); 
     133    dims[oldY] = getSizeY(); 
     134    dims[oldZ] = getSizeZ(); 
     135    dims[oldC] = getSizeC(); 
     136    dims[oldT] = getSizeT(); 
    111137 
    112138    int series = getSeries(); 
    113139    CoreMetadata core = getCoreMetadata(); 
    114140 
    115     core.sizeX[series] = dims[order.indexOf("X")]; 
    116     core.sizeY[series] = dims[order.indexOf("Y")]; 
    117     core.sizeZ[series] = dims[order.indexOf("Z")]; 
    118     core.sizeC[series] = dims[order.indexOf("C")]; 
    119     core.sizeT[series] = dims[order.indexOf("T")]; 
     141    core.sizeX[series] = dims[newX]; 
     142    core.sizeY[series] = dims[newY]; 
     143    core.sizeZ[series] = dims[newZ]; 
     144    core.sizeC[series] = dims[newC]; 
     145    core.sizeT[series] = dims[newT]; 
    120146    core.currentOrder[series] = order; 
    121147 
    122148    MetadataStore store = getMetadataStore(); 
    123     store.setPixels(new Integer(dims[xndx]), new Integer(dims[yndx]), 
    124       new Integer(dims[zndx]), new Integer(dims[cndx]), 
    125       new Integer(dims[tndx]), null, null, order, new Integer(series), null); 
     149    store.setPixels(new Integer(dims[newX]), new Integer(dims[newY]), 
     150      new Integer(dims[newZ]), new Integer(dims[newC]), 
     151      new Integer(dims[newT]), null, null, order, new Integer(series), null); 
    126152  } 
    127153 
Note: See TracChangeset for help on using the changeset viewer.