Skip to content

Commit

Permalink
Several minor bugfixes. Closes #430.
Browse files Browse the repository at this point in the history
  • Loading branch information
melissalinkert committed Nov 4, 2009
1 parent 106d4dd commit e93a5bc
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
5 changes: 3 additions & 2 deletions components/bio-formats/src/loci/formats/FileStitcher.java
Expand Up @@ -924,12 +924,13 @@ protected void initFile(String id) throws FormatException, IOException {

fp = findPattern(currentId);

reader.setId(fp.getFiles()[0]);
if (reader.fileGroupOption(fp.getFiles()[0]) == FormatTools.MUST_GROUP) {
if (reader.fileGroupOption(id) == FormatTools.MUST_GROUP) {
// reader subclass is handling file grouping
noStitch = true;
reader.setId(currentId);
return;
}
reader.setId(fp.getFiles()[0]);

AxisGuesser guesser = new AxisGuesser(fp, reader.getDimensionOrder(),
reader.getSizeZ(), reader.getSizeT(), reader.getEffectiveSizeC(),
Expand Down
Expand Up @@ -143,7 +143,7 @@ public boolean isThisType(RandomAccessInputStream stream) throws IOException {

/* @see loci.formats.IFormatReader#fileGroupOption(String) */
public int fileGroupOption(String id) throws FormatException, IOException {
Location parent = new Location(id).getParentFile();
Location parent = new Location(id).getAbsoluteFile().getParentFile();
String[] list = parent.list();
for (String f : list) {
if (checkSuffix(f, "raw") || checkSuffix(f, "xml")) {
Expand Down
23 changes: 17 additions & 6 deletions components/bio-formats/src/loci/formats/in/InCellReader.java
Expand Up @@ -426,10 +426,16 @@ protected void initFile(String id) throws FormatException, IOException {
store.setLogicalChannelName(channelNames.get(q), i, q);
}
if (q < emWaves.size()) {
store.setLogicalChannelEmWave(emWaves.get(q), i, q);
int wave = emWaves.get(q).intValue();
if (wave > 0) {
store.setLogicalChannelEmWave(emWaves.get(q), i, q);
}
}
if (q < exWaves.size()) {
store.setLogicalChannelExWave(exWaves.get(q), i, q);
int wave = exWaves.get(q).intValue();
if (wave > 0) {
store.setLogicalChannelExWave(exWaves.get(q), i, q);
}
}
}
}
Expand All @@ -447,12 +453,17 @@ protected void initFile(String id) throws FormatException, IOException {
for (int i=0; i<seriesCount; i++) {
int well = getWellFromSeries(i);
int field = getFieldFromSeries(i);
int totalTimepoints =
oneTimepointPerSeries ? channelsPerTimepoint.size() : 1;
int timepoint = i % totalTimepoints;

int sampleIndex = field * totalTimepoints + timepoint;

String imageID = MetadataTools.createLSID("Image", i);
store.setWellSampleIndex(new Integer(i), 0, well, field);
store.setWellSampleImageRef(imageID, 0, well, field);
store.setWellSamplePosX(posX.get(field), 0, well, field);
store.setWellSamplePosY(posY.get(field), 0, well, field);
store.setWellSampleIndex(new Integer(i), 0, well, sampleIndex);
store.setWellSampleImageRef(imageID, 0, well, sampleIndex);
store.setWellSamplePosX(posX.get(field), 0, well, sampleIndex);
store.setWellSamplePosY(posY.get(field), 0, well, sampleIndex);
}

// populate ROI data
Expand Down
Expand Up @@ -741,7 +741,12 @@ protected void initStandardMetadata() throws FormatException, IOException {
parseUIC1Tags(uic1tagEntry.getValueOffset(),
uic1tagEntry.getValueCount());
in.seek(uic4tagEntry.getValueOffset());
}
catch (IllegalArgumentException exc) { traceDebug(exc); } // unknown tag
catch (NullPointerException exc) { traceDebug(exc); }
catch (IOException exc) { traceDebug(exc); }

try {
// copy ifds into a new array of Hashtables that will accommodate the
// additional image planes
IFD firstIFD = ifds.get(0);
Expand Down Expand Up @@ -819,7 +824,6 @@ protected void initStandardMetadata() throws FormatException, IOException {
}
catch (IllegalArgumentException exc) { traceDebug(exc); } // unknown tag
catch (NullPointerException exc) { traceDebug(exc); }
catch (IOException exc) { traceDebug(exc); }
catch (FormatException exc) { traceDebug(exc); }

// parse (mangle) TIFF comment
Expand Down Expand Up @@ -937,6 +941,7 @@ void parseUIC2Tags(long uic2offset) throws IOException {

for (int i=0; i<mmPlanes; i++) {
iAsString = intFormatMax(i, mmPlanes);
if (in.getFilePointer() + 8 > in.length()) break;
zDistances[i] = readRational(in).doubleValue();
addSeriesMeta("zDistance[" + iAsString + "]", zDistances[i]);

Expand Down Expand Up @@ -971,6 +976,7 @@ void parseUIC2Tags(long uic2offset) throws IOException {
private void parseUIC4Tags(long uic4offset) throws IOException {
long saveLoc = in.getFilePointer();
in.seek(uic4offset);
if (in.getFilePointer() + 2 >= in.length()) return;
short id = in.readShort();
while (id != 0) {
switch (id) {
Expand Down
Expand Up @@ -822,7 +822,7 @@ else if ((block instanceof DetectionChannel) && i > 0) {
}
int nLogicalChannels = nextDataChannel == 0 ? 1 : nextDataChannel;
if (nLogicalChannels == getSizeC()) {
splitPlanes = isRGB();
if (!splitPlanes) splitPlanes = isRGB();
core[series].rgb = false;
if (splitPlanes) core[series].imageCount *= getSizeC();
}
Expand Down
Expand Up @@ -963,7 +963,9 @@ private void parseROIs(int imageNum, RandomAccessInputStream s,
}

s.seek(nameBlock);
String roiName = DataTools.stripString(s.readString(s.readInt()));
int strlen = s.readInt();
if (strlen + s.getFilePointer() > s.length()) continue;
String roiName = DataTools.stripString(s.readString(strlen));

s.seek(fontBlock);
int fontLength = s.readInt();
Expand Down

0 comments on commit e93a5bc

Please sign in to comment.