Skip to content

Commit

Permalink
Add populateMetadata method that takes a file name
Browse files Browse the repository at this point in the history
Importantly, this allows us to set the default creation date using the
file modification time when calling populatePixels(...) from a reader.
Previously, the default creation date was always set to "now", as the
file name passed to setDefaultCreationDate(...) was always null.

See #7319.
  • Loading branch information
melissalinkert committed Mar 7, 2012
1 parent d91f6e1 commit 4867101
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions components/scifio/src/loci/formats/MetadataTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,18 @@ public static void populatePixels(MetadataStore store, IFormatReader r,
int oldSeries = r.getSeries();
for (int i=0; i<r.getSeriesCount(); i++) {
r.setSeries(i);

String imageName = null;
if (doImageName) {
Location f = new Location(r.getCurrentFile());
imageName = f.getName();
}
String pixelType = FormatTools.getPixelTypeString(r.getPixelType());

populateMetadata(store, i, imageName, r.isLittleEndian(),
r.getDimensionOrder(), pixelType, r.getSizeX(), r.getSizeY(),
r.getSizeZ(), r.getSizeC(), r.getSizeT(), r.getRGBChannelCount());
populateMetadata(store, r.getCurrentFile(), i, imageName,
r.isLittleEndian(), r.getDimensionOrder(), pixelType, r.getSizeX(),
r.getSizeY(), r.getSizeZ(), r.getSizeC(), r.getSizeT(),
r.getRGBChannelCount());

try {
OMEXMLService service =
Expand Down Expand Up @@ -168,7 +169,7 @@ public static void populateMetadata(MetadataStore store, int series,
final String pixelType = FormatTools.getPixelTypeString(coreMeta.pixelType);
final int effSizeC = coreMeta.imageCount / coreMeta.sizeZ / coreMeta.sizeT;
final int samplesPerPixel = coreMeta.sizeC / effSizeC;
populateMetadata(store, series, imageName, coreMeta.littleEndian,
populateMetadata(store, null, series, imageName, coreMeta.littleEndian,
coreMeta.dimensionOrder, pixelType, coreMeta.sizeX, coreMeta.sizeY,
coreMeta.sizeZ, coreMeta.sizeC, coreMeta.sizeT, samplesPerPixel);
}
Expand All @@ -186,9 +187,28 @@ public static void populateMetadata(MetadataStore store, int series,
String imageName, boolean littleEndian, String dimensionOrder,
String pixelType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT,
int samplesPerPixel)
{
populateMetadata(store, null, series, imageName, littleEndian,
dimensionOrder, pixelType, sizeX, sizeY, sizeZ, sizeC, sizeT,
samplesPerPixel);
}

/**
* Populates the given {@link MetadataStore}, for the specified series, using
* the provided values.
* <p>
* After calling this method, the metadata store will be sufficiently
* populated for use with an {@link IFormatWriter} (assuming it is also a
* {@link MetadataRetrieve}).
* </p>
*/
public static void populateMetadata(MetadataStore store, String file,
int series, String imageName, boolean littleEndian, String dimensionOrder,
String pixelType, int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT,
int samplesPerPixel)
{
store.setImageID(createLSID("Image", series), series);
setDefaultCreationDate(store, null, series);
setDefaultCreationDate(store, file, series);
if (imageName != null) store.setImageName(imageName, series);
store.setPixelsID(createLSID("Pixels", series), series);
store.setPixelsBinDataBigEndian(!littleEndian, series, 0);
Expand Down

0 comments on commit 4867101

Please sign in to comment.