Skip to content

Commit

Permalink
Add test for number of OME-XML channels written by "bfconvert -channe…
Browse files Browse the repository at this point in the history
…l 1"
  • Loading branch information
melissalinkert committed Apr 11, 2024
1 parent 55d48a7 commit be40e04
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,21 @@
import java.util.ArrayList;
import java.util.Arrays;

import loci.common.services.ServiceFactory;
import loci.formats.ClassList;
import loci.formats.IFormatReader;
import loci.formats.ImageReader;
import loci.formats.ImageWriter;
import loci.formats.FormatException;
import loci.formats.meta.IMetadata;
import loci.formats.tools.ImageConverter;
import loci.formats.in.ICSReader;
import loci.formats.in.OMETiffReader;
import loci.formats.in.TiffDelegateReader;
import loci.formats.in.TiffReader;
import loci.formats.out.OMETiffWriter;
import loci.formats.services.OMEXMLService;
import loci.formats.tiff.TiffParser;

import org.apache.commons.lang.ArrayUtils;
import org.testng.annotations.AfterClass;
Expand Down Expand Up @@ -369,6 +373,27 @@ public void testConvertResolutions() throws FormatException, IOException {
assertConversion(args);
}

@Test
public void testConvertSingleChannel() throws FormatException, IOException {
outFile = getOutFile("single-channel.ome.tiff");
String[] args = {
"single-channel&sizeC=3.fake", "-channel", "1", outFile.getAbsolutePath()
};
assertConversion(args);

try (TiffParser parser = new TiffParser(outFile.getAbsolutePath())) {
String comment = parser.getComment();

final OMEXMLService service =
new ServiceFactory().getInstance(OMEXMLService.class);
IMetadata meta = service.createOMEXMLMetadata(comment);
assertEquals(meta.getChannelCount(0), 1);
}
catch (Exception e) {
throw new FormatException(e);
}
}

private Path getTempSubdir() throws IOException {
Path subdir = Files.createTempDirectory(tempDir, "ImageConverterTest");
subdir.toFile().deleteOnExit();
Expand Down

0 comments on commit be40e04

Please sign in to comment.