Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zeiss CZI: fix dimension calculations when expected planes are missing #1386

Merged
merged 3 commits into from
Nov 4, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 7 additions & 14 deletions components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public String[] getSeriesUsedFiles(boolean noPixels) {
return null;
}
else if (noPixels) {
return new String[] {currentId};
return null;
}
String[] files = new String[pixels.size() + 1];
files[0] = currentId;
Expand Down Expand Up @@ -305,6 +305,7 @@ public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h)
}
int previousHeight = 0;

Arrays.fill(buf, (byte) 0);
RandomAccessInputStream stream = new RandomAccessInputStream(currentId);
try {
for (SubBlock plane : planes) {
Expand Down Expand Up @@ -646,9 +647,6 @@ protected void initFile(String id) throws FormatException, IOException {
seriesCount /= positions;
positions = 1;
}
else {
ms0.sizeT = 1;
}
}
else if (planes.size() == ms0.sizeT || planes.size() == ms0.imageCount ||
(!isGroupFiles() && positions > 1))
Expand All @@ -659,14 +657,6 @@ else if (planes.size() == ms0.sizeT || planes.size() == ms0.imageCount ||
angles = 1;
seriesCount = 1;
}
ms0.imageCount = getSizeZ() * (isRGB() ? 1 : getSizeC()) * getSizeT();

int newCount = planes.size() / ms0.imageCount;
if (planes.size() - (ms0.imageCount * newCount) <
ms0.imageCount * seriesCount - planes.size() && (planes.size() % seriesCount) != 0)
{
seriesCount = newCount;
}
}

if (seriesCount > 1) {
Expand Down Expand Up @@ -983,6 +973,8 @@ private void calculateDimensions() {
// calculate the dimensions
CoreMetadata ms0 = core.get(0);

ArrayList<Integer> uniqueT = new ArrayList<Integer>();

for (SubBlock plane : planes) {
for (DimensionEntry dimension : plane.directoryEntry.dimensionEntries) {
if (dimension == null) {
Expand Down Expand Up @@ -1025,8 +1017,9 @@ else if (dimension.size > getSizeZ()) {
}
break;
case 'T':
if (dimension.start >= getSizeT()) {
ms0.sizeT = dimension.start + 1;
if (!uniqueT.contains(dimension.start)) {
uniqueT.add(dimension.start);
ms0.sizeT = uniqueT.size();
}
if (dimension.size > getSizeT()) {
ms0.sizeT = dimension.size;
Expand Down