Skip to content

Commit

Permalink
OIRReader: fix reading of oir spectral (lambda) images
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKiaru committed Jul 19, 2024
1 parent 0bd9fa9 commit d7ccc56
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions components/formats-gpl/src/loci/formats/in/OIRReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h)
lastChannel = zct[1];

// Gets all the PixelBlock potentially contained within c, z and t
PixelBlock[] blocks = cztToPixelBlocks.get(new CZTKey((zct[1] % channels.size()), zct[0], zct[2]));
PixelBlock[] blocks = cztToPixelBlocks.get(new CZTKey(zct[1], zct[0], zct[2]));

if ((blocks == null) || (blocks.length == 0)) {
LOGGER.warn("No pixel blocks for plane #{}", no);
Expand Down Expand Up @@ -412,8 +412,9 @@ else if (!checkSuffix(id, "oir")) {
for (String uid: pixelBlocks.keySet()) {
int z = getZ(uid)-minZ;
int t = getT(uid)-minT;
int c = getC(uid);
int c = getC(uid) + getL(uid); // Channel index or lambda index (We suppose there's no multichannel + lambda);
int b = getBlock(uid);

CZTKey key = new CZTKey(c,z,t);
if (!cztToPixelBlocks.containsKey(key)) cztToPixelBlocks.put(key, new PixelBlock[maxNumberOfBlocks]);
PixelBlock pb = pixelBlocks.get(uid);
Expand Down Expand Up @@ -1536,6 +1537,14 @@ private int getBlock(String uid) {
return Integer.parseInt(uid.substring(index + 1));
}

private int getL(String uid) {
// for example l001z001t001_0_1_93e4632f-0342-4d98-bdc1-4ce305b92525_46
// Assumes l is always first is the uid...
if (!uid.startsWith("l")) return 0;
// ... and has 3 digits
return Integer.parseInt(uid.substring(1, 4)) - 1;
}

private boolean isCurrentFile(String file) {
String currentPath = new Location(currentId).getAbsolutePath();
return currentPath.equals(new Location(file).getAbsolutePath());
Expand Down

0 comments on commit d7ccc56

Please sign in to comment.