Skip to content

Commit

Permalink
Avoid caching data when determining pixel type in initFile
Browse files Browse the repository at this point in the history
  • Loading branch information
marcobitplane authored Dec 3, 2024
1 parent 50de137 commit d742ade
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion components/formats-gpl/src/loci/formats/in/ImarisHDFReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ protected void initFile(String id) throws FormatException, IOException {

int type = -1;

Object pix = getImageData(0, 0, 0, 1, 1);
Object pix = getSampleData();
if (pix instanceof byte[][]) type = FormatTools.UINT8;
else if (pix instanceof short[][]) type = FormatTools.UINT16;
else if (pix instanceof int[][]) type = FormatTools.UINT32;
Expand Down Expand Up @@ -579,6 +579,24 @@ else if (buffer[zct[1]] instanceof float[][][]) {
return image;
}

private Object getSampleData()
throws FormatException
{
int resolutionIndex = getCoreIndex();
Object image = null;
int[] dimensions = new int[] {1, 2, 2};
int[] indices = new int[] {0, 0, 0};
try {
String path = "/DataSet/ResolutionLevel_" + resolutionIndex + "/TimePoint_0/Channel_0/Data";
image = netcdf.getArray(path, indices, dimensions);
}
catch (ServiceException e) {
throw new FormatException(e);
}

return image;
}

private void parseAttributes() {
final List<String> attributes = netcdf.getAttributeList();
CoreMetadata ms0 = core.get(0, 0);
Expand Down

0 comments on commit d742ade

Please sign in to comment.