We're Hiring!

Recovering Metadata on tile positions

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

Recovering Metadata on tile positions

Postby Oli » Tue Feb 15, 2011 2:55 pm

Hello,
Having a confocal microscope with a motorized stage, I can acquire arbitrary tiles using the included software (ZEN or LAS).
The stitching done within the software is rather poor and I was looking to use some of Fiji's built-in stitchers.

However, some of these tiles were acquired in non-grid patterns (Asking the microscope to follow a convex hull or manual tile placement so I cannot use the fully automated methods unless I have the X,Y coordinates of the images.

But having a motorized stage, the X,Y positions of each image in the LIF or LSM files should be accessible somewhere in the metadata. I've used your LOCI Formats reader to extract the metadata from the file, but there isn't a single field matching this criterion.

Seeing as the LAS or ZEN can reconstruct the image when I open the file in their reader, they must be recovering the positions from somewhere, right?

Thank you for any help you may provide with this issue.

Best
Oli
 
Posts: 71
Joined: Mon Nov 29, 2010 4:57 pm

Re: Recovering Metadata on tile positions

Postby mlinkert » Wed Feb 16, 2011 5:09 pm

Hi,

However, some of these tiles were acquired in non-grid patterns (Asking the microscope to follow a convex hull or manual tile placement so I cannot use the fully automated methods unless I have the X,Y coordinates of the images.

But having a motorized stage, the X,Y positions of each image in the LIF or LSM files should be accessible somewhere in the metadata. I've used your LOCI Formats reader to extract the metadata from the file, but there isn't a single field matching this criterion.


If you check the "Display metadata" and "Display OME-XML metadata" options in Fiji/ImageJ, you should see the stage coordinates at the very bottom of the "Original metadata" window ("X position for position #1", etc.) and in the PositionX and PositionY attributes of the Plane elements in the "OME Metadata" window.

Note that you may need to update to a recent trunk build in order to see the correct coordinates, particularly for LSM files.

If you want to retrieve the stage positions programatically, you can do so as follows:

Code: Select all
IFormatReader reader = new ImageReader();
ServiceFactory factory = new ServiceFactory();
OMEXMLService service = factory.getInstance(OMEXMLService.class);
IMetadata meta = service.createOMEXMLMetadata();

reader.setMetadataStore(omexmlMetadata);
reader.setId("/path/to/file");

for (int position=0; position<reader.getSeriesCount(); position++) {
  Double xCoordinate = omexmlMetadata.getPlanePositionX(position, 0);
  Double yCoordinate = omexmlMetadata.getPlanePositionY(position, 0);
  Double zCoordinate = omexmlMetadata.getPlanePositionZ(position, 0);
}


Regards,
-Melissa
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: Recovering Metadata on tile positions

Postby Oli » Fri Feb 18, 2011 3:16 pm

Excellent!
I had an older build indeed, and that was the problem. Thank you very much for the example code, you have just made my life a lot easier :)

Best!

Oli
Oli
 
Posts: 71
Joined: Mon Nov 29, 2010 4:57 pm

Re: Recovering Metadata on tile positions

Postby Oli » Thu Apr 07, 2011 7:34 am

I've been looking but to no avail.

Is there a metadata containing the orientation of the microscope stage. In some of the file's I've had to work with, either X/Y are flipped or are rotated with respect to the basic imageJ coordinate system

eg.
Code: Select all
   x                                 
<-----                                 ------>
     |             instead of         |
     | y                              |
     |                                |
     -                                -

Which is understandable, not all microscopes have the same stage orientation or calibration.
In the original XML I see things like
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eAFWorkflowXY 1
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eAFZUseMode 1
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eDataSource 0
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eDirectional 1
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eDirectionalY 1
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eSequentialMode 1

Which I am guessing would correspond to some of those settings, but I found no function from IMetadata to retrieve these values.

Thanks again for any help :)

Best!

Oli
Oli
 
Posts: 71
Joined: Mon Nov 29, 2010 4:57 pm

Re: Recovering Metadata on tile positions

Postby mlinkert » Fri Apr 08, 2011 3:56 pm

Hi Oli,

Is there a metadata containing the orientation of the microscope stage. In some of the file's I've had to work with, either X/Y are flipped or are rotated with respect to the basic imageJ coordinate system

*snipped diagram*
Which is understandable, not all microscopes have the same stage orientation or calibration.
In the original XML I see things like
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eAFWorkflowXY 1
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eAFZUseMode 1
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eDataSource 0
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eDirectional 1
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eDirectionalY 1
New collection/Pos001_S001 HardwareSetting|ScannerSettingRecord|eSequentialMode 1

Which I am guessing would correspond to some of those settings, but I found no function from IMetadata to retrieve these values.


That is probably a correct guess. Unfortunately, the OME-XML schema does not support orientation metadata, so you cannot retrieve that information using an IMetadata object. One option would be to automatically correct for flipped X and Y dimensions in Bio-Formats - you would still see in the original metadata that the images had been acquired with a different orientation, but at least the images would always have pixel (0, 0) in the upper-left hand corner (as expected by ImageJ).

Does that sound like a reasonable solution to you? If so, would you be willing to provide a small example dataset that demonstrates the flipped axes? I think I have sent you our SFTP server information in the past, but if not please let me know and I will send it in a private message.

Regards,
-Melissa
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: Recovering Metadata on tile positions

Postby Oli » Tue Apr 12, 2011 7:28 am

Hello,
One option would be to automatically correct for flipped X and Y dimensions in Bio-Formats - you would still see in the original metadata that the images had been acquired with a different orientation, but at least the images would always have pixel (0, 0) in the upper-left hand corner (as expected by ImageJ).

Does that sound like a reasonable solution to you? If so, would you be willing to provide a small example dataset that demonstrates the flipped axes? I think I have sent you our SFTP server information in the past, but if not please let me know and I will send it in a private message.


That sounds perfectly reasonable. Unfortunately each time I am confronted to these problems, I have very large datasets but I will trim down the tiles to a single plane and that should make it manageable to send via your FTP server. I'll let you know once it is done.

Thank you very much!

Oli
Oli
 
Posts: 71
Joined: Mon Nov 29, 2010 4:57 pm

Re: Recovering Metadata on tile positions

Postby Oli » Tue Apr 19, 2011 12:02 pm

Hello, sorry for the delay.

The sample data is under
incoming/PTBIOP Coordinates/STAGE CONFIG1.lif

It is a tile scan of convalaria. If I import the stage coordinates into Fiji as they are, I get images that are flipped horizontally with respect to how they should be. By flipping each image using the horizontal center, I can recover the proper configuration.

Thank you for your time,

Oli
Oli
 
Posts: 71
Joined: Mon Nov 29, 2010 4:57 pm

Re: Recovering Metadata on tile positions

Postby mlinkert » Tue Apr 19, 2011 4:10 pm

Hi Oli,

The sample data is under
incoming/PTBIOP Coordinates/STAGE CONFIG1.lif

It is a tile scan of convalaria. If I import the stage coordinates into Fiji as they are, I get images that are flipped horizontally with respect to how they should be. By flipping each image using the horizontal center, I can recover the proper configuration.


Perfect, thank you!

I have filed a ticket for this problem on our issue tracking system:

https://trac.openmicroscopy.org.uk/ome/ticket/5000

If you would like to be automatically notified of our progress, please let me know and I will CC you on the ticket.

Regards,
-Melissa
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 1 guest

cron