We're Hiring!

Opening TIFF series

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.

Opening TIFF series

Postby Oli » Thu Jun 16, 2011 1:05 pm

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
Oli
 
Posts: 71
Joined: Mon Nov 29, 2010 4:57 pm

Re: Opening TIFF series

Postby mlinkert » Thu Jun 16, 2011 2:03 pm

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
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: Opening TIFF series

Postby Oli » Fri Jun 17, 2011 11:39 am

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
Oli
 
Posts: 71
Joined: Mon Nov 29, 2010 4:57 pm

Re: Opening TIFF series

Postby mlinkert » Wed Jun 22, 2011 9:38 pm

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
Attachments
FileGroupingTest.zip
ImageJ plugin that demonstrates how to group files.
(836 Bytes) Downloaded 236 times
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: Opening TIFF series

Postby Oli » Fri Jul 01, 2011 8:56 am

Hello!

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

Best

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


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 1 guest

cron