We're Hiring!

how to tie up multiple images into one OME-TIFF?

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

how to tie up multiple images into one OME-TIFF?

Postby bhcho » Mon Jun 07, 2010 3:30 pm

Hi all,

I'd like to tie up multiple images into one OME-TIFF file, such as multiple channel image and multiple time-series image.
In this case, it should be able to handle the meta data correctly.
for instance, for multiple channel image (protein channel and DNA channel for the same cell).
almost every the meta information is the same, except the channel names (and/or the channel settings).

Is there any sample java code to do this?
(especially how to handle the "savebytes" function fro loci.formats.IFormatWriter.)

And I think there are lots of discrepancies between the actual library and the javadoc for loci_tools.jar.
for example, the "setPixelsSizeX" method from "loci.formats.meta.IMetadta", the javadoc says it needs two integer arguments, but in the code I need three arcuments to compile correctly.
I'm currently looking at http://hudson.openmicroscopy.org.uk/job/LOCI/javadoc/.
Am I looking at an old version of javadoc or something?

Thanks in advance.

BK
Last edited by bhcho on Wed Jun 09, 2010 3:35 pm, edited 1 time in total.
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: how to tie up multiple images into one OME-TIFF?

Postby mlinkert » Mon Jun 07, 2010 7:57 pm

I'd like to tie up multiple images into one OME-TIFF file, such as multiple channel image and multiple time-series image.


A simple example using the 4.1.1 API, assuming that you have already created an IMetadata object named 'metadata':

Code: Select all
metadata.createRoot();
// populate metadata for the first image (multi-channel)
metadata.setPixelsBigEndian(Boolean.TRUE, 0, 0);
metadata.setPixelsDimensionOrder("XYCZT", 0, 0);
metadata.setPixelsPixelType("uint8", 0, 0);
metadata.setPixelsSizeX(512, 0, 0);
metadata.setPixelsSizeY(512, 0, 0);
metadata.setPixelsSizeC(3, 0, 0);
metadata.setPixelsSizeZ(1, 0, 0);
metadata.setPixelsSizeT(1, 0, 0);
// populate metadata for the second image (timelapse)
metadata.setPixelsBigEndian(Boolean.TRUE, 0, 0);
metadata.setPixelsDimensionOrder("XYCZT", 0, 0);
metadata.setPixelsPixelType("uint8", 0, 0);
metadata.setPixelsSizeX(512, 0, 0);
metadata.setPixelsSizeY(512, 0, 0);
metadata.setPixelsSizeC(1, 0, 0);
metadata.setPixelsSizeZ(1, 0, 0);
metadata.setPixelsSizeT(5, 0, 0);

// initialize the writer
ImageWriter writer = new ImageWriter();
writer.setMetadataRetrieve(metadata);
writer.setId("/path/to/output/file.ome.tiff");
for (int image=0; image<metadata.getImageCount(); image++) {
  int sizeZ = metadata.getPixelsSizeZ(image, 0);
  int sizeC = metadata.getPixelsSizeC(image, 0);
  int sizeT = metadata.getPixelsSizeT(image, 0);
  int planeCount = sizeZ * sizeC * sizeT;
  for (int plane=0; plane<planeCount; plane++) {
    byte[] pixelBuffer = new byte[]; // replace this with your own image retrieval code
    boolean lastInSeries = plane == planeCount - 1;
    writer.saveBytes(pixelBuffer, image, lastInSeries, image == metadata.getImageCount() - 1 && lastInSeries);
  }
}
writer.close();


Note that in the upcoming 4.2 release, the saveBytes signature used above will be deprecated. Updated example code will be available on the Bio-Formats website once 4.2 is released.

And I think there are lots of discrepancies between the actual library and the javadoc for loci_tools.jar.
for example, the "setPixelsSizeX" method from "loci.formats.meta.IMetadta", the javadoc says it needs two integer arguments, but in the code I need three arcuments to compile correctly.
I'm currently looking at http://hudson.openmicroscopy.org.uk/job/LOCI/javadoc/.


Those Javadocs correspond to the latest trunk build, and as such will not necessarily correspond to the API for any given stable release. We do not currently have pre-built Javadocs for the stable releases; however, you can easily generate them yourself. To generate the docs for the 4.1.1 release, make sure that you have Apache Ant and Subversion installed, and then do this:

Code: Select all
svn co https://skyking.microscopy.wisc.edu/svn/java/tags/loci-tools-4.1.1/ bio-formats-4.1.1/
cd bio-formats-4.1.1/
ant docs
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: how to tie up multiple images into one OME-TIFF?

