Metadata woes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Metadata woes

ChrisB14
I am having a bit of a problem with TIFF headers/metadata. I am acquiring images using a laser scanning microscope and the acquisition system stores the complete measurement setup as key:value pairs in the metadata. I use this to help set up the further downstream analysis. Recently I started integrating ImageJ (or FIJI) into my workflow for some preliminary data processing (image registration, etc.). When I save the processed tiff, the metadata is lost.

I wrote a quick macro that uses getMetadata() and setMetadata() to copy the header information. To a certain level this appears to work: "Show Info ..." includes the added metadata and when loading the file using BioFormats the metadata is displayed as well. But, when loading it into other analysis software the metadata isn't found. I have looked at the files with hex editor and found that ImageJ creates a first metadata block specifying the ImageJ version that created the file along with some image stats close to the top of the file. The rest of the metadata is stored further downstream, separated from the first block by a binary block.

I suspect the problem is that other software simply takes the first text block as metadata and ignores everything after that. The solution would be to get ImageJ to write all the metadata into a single text block, but I haven't even been able to get access to that first text block from within ImageJ.

I have a feeling this has been solved before, but all the related information I have found on the web over the past few days hasn't brought me a step closer to resolving the problem. If anyone has any suggestions on how solve this, I would be more than grateful.

Best regards, Chris
Reply | Threaded
Open this post in threaded view
|

Re: Metadata woes

ctrueden
Hi Chris,

> I am having a bit of a problem with TIFF headers/metadata.

I think it is important to understand the internal structure of the TIFF.

I wrote an ImageJ plugin to dump the tags of a TIFF:
http://imagej.net/plugins/tiff-dumper.html

Alternately, if you install libtiff [1], you can use the tiffdump command
line tool to achieve a similar (almost certainly more thorough) result.

> when loading it into other analysis software the metadata isn't found.

It really depends on A) where the metadata is being saved; and B) which
other software you are using, and where it looks for said metadata.

> The solution would be to get ImageJ to write all the metadata into a
> single text block, but I haven't even been able to get access to that
> first text block from within ImageJ.

For what it's worth, the Bio-Formats library can efficiently overwrite an
existing TIFF file's comment field (i.e., the first IFD's ImageDescription
directory entry). Bio-Formats ships with Fiji, so if you use that, you can
write a script or plugin using the following code snippet:

        RandomAccessInputStream in = new RandomAccessInputStream(file);
        RandomAccessOutputStream out = new RandomAccessOutputStream(file);
        TiffSaver saver = new TiffSaver(out, file);
        saver.overwriteComment(in, newComment);
        in.close();
        out.close();

So you could save your metadata to the TIFF comment manually in this way,
if the other software you want to use will indeed read this text block as
you hope.

Regards,
Curtis

[1] E.g., "brew install libtiff" with Homebrew on OS X, or "sudo apt-get
install libtiff4" on Ubuntu.



On Thu, Jan 16, 2014 at 5:58 AM, ChrisB14 <[hidden email]> wrote:

> I am having a bit of a problem with TIFF headers/metadata. I am acquiring
> images using a laser scanning microscope and the acquisition system stores
> the complete measurement setup as key:value pairs in the metadata. I use
> this to help set up the further downstream analysis. Recently I started
> integrating ImageJ (or FIJI) into my workflow for some preliminary data
> processing (image registration, etc.). When I save the processed tiff, the
> metadata is lost.
>
> I wrote a quick macro that uses getMetadata() and setMetadata() to copy the
> header information. To a certain level this appears to work: "Show Info
> ..."
> includes the added metadata and when loading the file using BioFormats the
> metadata is displayed as well. But, when loading it into other analysis
> software the metadata isn't found. I have looked at the files with hex
> editor and found that ImageJ creates a first metadata block specifying the
> ImageJ version that created the file along with some image stats close to
> the top of the file. The rest of the metadata is stored further downstream,
> separated from the first block by a binary block.
>
> I suspect the problem is that other software simply takes the first text
> block as metadata and ignores everything after that. The solution would be
> to get ImageJ to write all the metadata into a single text block, but I
> haven't even been able to get access to that first text block from within
> ImageJ.
>
> I have a feeling this has been solved before, but all the related
> information I have found on the web over the past few days hasn't brought
> me
> a step closer to resolving the problem. If anyone has any suggestions on
> how
> solve this, I would be more than grateful.
>
> Best regards, Chris
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/Metadata-woes-tp5006141.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html