Extracting .tif Metadata from SEM image?

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

Extracting .tif Metadata from SEM image?

Silas Kraus-2
Greetings.

I am using Fiji to analyse images taken with a Scanning Electron
Microscope (FEI Quanta 250). I want to analyse particle density and
therefore need the magnification or Pixel size. The SEM stores this data
as text in the .tif file together with many other metadata, but Fiji's
"Show Info..." function does not show this data. Debug mode won't do the
trick either.

I managed to fetch the information with the simple bash-command:
> "grep --text -e Pixel -i <image.tif>"
But my goal is to write a single ImageJ macro that I can give to my
colleagues who are working on Windows, with just Fiji and maybe a few
plugins installed.

So, my question is:
How can I find a text line in a .tif file that reads something like
"PixelSize = 1.4681e-008"
and process the number, all in a simple ImageJ macro?

I've been searching the Internet for a few days now. There seem to be a
few similar discussions online, but I didn't manage to make use of them,
mostly because they often involve Java programming, which I understand
nothing about. Any help would be greatly appreciated.

Silas Kraus


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

signature.asc (501 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Extracting .tif Metadata from SEM image?

Straatman, Kees (Dr.)
Dear Silas,

In general I think you can get the header info via getMetadata("Info") or maybe via getImageInfo()

I don't know the format of your header but to start with try for example:

print(getMetadata("Info")); find the line with the data you want to extract and put it into the code below where you replace the 1 in N = lines[1] with the line number -1 you want to extract.

print(getMetadata("Info"));
selectWindow("Log");
lines = split(getInfo(),"\n");
N = lines[1];
print(N);


Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif

ImageJ workshops 1 and 2 June: http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-June-2017


-----Original Message-----
From: Silas Kraus [mailto:[hidden email]]
Sent: 17 May 2017 23:16
To: [hidden email]
Subject: Extracting .tif Metadata from SEM image?

Greetings.

I am using Fiji to analyse images taken with a Scanning Electron Microscope (FEI Quanta 250). I want to analyse particle density and therefore need the magnification or Pixel size. The SEM stores this data as text in the .tif file together with many other metadata, but Fiji's "Show Info..." function does not show this data. Debug mode won't do the trick either.

I managed to fetch the information with the simple bash-command:
> "grep --text -e Pixel -i <image.tif>"
But my goal is to write a single ImageJ macro that I can give to my colleagues who are working on Windows, with just Fiji and maybe a few plugins installed.

So, my question is:
How can I find a text line in a .tif file that reads something like "PixelSize = 1.4681e-008"
and process the number, all in a simple ImageJ macro?

I've been searching the Internet for a few days now. There seem to be a few similar discussions online, but I didn't manage to make use of them, mostly because they often involve Java programming, which I understand nothing about. Any help would be greatly appreciated.

Silas Kraus


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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Extracting .tif Metadata from SEM image?

Silas Kraus-2
Hello, Kees.

Thanks for the help. The code using "split" will be helpful to isolate
the numerical value once I have the raw data. However,
"print(getMetadata("Info"));" only returns an empty Log window. I am not
sure what is the difference between "getMetadata("Info")" and "run("Show
Info...");"  , which works but does only show general information about
image resolution and file size.

Reading through the Builtin Macro Functions, I discovered "indexOf" and
"substring" which could be useful to find the data in the bulk text.
However, I would still need a way to parse the image as a text string.
Actually, is that really a good idea to try and parse a 10MB image file
as text?

Greetings.
Silas





On 18/05/2017 10:50, Straatman, Kees (Dr.) wrote:

> Dear Silas,
>
> In general I think you can get the header info via
> getMetadata("Info") or maybe via getImageInfo()
>
> I don't know the format of your header but to start with try for
> example:
>
> print(getMetadata("Info")); find the line with the data you want to
> extract and put it into the code below where you replace the 1 in N =
> lines[1] with the line number -1 you want to extract.
>
> print(getMetadata("Info")); selectWindow("Log"); lines =
> split(getInfo(),"\n"); N = lines[1]; print(N);
>
>
> Best wishes
>
> Kees
>
>
> Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging
> Facility Centre for Core Biotechnology Services University of
> Leicester
> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif
>
>  ImageJ workshops 1 and 2 June:
> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-June-2017
>
>
>
> -----Original Message----- From: Silas Kraus
> [mailto:[hidden email]] Sent: 17 May 2017 23:16 To:
> [hidden email] Subject: Extracting .tif Metadata from SEM
> image?
>
> Greetings.
>
> I am using Fiji to analyse images taken with a Scanning Electron
> Microscope (FEI Quanta 250). I want to analyse particle density and
> therefore need the magnification or Pixel size. The SEM stores this
> data as text in the .tif file together with many other metadata, but
> Fiji's "Show Info..." function does not show this data. Debug mode
> won't do the trick either.
>
> I managed to fetch the information with the simple bash-command:
>> "grep --text -e Pixel -i <image.tif>"
> But my goal is to write a single ImageJ macro that I can give to my
> colleagues who are working on Windows, with just Fiji and maybe a few
> plugins installed.
>
> So, my question is: How can I find a text line in a .tif file that
> reads something like "PixelSize = 1.4681e-008" and process the
> number, all in a simple ImageJ macro?
>
> I've been searching the Internet for a few days now. There seem to be
> a few similar discussions online, but I didn't manage to make use of
> them, mostly because they often involve Java programming, which I
> understand nothing about. Any help would be greatly appreciated.
>
> Silas Kraus
>
>
> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Extracting .tif Metadata from SEM image?

Michael Schmid-3
Hi Silas,

probably the metadata of your microscope images are in a tiff tag that
ImageJ does not read. ImageJ takes the info from its private tag
"MetaData" (50839), where also other 'non-pixel data' such as overlays
are stored.

You might try the Tiff tags plugin
   https://imagej.nih.gov/ij/plugins/tiff-tags.html


Michael
________________________________________________________________
On 18/05/2017 16:03, Silas Kraus wrote:

> Hello, Kees.
>
> Thanks for the help. The code using "split" will be helpful to isolate
> the numerical value once I have the raw data. However,
> "print(getMetadata("Info"));" only returns an empty Log window. I am not
> sure what is the difference between "getMetadata("Info")" and "run("Show
> Info...");"  , which works but does only show general information about
> image resolution and file size.
>
> Reading through the Builtin Macro Functions, I discovered "indexOf" and
> "substring" which could be useful to find the data in the bulk text.
> However, I would still need a way to parse the image as a text string.
> Actually, is that really a good idea to try and parse a 10MB image file
> as text?
>
> Greetings.
> Silas
>
>
>
>
>
> On 18/05/2017 10:50, Straatman, Kees (Dr.) wrote:
>> Dear Silas,
>>
>> In general I think you can get the header info via
>> getMetadata("Info") or maybe via getImageInfo()
>>
>> I don't know the format of your header but to start with try for
>> example:
>>
>> print(getMetadata("Info")); find the line with the data you want to
>> extract and put it into the code below where you replace the 1 in N =
>> lines[1] with the line number -1 you want to extract.
>>
>> print(getMetadata("Info")); selectWindow("Log"); lines =
>> split(getInfo(),"\n"); N = lines[1]; print(N);
>>
>>
>> Best wishes
>>
>> Kees
>>
>>
>> Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging
>> Facility Centre for Core Biotechnology Services University of
>> Leicester
>> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif
>>
>>
>>  ImageJ workshops 1 and 2 June:
>> http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/AIF/workshops/imagej-workshops-June-2017
>>
>>
>>
>>
>> -----Original Message----- From: Silas Kraus
>> [mailto:[hidden email]] Sent: 17 May 2017 23:16 To:
>> [hidden email] Subject: Extracting .tif Metadata from SEM
>> image?
>>
>> Greetings.
>>
>> I am using Fiji to analyse images taken with a Scanning Electron
>> Microscope (FEI Quanta 250). I want to analyse particle density and
>> therefore need the magnification or Pixel size. The SEM stores this
>> data as text in the .tif file together with many other metadata, but
>> Fiji's "Show Info..." function does not show this data. Debug mode
>> won't do the trick either.
>>
>> I managed to fetch the information with the simple bash-command:
>>> "grep --text -e Pixel -i <image.tif>"
>> But my goal is to write a single ImageJ macro that I can give to my
>> colleagues who are working on Windows, with just Fiji and maybe a few
>> plugins installed.
>>
>> So, my question is: How can I find a text line in a .tif file that
>> reads something like "PixelSize = 1.4681e-008" and process the
>> number, all in a simple ImageJ macro?
>>
>> I've been searching the Internet for a few days now. There seem to be
>> a few similar discussions online, but I didn't manage to make use of
>> them, mostly because they often involve Java programming, which I
>> understand nothing about. Any help would be greatly appreciated.
>>
>> Silas Kraus
>>
>>
>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Extracting .tif Metadata from SEM image?

Silas Kraus-2
In reply to this post by Silas Kraus-2
Hello everyone.

Thanks to Jerome Mutterer who provided a solution to this problem.
You'll find his answers below. Note that the tag number may vary for
different Microscopes.

Jerome wrote:
> The attached macro does calibrate an opened SEM image. The trick was
> to find out in which Tiff tag the metadata was stored. I did this
> with the Tif tags plugin.
> https://imagej.nih.gov/ij/plugins/tiff-tags.html You need to install
> this one by getting the jar file from
> https://imagej.nih.gov/ij/plugins/download/jars/tiff_tags.jar and put
> it in the plugins folder. Then I modified the example macro at
> https://imagej.nih.gov/ij/macros/SetScaleFromTiffTag.txt that was
> written for Zeiss SEM, and a different tag.


and in a followup mail:

> Here's a much better version of the macro that transfers the metadata to the standard ImageJ metadata info location, so that further saving of the image in Tif preserves the metadata.
> Also, I'm using a list object constructed from the metadata, so that it's very easy to retrieve any other value.
>
>
> // retrieves the calibration info from tiff tag 34682
> // uses https://imagej.nih.gov/ij/plugins/tiff-tags.html
> // adapted from https://imagej.nih.gov/ij/macros/SetScaleFromTiffTag.txt
>
> tagnum=34682;
> path = getDirectory("image");
> if (path=="") exit ("path not available");
> name = getInfo("image.filename");
> if (name=="") exit ("name not available");
> path = path + name;
> tag = call("TIFF_Tags.getTag", path, tagnum);
> tag = replace(tag, "  ", "\n");
> setMetadata("Info", tag);
> List.setList(tag);
> pixelSize = 1E6*List.getValue('PixelWidth');
> setVoxelSize(pixelSize, pixelSize, 1, "micron");
> // print (List.get("SystemType"));
>

See you.
Silas

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

read_SEM_cal.txt (988 bytes) Download Attachment