Postby bhcho » Wed Jun 09, 2010 3:29 pm

Thanks.

And I think the code needs to be modified a little bit for the argument of image index. (especially for the second image)

Code: Select all
metadata.createRoot();
// populate metadata for the first image (multi-channel)
metadata.setPixelsBigEndian(Boolean.TRUE, 0, 0);
metadata.setPixelsDimensionOrder("XYCZT", 0, 0);
metadata.setPixelsPixelType("uint8", 0, 0);
metadata.setPixelsSizeX(512, 0, 0);
metadata.setPixelsSizeY(512, 0, 0);
metadata.setPixelsSizeC(3, 0, 0);
metadata.setPixelsSizeZ(1, 0, 0);
metadata.setPixelsSizeT(1, 0, 0);
// populate metadata for the second image (timelapse)
metadata.setPixelsBigEndian(Boolean.TRUE, 1, 0);
metadata.setPixelsDimensionOrder("XYCZT", 1, 0);
metadata.setPixelsPixelType("uint8", 1, 0);
metadata.setPixelsSizeX(512, 1, 0);
metadata.setPixelsSizeY(512, 1, 0);
metadata.setPixelsSizeC(1, 1, 0);
metadata.setPixelsSizeZ(1, 1, 0);
metadata.setPixelsSizeT(5, 1, 0);

// initialize the writer
ImageWriter writer = new ImageWriter();
writer.setMetadataRetrieve(metadata);
writer.setId("/path/to/output/file.ome.tiff");
for (int image=0; image<metadata.getImageCount(); image++) {
  int sizeZ = metadata.getPixelsSizeZ(image, 0);
  int sizeC = metadata.getPixelsSizeC(image, 0);
  int sizeT = metadata.getPixelsSizeT(image, 0);
  int planeCount = sizeZ * sizeC * sizeT;
  for (int plane=0; plane<planeCount; plane++) {
    byte[] pixelBuffer = new byte[]; // replace this with your own image retrieval code
    boolean lastInSeries = plane == planeCount - 1;
    writer.saveBytes(pixelBuffer, image, lastInSeries, image == metadata.getImageCount() - 1 && lastInSeries);
  }
}
writer.close();


Anyway, I did what you said.
svn co https://skyking.microscopy.wisc.edu/svn ... ols-4.1.1/ bio-formats-4.1.1/
cd bio-formats-4.1.1/
ant docs


But I dont know where I can find the javadocs.
Right now, I need some API java functions which set the Name, Color, Wavelength, ... for each channel.
Those setChannelName and setChannelColor does not work with my loci_tools.jar library (which I downloaded from a Trunk Build several weeks ago).
Could you tell me about those API functions?
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: how to tie up multiple images into one OME-TIFF?

Postby mlinkert » Wed Jun 09, 2010 8:04 pm

And I think the code needs to be modified a little bit for the argument of image index. (especially for the second image)


You're right; the image index should have been 1 for the second image.

But I dont know where I can find the javadocs.


They will be in the build/docs/api/ subdirectory of your SVN checkout after 'ant docs' has completed.

Right now, I need some API java functions which set the Name, Color, Wavelength, ... for each channel.
Those setChannelName and setChannelColor does not work with my loci_tools.jar library (which I downloaded from a Trunk Build several weeks ago).


setChannelName and setChannelColor were previously:

setLogicalChannelName(String name, int imageIndex, int channelIndex) and
setChannelComponentColorDomain(String color, int imageIndex, int channelIndex, int channelComponentIndex)

Note that 'channelComponentIndex' must be less than the value passed to setLogicalChannelSamplesPerPixel.
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: how to tie up multiple images into one OME-TIFF?

Postby bhcho » Wed Jun 09, 2010 8:27 pm

Thanks Mellisa,

Could you please tell me more about the arguments of
setChannelComponentColorDomain(String color, int imageIndex, int channelIndex, int channelComponentIndex)

Especially, If I want to set the color as green, red, blue, or yellow, how to set the "String color"?
And what's the "int channelComponentIndex"?



And for the javadoc,
svn co https://skyking.microscopy.wisc.edu/svn ... ols-4.1.1/ bio-formats-4.1.1/
cd bio-formats-4.1.1/
ant docs


it was okay in the "svn" part, but after I do "ant docs", I got
"BUILD FAILED",
/bio-formats-4.1.1/build.xml:796: Basedir /home/bhcho/bio-formats-4.1.1/components/visbio does not exist

Could you tell me what's wrong with me?

Many Thanks,
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm


Return to Developer Discussion

Who is online

Users browsing this forum: Google [Bot] and 0 guests