Page 1 of 1

Opening TIFF series

PostPosted: Thu Jun 16, 2011 1:05 pm
by Oli
Hello all,

I am looking at how to integrate LOCI with TIFF File series
Code: Select all
HyperStack_t001_z001_c001.tif
HyperStack_t001_z002_c001.tif
HyperStack_t001_z003_c001.tif
HyperStack_t001_z001_c002.tif
HyperStack_t001_z002_c002.tif
HyperStack_t001_z003_c002.tif
...

So calling a simple reader like
Code: Select all
ImageReader reader = new ImageReader();
      String id = "E:\\Tests\\Test_Open_Series\\HyperStack_t001_z001_c001.tif";
      reader.setId(id);

I've been looking at the API to see how to define a string contaning the position data for the reader to understand it, but I am a bit lost. I know I can use setGroupFiles() but what other options can I specify?

I'm trying to do this so that TIFF series are handled by LOCI as well instead of having to do something customized.

Thanks in advance!

Oli

Re: Opening TIFF series

PostPosted: Thu Jun 16, 2011 2:03 pm
by mlinkert
Hi Oli,

So calling a simple reader like

Code: Select all
    ImageReader reader = new ImageReader();
          String id = "E:\\Tests\\Test_Open_Series\\HyperStack_t001_z001_c001.tif";
          reader.setId(id);


I've been looking at the API to see how to define a string contaning the position data for the reader to understand it, but I am a bit lost. I know I can use setGroupFiles() but what other options can I specify?

I'm trying to do this so that TIFF series are handled by LOCI as well instead of having to do something customized.


The 'FileStitcher' class in loci.formats should do exactly this. So if you just do:

Code: Select all
IFormatReader reader = new FileStitcher();
String id = "/path/to/HyperStack_t001_z001_c001.tif";
reader.setId(id);


...then you should see all of the files grouped together. If that doesn't work, though, please do let us know.

Regards,
-Melissa

Re: Opening TIFF series

PostPosted: Fri Jun 17, 2011 11:39 am
by Oli
Hello and thanks for the reply,

Unfortunately it does not work:
Code: Select all
      
IFormatReader reader2 = new FileStitcher();
int grpOpt = reader2.fileGroupOption(id);
String format = reader2.getFormat();
int imgCnt = reader2.getImageCount();
String[] usedFiles = reader2.getUsedFiles();
boolean comp = reader2.hasCompanionFiles();
boolean group = reader2.isGroupFiles();

IJ.log("GroupOption:"+grpOpt);
IJ.log("Format:"+format);
IJ.log("Image Count:"+imgCnt);
IJ.log("Companion files:"+comp);
IJ.log("Is grouped file:"+group);
IJ.log("Used files:"+usedFiles.length);

Returns
Code: Select all
GroupOption:2
Format:Tagged Image File Format
Image Count:1
Companion files:false
Is grouped file:true
Used files:1
FileData:1


I've also tried using
Code: Select all
public FileStitcher(boolean patternIds)
as a constructor or
Code: Select all
((FileStitcher) reader).setUsingPatternIds(true);

But using
Code: Select all
String id = "E:\\Tests\\Test_Open_Series\\HyperStack_t<001-024_z<001-015>-_c<001-003>.tif";
reader.setId(id);

gives me the following error in the IJ log:
Code: Select all
E:\Tests\Test_Open_Series\HyperStack_t<001-024_z<001-015>-_c<001-003>.tif (The filename, directory name, or volume label syntax is incorrect)

I tried following the examples here: http://pacific.mpi-cbg.de/javadoc/loci/formats/FilePattern.html

Thanks for your time!
Oli

Re: Opening TIFF series

PostPosted: Wed Jun 22, 2011 9:38 pm
by mlinkert
Hi Oli,

Unfortunately it does not work:

Code: Select all
    IFormatReader reader2 = new FileStitcher();
    int grpOpt = reader2.fileGroupOption(id);
    String format = reader2.getFormat();
    int imgCnt = reader2.getImageCount();
    String[] usedFiles = reader2.getUsedFiles();
    boolean comp = reader2.hasCompanionFiles();
    boolean group = reader2.isGroupFiles();

    IJ.log("GroupOption:"+grpOpt);
    IJ.log("Format:"+format);
    IJ.log("Image Count:"+imgCnt);
    IJ.log("Companion files:"+comp);
    IJ.log("Is grouped file:"+group);
    IJ.log("Used files:"+usedFiles.length);


Returns

Code: Select all
    GroupOption:2
    Format:Tagged Image File Format
    Image Count:1
    Companion files:false
    Is grouped file:true
    Used files:1
    FileData:1


I've also tried using

Code: Select all
    public FileStitcher(boolean patternIds)


as a constructor or

Code: Select all
    ((FileStitcher) reader).setUsingPatternIds(true);


But using

Code: Select all
    String id = "E:\\Tests\\Test_Open_Series\\HyperStack_t<001-024_z<001-015>-_c<001-003>.tif";
    reader.setId(id);


gives me the following error in the IJ log:

Code: Select all
    E:\Tests\Test_Open_Series\HyperStack_t<001-024_z<001-015>-_c<001-003>.tif (The filename, directory name, or volume label syntax is incorrect)



Sorry for the confusion - I've attached a small ImageJ plugin that more fully demonstrates how to accomplish this. If you compile and run it, you should be prompted for one of the files in the dataset. The list of all files in the dataset should be automatically calculated, and you should see the complete list of files in the "Log" window. I've tested this against a directory with the following files:

Code: Select all
HyperStack_t001_z001_c001.tif
HyperStack_t001_z001_c002.tif
HyperStack_t001_z002_c001.tif
HyperStack_t001_z002_c002.tif
HyperStack_t001_z003_c001.tif
HyperStack_t001_z003_c002.tif


Choosing any one of the files produces the following output:

Code: Select all
Z = 3
C = 2
T = 1
# of used files = 6
  /home/melissa/test/HyperStack_t001_z001_c001.tif
  /home/melissa/test/HyperStack_t001_z002_c001.tif
  /home/melissa/test/HyperStack_t001_z003_c001.tif
  /home/melissa/test/HyperStack_t001_z001_c002.tif
  /home/melissa/test/HyperStack_t001_z002_c002.tif
  /home/melissa/test/HyperStack_t001_z003_c002.tif


Hopefully that works for you as well, but if not please let us know.

Regards,
-Melissa

Re: Opening TIFF series

PostPosted: Fri Jul 01, 2011 8:56 am
by Oli
Hello!

Thank you very much, I will try it as soon as possible!

Best

Oli