Skip to content

Commit

Permalink
Merge branch 'develop' into release_artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
dgault authored Feb 1, 2023
2 parents 68df260 + ff0cd76 commit c6cd3cc
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 83 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
strategy:
matrix:
java: [1.8, 11]
java: [1.8, 11, 17]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -20,3 +20,10 @@ jobs:
run: |
./tools/test-build ant
ant docs
- name: Upload artifacts
# upload just one set of artifacts for easier PR review
if: matrix.os == 'ubuntu-latest' && matrix.java == '1.8'
uses: actions/upload-artifact@v3
with:
path: artifacts/
retention-days: 30
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
strategy:
matrix:
java: [1.8, 11]
java: [1.8, 11, 17]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
Expand Down
2 changes: 2 additions & 0 deletions components/bio-formats-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<optional>true</optional>
</dependency>

<!-- NB: dependency:analyze has false warning about xml-apis:xml-apis. -->
Expand Down
2 changes: 2 additions & 0 deletions components/bio-formats-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<!-- NB: We want this, despite warning from dependency:analyze. -->
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<!-- NB: We want this, despite warning from dependency:analyze. -->
Expand Down
2 changes: 1 addition & 1 deletion components/formats-bsd/src/loci/formats/in/JPEGReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void close(boolean fileOnly) throws IOException {

// -- Helper reader --

static class DefaultJPEGReader extends ImageIOReader {
public static class DefaultJPEGReader extends ImageIOReader {
public DefaultJPEGReader() {
super("JPEG", new String[] {"jpg", "jpeg", "jpe"});
suffixNecessary = false;
Expand Down
3 changes: 1 addition & 2 deletions components/formats-gpl/src/loci/formats/in/CV7000Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public class CV7000Reader extends FormatReader {
// -- Fields --

private String[] allFiles;
private Location parent;
private MinimalTiffReader reader;
private String wppPath;
private String detailPath;
Expand Down Expand Up @@ -239,7 +238,7 @@ protected void initFile(String id) throws FormatException, IOException {
String wpiXML = readSanitizedXML(id);
XMLTools.parseXML(wpiXML, plate);

parent = new Location(id).getAbsoluteFile().getParentFile();
Location parent = new Location(id).getAbsoluteFile().getParentFile();
allFiles = parent.list(true);
Arrays.sort(allFiles);
for (int i=0; i<allFiles.length; i++) {
Expand Down
18 changes: 16 additions & 2 deletions components/formats-gpl/src/loci/formats/in/CellSensReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ public class CellSensReader extends FormatReader {
// -- Fields --

private String[] usedFiles;
// non-pixels files that are included in the directory (e.g. "blobs")
private ArrayList<String> extraFiles = new ArrayList<String>();
private HashMap<Integer, String> fileMap = new HashMap<Integer, String>();

private TiffParser parser;
Expand Down Expand Up @@ -451,7 +453,15 @@ public String[] getSeriesUsedFiles(boolean noPixels) {
FormatTools.assertId(currentId, true, 1);

// all files contain pixels
return noPixels ? null : usedFiles;
if (noPixels) {
return extraFiles.toArray(new String[extraFiles.size()]);
}
String[] allFiles = new String[extraFiles.size() + usedFiles.length];
System.arraycopy(usedFiles, 0, allFiles, 0, usedFiles.length);
for (int i=0; i<extraFiles.size(); i++) {
allFiles[usedFiles.length + i] = extraFiles.get(i);
}
return allFiles;
}

/* @see loci.formats.IFormatReader#getOptimalTileWidth() */
Expand Down Expand Up @@ -591,6 +601,7 @@ public void close(boolean fileOnly) throws IOException {
parser = null;
ifds = null;
usedFiles = null;
extraFiles.clear();
fileMap.clear();
tileOffsets.clear();
jpeg = false;
Expand Down Expand Up @@ -673,9 +684,12 @@ protected void initFile(String id) throws FormatException, IOException {
if (pixelsFiles != null) {
Arrays.sort(pixelsFiles);
for (String pixelsFile : pixelsFiles) {
if (checkSuffix(pixelsFile, "ets")) {
if (checkSuffix(pixelsFile, "ets") && pixelsFile.startsWith("frame_")) {
files.add(new Location(stackDir, pixelsFile).getAbsolutePath());
}
else {
extraFiles.add(new Location(stackDir, pixelsFile).getAbsolutePath());
}
}
}
}
Expand Down
48 changes: 21 additions & 27 deletions components/formats-gpl/src/loci/formats/in/CellVoyagerReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,17 @@ public class CellVoyagerReader extends FormatReader

private static final String SINGLE_TIFF_PATH_BUILDER = "W%dF%03dT%04dZ%02dC%d.tif";

private Location measurementFolder;
private Location imageFolder;
private String imageFolder;

private List< ChannelInfo > channelInfos;

private List< WellInfo > wells;

private List< Integer > timePoints;

private Location measurementResultFile;
private String measurementResultFile;

private Location omeMeasurementFile;
private String omeMeasurementFile;

public CellVoyagerReader()
{
Expand All @@ -148,8 +147,6 @@ public byte[] openBytes( final int no, final byte[] buf, final int x, final int
final AreaInfo area = well.areas.get( areaIndex );
final MinimalTiffReader tiffReader = new MinimalTiffReader();

imageFolder = new Location(currentId).getAbsoluteFile().getParentFile();
imageFolder = new Location(imageFolder, "Image");
for ( final FieldInfo field : area.fields )
{

Expand Down Expand Up @@ -274,7 +271,7 @@ protected void initFile( final String id ) throws FormatException, IOException
{
super.initFile( id );

measurementFolder = new Location( id ).getAbsoluteFile();
Location measurementFolder = new Location( id ).getAbsoluteFile();
if ( !measurementFolder.exists() ) { throw new IOException( "File " + id + " does not exist." ); }
if ( !measurementFolder.isDirectory() )
{
Expand All @@ -283,22 +280,26 @@ protected void initFile( final String id ) throws FormatException, IOException
measurementFolder = measurementFolder.getParentFile();
}
}
imageFolder = new Location(measurementFolder, "Image");
imageFolder = new Location(measurementFolder, "Image").getAbsolutePath();

measurementResultFile = new Location( measurementFolder, "MeasurementResult.xml" );
if ( !measurementResultFile.exists() ) { throw new IOException( "Could not find " + measurementResultFile + " in folder." ); }
Location measurementResult = new Location( measurementFolder, "MeasurementResult.xml" );
if ( !measurementResult.exists() ) { throw new IOException( "Could not find " + measurementResult + " in folder." ); }
else {
measurementResultFile = measurementResult.getAbsolutePath();
}

omeMeasurementFile = new Location( measurementFolder, "MeasurementResult.ome.xml" );
if ( !omeMeasurementFile.exists() ) { throw new IOException( "Could not find " + omeMeasurementFile + " in folder." ); }
Location omeMeasurement = new Location( measurementFolder, "MeasurementResult.ome.xml" );
if ( !omeMeasurement.exists() ) { throw new IOException( "Could not find " + omeMeasurement + " in folder." ); }
else {
omeMeasurementFile = omeMeasurement.getAbsolutePath();
}

/*
* Open MeasurementSettings file
*/

RandomAccessInputStream result =
new RandomAccessInputStream(measurementResultFile.getAbsolutePath());
Document msDocument = null;
try {
try (RandomAccessInputStream result = new RandomAccessInputStream(measurementResultFile)) {
msDocument = XMLTools.parseDOM(result);
}
catch (ParserConfigurationException e) {
Expand All @@ -307,9 +308,6 @@ protected void initFile( final String id ) throws FormatException, IOException
catch (SAXException e) {
throw new IOException(e);
}
finally {
result.close();
}

msDocument.getDocumentElement().normalize();

Expand All @@ -329,10 +327,9 @@ protected void initFile( final String id ) throws FormatException, IOException
* Open OME metadata file
*/

RandomAccessInputStream measurement =
new RandomAccessInputStream(omeMeasurementFile.getAbsolutePath());

Document omeDocument = null;
try {
try (RandomAccessInputStream measurement = new RandomAccessInputStream(omeMeasurementFile)) {
omeDocument = XMLTools.parseDOM(measurement);
}
catch (ParserConfigurationException e) {
Expand All @@ -341,9 +338,6 @@ protected void initFile( final String id ) throws FormatException, IOException
catch (SAXException e) {
throw new IOException(e);
}
finally {
measurement.close();
}
omeDocument.getDocumentElement().normalize();

/*
Expand All @@ -361,7 +355,7 @@ public String[] getSeriesUsedFiles( final boolean noPixels )

if ( noPixels )
{
return new String[] { measurementResultFile.getAbsolutePath(), omeMeasurementFile.getAbsolutePath() };
return new String[] { measurementResultFile, omeMeasurementFile };
}
else
{
Expand All @@ -371,8 +365,8 @@ public String[] getSeriesUsedFiles( final boolean noPixels )
final AreaInfo area = wells.get( wellIndex ).areas.get( areaIndex );
final int nFields = area.fields.size();
ArrayList<String> images = new ArrayList<String>();
images.add(measurementResultFile.getAbsolutePath());
images.add(omeMeasurementFile.getAbsolutePath());
images.add(measurementResultFile);
images.add(omeMeasurementFile);

for ( final Integer timepoint : timePoints )
{
Expand Down
70 changes: 47 additions & 23 deletions components/formats-gpl/src/loci/formats/in/LiFlimReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class LiFlimReader extends FormatReader {

// relevant keys in layout and background tables
public static final String DATATYPE_KEY = "datatype";
public static final String PACKING_KEY = "packing";
public static final String C_KEY = "channels";
public static final String X_KEY = "x";
public static final String Y_KEY = "y";
Expand Down Expand Up @@ -120,6 +121,7 @@ public class LiFlimReader extends FormatReader {
private String version;
private String compression;
private String datatype;
private String packing;
private String channels;
private String xLen;
private String yLen;
Expand Down Expand Up @@ -215,12 +217,14 @@ else if (TypeUINT12) {
UINT12stream.readFully(bytes);
}
catch (EOFException e) {
LOGGER.debug("Could not read full 12-bitt plane", e);
LOGGER.debug("Could not read full 12-bit plane", e);
}

//Covert 12bit data to 16bit data, maintaining 12bit depth.
// Covert 12bit data to 16bit data, maintaining 12bit depth.
// with msb packing convert in the order of most significant bit, otherwise use least significant bit
byte[] returnArray = new byte[0];
returnArray = convert12to16(bytes);
returnArray = packing.equals("msb") ?
convert12to16MSB(bytes) : convert12to16LSB(bytes);
RandomAccessInputStream s = new RandomAccessInputStream(returnArray);
readPlane(s, x, y, w, h, buf);
s.close();
Expand Down Expand Up @@ -255,6 +259,11 @@ public void close(boolean fileOnly) throws IOException {
version = null;
compression = null;
datatype = null;
packing = null;
if (UINT12stream != null) UINT12stream.close();
UINT12stream = null;
UINT12streamPos = 0;
UINT12streamSeries = 0;
channels = null;
xLen = null;
yLen = null;
Expand Down Expand Up @@ -310,6 +319,7 @@ private void initOriginalMetadata() {

IniTable layoutTable = ini.getTable(LAYOUT_TABLE);
datatype = layoutTable.get(DATATYPE_KEY);
packing = layoutTable.get(PACKING_KEY);
channels = layoutTable.get(C_KEY);
xLen = layoutTable.get(X_KEY);
yLen = layoutTable.get(Y_KEY);
Expand Down Expand Up @@ -572,10 +582,10 @@ private int getPixelTypeFromString(String type) throws FormatException {
else if (DATATYPE_REAL64.equals(type)) return FormatTools.DOUBLE;
/* Check for UINT12, set DataType to UINT16 because core does not support UINT12 */
else if (DATATYPE_UINT12.equals(type))
{
{
TypeUINT12 = true;
return FormatTools.UINT16;
}
}
throw new FormatException("Unknown data type: " + type);
}

Expand Down Expand Up @@ -667,25 +677,39 @@ else if (UINT12streamSeries == 1 && DarkImage != null && DarkImage.equals(new St

}

// Added a Function to unpack 12bit data to 16bit data maintaining 12bits depth.
private static byte[] convert12to16(byte[] image) {
byte[] image16 = new byte[image.length * 4 / 3];


if (image16.length / 4 != image.length / 3)
return new byte[0];

for (int idx = 0, idx16 = 0; idx < (image.length - 2) && (idx16 < image16.length - 3); idx += 3, idx16 += 4)
{
image16[idx16] = (byte)(image[idx] & 0xff);
image16[idx16 + 1] = (byte)((image[idx + 1] & 0x0f));
image16[idx16 + 2] = (byte)(((image[idx + 1] & 0xf0) >> 4) + ((image[idx + 2] & 0x0f) << 4));
image16[idx16 + 3] = (byte)((image[idx + 2] & 0xf0) >> 4);
}

return image16;
}
// Unpack 12bit data by least significant bit first to 16bit data maintaining 12bits depth.
private static byte[] convert12to16LSB(byte[] image) {
byte[] image16 = new byte[image.length * 4 / 3];

if (image16.length / 4 != image.length / 3)
return new byte[0];

for (int idx = 0, idx16 = 0; idx < (image.length - 2) && (idx16 < image16.length - 3); idx += 3, idx16 += 4) {
image16[idx16] = (byte)(image[idx] & 0xff);
image16[idx16 + 1] = (byte)((image[idx + 1] & 0x0f));
image16[idx16 + 2] = (byte)(((image[idx + 1] & 0xf0) >> 4) | ((image[idx + 2] & 0x0f) << 4));
image16[idx16 + 3] = (byte)((image[idx + 2] & 0xf0) >> 4);
}

return image16;
}

// Unpack 12bit data by most significant bit first to 16bit data maintaining 12bits depth.
private static byte[] convert12to16MSB(byte[] image) {
byte[] image16 = new byte[image.length * 4 / 3];

if (image16.length / 4 != image.length / 3)
return new byte[0];

for (int idx = 0, idx16 = 0; idx < (image.length - 2) && (idx16 < image16.length - 3); idx += 3, idx16 += 4) {
image16[idx16] = (byte)(((image[idx] & 0x0f) << 4) | ((image[idx + 1] & 0xf0) >> 4));
image16[idx16 + 1] = (byte)((image[idx] & 0xf0) >> 4);
image16[idx16 + 2] = (byte)((image[idx + 2] & 0xff));
image16[idx16 + 3] = (byte)((image[idx + 1]) & 0x0f);
}

return image16;
}

private void skip(InputStream is, long num) throws IOException {
long skipLeft = num;
Expand Down
Loading

0 comments on commit c6cd3cc

Please sign in to comment.