We're Hiring!

Very basic question: associating png import into time series

General user discussion about using the OMERO platform to its fullest. Please ask 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

There are workflow guides for various OMERO functions on our help site - http://help.openmicroscopy.org

You should find answers to any basic questions about using the clients there.

Re: Very basic question: associating png import into time se

Postby dps » Thu Oct 20, 2016 10:32 am

Hello again,

this works for me - thank you Roger! and i can start with .tif files from the acquisition machine, so conversion to png is no longer needed.

Now i would indeed like to create a single OME-TIFF file: all channels, all time points. as you said, this obviates the need for a companion file, but i also now need to package all the original images (1000s of tiffs) as well - are there memory concerns doing this? is using image- or graphicsMagick a reasonable approach?

example:

p0101_t0001_c0.tif
p0101_t0001_c1.tif
p0101_t0001_c2.tif
p0101_t0002_c0.tif
p0101_t0003_c0.tif
p0101_t0003_c1.tif
p0101_t0004_c0.tif
p0101_t0005_c0.tif
p0101_t0005_c1.tif
p0101_t0005_c2.tif
...
p0101_t3094_c0.tif

in the end i want something like http://downloads.openmicroscopy.org/ima ... es.ome.tif that additionally reflects your code for referring to the previous plane when there is no time point for a channel (via IFD i assume). i'm not clear on how to associate the IFD for each plane in this new multi-page file with its original filename...

there are thousands of images (1344x1024 8bit) per position (e.g. p0101 above), and i want to create a single OME-TIFF for each position.

thanks in advance!
d
dps
 
Posts: 12
Joined: Sat Jul 23, 2016 11:58 am

Re: Very basic question: associating png import into time se

Postby dgault » Mon Oct 24, 2016 2:29 pm

Hi David,

If you are looking at converting the tiff files in one combined OME-Tiff then I would recommend looking into a modified version of the below example:
https://github.com/openmicroscopy/biofo ... Tiffs.java

You would want to change the TiffWriter to an OMETiffWriter and rather than looping over a number of files you could through the number of timepoints and channels as below:

Code: Select all
   
for (int t=0; t<timePoints; t++) {
      for (int c=0; c<channels; c++) {
        String inId = base + "t" + String.format("%04d", t) + "c"+ c +".tiff";
        int planeIndex = (t*c) + c;
        in.setMetadataStore(meta);

        //Check if the file exists, otherwise use plane from previous timepoint
        File wantedFile = new File(inId);
        int wantedTimePoint = t;
        while (!wantedFile.exists() && wantedTimePoint >= 0) {
          wantedTimePoint --;
          inId = base + "t" + String.format("%04d", wantedTimePoint) + "c"+ c +".tiff";
          wantedFile = new File(inId);
        }
        in.setId(inId);

        // read first image plane
        byte[] image = in.openBytes(0);
        in.close();

        if (t == 0 && c == 0) {
          meta.setPixelsSizeC(new PositiveInteger(channels), 0);
          meta.setPixelsSizeT(new PositiveInteger(timePoints), 0);
          out.setMetadataRetrieve(meta);
          out.setId(outId);
          // read first IFD
          RandomAccessInputStream ras = new RandomAccessInputStream(inId);
          TiffParser parser = new TiffParser(ras);
          IFD ifd = parser.getFirstIFD();
          ras.close();

          // preserve TIFF comment
          String desc = ifd.getComment();

          if (desc != null) {
            ifd = new IFD();
            ifd.putIFDValue(IFD.IMAGE_DESCRIPTION, desc);
            comment = true;
            out.saveBytes(planeIndex, image, ifd);
            System.out.print(".");
            continue;
          }
        }

        // write image plane
        out.saveBytes(planeIndex, image);
      }
    }


I hope that makes sense and is a possible solution for you in this instance. It should allow you to generate a single OME-Tiff similar to the multi channel file you listed. If have any further questions or need additional help please do feel free to ask.

With Thanks,
David Gault
User avatar
dgault
Team Member
 
Posts: 208
Joined: Fri Aug 14, 2015 2:56 pm

Re: Very basic question: associating png import into time se

Postby dps » Tue Oct 25, 2016 4:24 am

thanks David!

the java code is going to be very useful as i eventually plan to write a plugin to my image acquisition structure.

i also got it working with command line tools and a python script. Happy to share if anyone is interested.

-d
dps
 
Posts: 12
Joined: Sat Jul 23, 2016 11:58 am

Re: Very basic question: associating png import into time se

Postby dgault » Tue Oct 25, 2016 3:32 pm

Thanks for the update David, thats great to hear you got it working. Please do feel free to let us know if you need any additional help in future.

David
User avatar
dgault
Team Member
 
Posts: 208
Joined: Fri Aug 14, 2015 2:56 pm

Re: Very basic question: associating png import into time se

Postby dps » Tue Jan 03, 2017 2:18 pm

I had this working at one point, and now a few months later having trouble again. Here is what i did: createa single tiff of my png files (example representing wavelegnths 00, 01, and 03)

gm convert -comment "%f" *.png all.bigtiff

as the comment i add the png file's name so i can extract the metadata from it.

then I run my script to generate the XML encoding the sparse data, and it looks correct and validates. but opening it in showinf or fiji doesn't show me the expected IFDs in the right places. for example, channels 01 and 03 show images data from channel 00, even though the IFDs seem correct.

ive attached the dir listing and ome.xml that i am prepending to all.bigtiff with the blank pane.
dps
 
Posts: 12
Joined: Sat Jul 23, 2016 11:58 am

Re: Very basic question: associating png import into time se

Postby dps » Tue Jan 03, 2017 3:31 pm

i found the problem - because i named the FirstC attribute didn't like the gap in channel numbers. e.g. for this experiment i numbered the channels 00, 01, 03. when i changed the FirstC entries to 0,1,2, it works.
dps
 
Posts: 12
Joined: Sat Jul 23, 2016 11:58 am

Previous

Return to User Discussion

Who is online

Users browsing this forum: No registered users and 1 guest