Skip to content

Commit 6fa35f6

Browse files
authored
Merge pull request #4147 from TBlackmore/develop
Added support for ColumbusReader to import data with z stacks
2 parents 79e97b3 + f7da097 commit 6fa35f6

1 file changed

Lines changed: 30 additions & 10 deletions

File tree

components/formats-gpl/src/loci/formats/in/ColumbusReader.java

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h)
186186
Plane p = null;
187187
for (Plane plane : planes) {
188188
if (plane.series == getSeries() && plane.timepoint == zct[2] &&
189-
plane.channel == zct[1])
189+
plane.channel == zct[1] && plane.z == zct[0])
190190
{
191191
p = plane;
192192
break;
@@ -287,6 +287,9 @@ public int compare(Plane p1, Plane p2) {
287287
if (p1.channel != p2.channel) {
288288
return p1.channel - p2.channel;
289289
}
290+
if (p1.z != p2.z) {
291+
return p1.z - p2.z;
292+
}
290293

291294
return 0;
292295
}
@@ -303,6 +306,7 @@ public int compare(Plane p1, Plane p2) {
303306

304307
m.sizeC = 0;
305308
m.sizeT = 0;
309+
m.sizeZ = 0;
306310

307311
ArrayList<Integer> uniqueSamples = new ArrayList<Integer>();
308312
ArrayList<Integer> uniqueRows = new ArrayList<Integer>();
@@ -332,10 +336,12 @@ public int compare(Plane p1, Plane p2) {
332336
if (p.timepoint >= getSizeT()) {
333337
m.sizeT = p.timepoint + 1;
334338
}
335-
339+
if (p.z >= getSizeZ()) {
340+
m.sizeZ = p.z + 1;
341+
}
336342
}
337343

338-
m.sizeZ = 1;
344+
339345
m.imageCount = getSizeZ() * getSizeC() * getSizeT();
340346
m.dimensionOrder = "XYCTZ";
341347
m.rgb = false;
@@ -376,7 +382,7 @@ public int compare(Plane p1, Plane p2) {
376382
store.setWellColumn(new NonNegativeInteger(col), 0, nextWell);
377383

378384
for (int field=0; field<nFields; field++) {
379-
Plane p = lookupPlane(row, col, field, 0, 0);
385+
Plane p = lookupPlane(row, col, field, 0, 0, 0);
380386
String wellSampleID = MetadataTools.createLSID("WellSample", 0, nextWell, field);
381387
store.setWellSampleID(wellSampleID, 0, nextWell, field);
382388
store.setWellSampleIndex(new NonNegativeInteger(wellSample), 0, nextWell, field);
@@ -401,7 +407,7 @@ public int compare(Plane p1, Plane p2) {
401407
store.setPixelsPhysicalSizeY(FormatTools.getPhysicalSizeY(p.sizeY), p.series);
402408

403409
for (int c=0; c<getSizeC(); c++) {
404-
p = lookupPlane(row, col, field, 0, c);
410+
p = lookupPlane(row, col, field, 0, c, 0);
405411
if (p != null) {
406412
p.series = wellSample;
407413
store.setChannelName(p.channelName, p.series, p.channel);
@@ -417,11 +423,21 @@ public int compare(Plane p1, Plane p2) {
417423
}
418424

419425
for (int t=0; t<getSizeT(); t++) {
420-
p = lookupPlane(row, col, field, t, c);
426+
p = lookupPlane(row, col, field, t, c, 0);
421427
if (p != null) {
422428
p.series = wellSample;
423429
store.setPlaneDeltaT(new Time(p.deltaT - timestampSeconds, UNITS.SECOND), p.series, getIndex(0, c, t));
424430
}
431+
for (int z=0; z<getSizeZ(); z++) {
432+
p = lookupPlane(row, col, field, t, c, z);
433+
if (p != null) {
434+
p.series = wellSample;
435+
436+
store.setPlanePositionX(new Length(p.positionX, UNITS.REFERENCEFRAME), p.series, getIndex(z, c, t));
437+
store.setPlanePositionY(new Length(p.positionY, UNITS.REFERENCEFRAME), p.series, getIndex(z, c, t));
438+
store.setPlanePositionZ(new Length(p.positionZ, UNITS.REFERENCEFRAME), p.series, getIndex(z, c, t));
439+
}
440+
}
425441
}
426442
}
427443
}
@@ -504,6 +520,9 @@ else if (name.equals("Col")) {
504520
else if (name.equals("FieldID")) {
505521
p.field = Integer.parseInt(value) - 1;
506522
}
523+
else if (name.equals("PlaneID")) {
524+
p.z = Integer.parseInt(value) - 1;
525+
}
507526
else if (name.equals("TimepointID")) {
508527
p.timepoint = Integer.parseInt(value) - 1;
509528
if (p.timepoint == 0) {
@@ -584,16 +603,16 @@ else if (unit.equals("nm")) {
584603
return v;
585604
}
586605

587-
private Plane lookupPlane(int row, int col, int field, int t, int c) {
606+
private Plane lookupPlane(int row, int col, int field, int t, int c, int z) {
588607
for (Plane p : planes) {
589608
if (p.row == row && p.col == col && p.field == field &&
590-
p.timepoint == t && p.channel == c)
609+
p.timepoint == t && p.channel == c && p.z == z)
591610
{
592611
return p;
593612
}
594613
}
595-
LOGGER.warn("Could not find plane for row={}, column={}, field={}, t={}, c={}",
596-
new Object[] {row, col, field, t, c});
614+
LOGGER.warn("Could not find plane for row={}, column={}, field={}, t={}, c={}, z={}",
615+
new Object[] {row, col, field, t, c, z});
597616
return null;
598617
}
599618

@@ -725,6 +744,7 @@ class Plane {
725744
public int field;
726745
public int timepoint;
727746
public int channel;
747+
public int z;
728748
public double deltaT;
729749
public double emWavelength;
730750
public double exWavelength;

0 commit comments

Comments
 (0)