Looking for ways to group and merge the channels from the list of files (group files with similar names)

I am new to Bioformats, FIJI and this image processing world. I am looking for ways to automate the below manual process which can be one in FIJI tool.

Is there any way that the below operation can be done by the java process(more like a batch processing) , without having to use the macro on the FIJI application

Requirement:
I would like to group the list of relevant files and then save them as a single file.

Steps done in FIJI tool:

  1. Install the bioFormats plugin (if not present)
    Go to Plugins- > bioFormat Importer ->choose the file → Int he dialog box please select the checkbox, ‘group files with similar names’ and click ok-> Now specify the pattern which allows choosing all the files that belongs to the same group from a folder
    Ex:
    C:\Main\Workstation\TIFF\DsRed30KD_6.2.19_Mark_and_Find 001_Position049\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z<0-7>_ch0<0-1>.tif

  2. Now all the 16 files are loaded as a single image and we can scroll through the channels.

  3. Combining all the files and writing as 2 files (one file for channel 0 and one file for Channel 1) Pefomr this step → Plugins → Bioformat Exporter → choose to write each channel into a separate file.

Now two files will be generated with the same file name appended with channel number… Channel number will be appended before the first dot(.) in the filename mentioned.

Imported Files list:
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch01.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch00.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch01.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch00.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch01.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch00.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch01.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch00.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch01.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch00.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch01.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch00.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch01.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch00.tif
DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch01.tif

Exported File:
DsRed30KD_6_C0_C0.2.19_Mark_and_Find_001_Position049
DsRed30KD_6_C0_C1.2.19_Mark_and_Find_001_Position049

As well as the macro recording there are also the options to script with jython or groovy for example (you can see some Bio-Formats example scripts at bio-formats-examples/TiledConversion.py at 6cdb11e8c64566611b18f384b3a257dab5037e90 · dgault/bio-formats-examples · GitHub or bio-formats-examples/OverlappedTiledPyramidConversion.groovy at 6cdb11e8c64566611b18f384b3a257dab5037e90 · dgault/bio-formats-examples · GitHub)

If you do not want to do it through a FIJI macro another option may be the Bio-Formats command line tools (can be downloaded from Bio-Formats Downloads | Open Microscopy Environment (OME)). These will allow you to use the pattern file for grouping as well as splitting the channels:

bfconvert /path/to/in/filename_z<0-7>_ch0<0-1>.tif path/to/out/filename_Z%z_C%c.tiff

See docs at Converting a file to different format — Bio-Formats 6.6.0 documentation

Otherwise if you wanted to write a Java program to do the conversion you can do that also

2 Likes

Thank you for the great suggestions @dgault

  1. bfconvert tool:

When I try with bfconvert cmd line tool, I see the FileNotFound Exception even though I have the path specified correctly. Am I missing something here?

*C:\Users\mpancham>*bfconvert “C:\Madhan\input\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z<0-7>_ch0<0-1>.tif” “C:\Madhan\output\somename_c0<0-1>.tiff”
C:\Madhan\input\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z<0-7>_ch0<0-1>.tif

Exception in thread “main” java.io.FileNotFoundException: C:\Madhan\input\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z<0-7>_ch0<0-1>.tif (The filename, directory name, or volume label syntax is incorrect)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(Unknown Source)
at java.io.RandomAccessFile.(Unknown Source)
at loci.common.NIOFileHandle.(NIOFileHandle.java:130)
at loci.common.NIOFileHandle.(NIOFileHandle.java:151)
at loci.common.NIOFileHandle.(NIOFileHandle.java:165)
at loci.common.Location.getHandle(Location.java:522)
at loci.common.Location.getHandle(Location.java:462)
at loci.common.Location.getHandle(Location.java:443)
at loci.common.Location.getHandle(Location.java:426)
at loci.common.Location.checkValidId(Location.java:551)
at loci.formats.ImageReader.getReader(ImageReader.java:182)
at loci.formats.ImageReader.setId(ImageReader.java:844)
at loci.formats.tools.ImageConverter.testConvert(ImageConverter.java:506)
at loci.formats.tools.ImageConverter.main(ImageConverter.java:1095)

This error occurs when I specify the input file as a pattern string. However to make sure that tool can access the file I tried the below command of converting just one file with no patterns and it works… Please help!!!

C:\Users\mpancham>bfconvert “C:\Madhan\input\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif” “C:\Madhan\output\cnverted.ome.tiff”
C:\Madhan\input\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
TiffDelegateReader initializing C:\Madhan\input\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
[Tagged Image File Format] → C:\Madhan\output\cnverted.ome.tiff [OME-TIFF]
Converted 1/1 planes (100%)
[done]
2.321s elapsed (26.0+110.0ms per plane, 2040ms overhead)

  1. Could you please direct me to some Java code examples?

Thanks

Your image names contain “…ch00…”
Your command contains " …ch0<0-1>…"

According to
https://docs.openmicroscopy.org/bio-formats/6.6.0/formats/pattern-file.html

Leading zeros in the integer values must be specified.
To group test_Z00.tiff and test_Z01.tiff:

test_Z<00-01>.tiff

Maybe this helps.

@phaub Sorry that didn’t help…
Document also says that it can be used as in my command… however I tried the way you have mentioned as well. but no luck. Any other options?

Leading zeros in the integer values must be specified. To group test_Z00.tiff and test_Z01.tiff :
test_Z<00-01>.tiff
or:
test_Z0<0-1>.tiff

C:\Users\mpancham>bfconvert “C:\Madhan\input\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z<0-7>_ch<00-01>.tif” “C:\Madhan\output\somename_c0<0-1>.tiff”
C:\Madhan\input\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z<0-7>_ch<00-01>.tif
Exception in thread “main” java.io.FileNotFoundException: C:\Madhan\input\DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z<0-7>_ch<00-01>.tif (The filename, directory name, or volume label syntax is incorrect)
at java.io.RandomAccessFile.open0(Native Method)
at java.io.RandomAccessFile.open(Unknown Source)
at java.io.RandomAccessFile.(Unknown Source)
at loci.common.NIOFileHandle.(NIOFileHandle.java:130)
at loci.common.NIOFileHandle.(NIOFileHandle.java:151)
at loci.common.NIOFileHandle.(NIOFileHandle.java:165)
at loci.common.Location.getHandle(Location.java:522)
at loci.common.Location.getHandle(Location.java:462)
at loci.common.Location.getHandle(Location.java:443)
at loci.common.Location.getHandle(Location.java:426)
at loci.common.Location.checkValidId(Location.java:551)
at loci.formats.ImageReader.getReader(ImageReader.java:182)
at loci.formats.ImageReader.setId(ImageReader.java:844)
at loci.formats.tools.ImageConverter.testConvert(ImageConverter.java:506)
at loci.formats.tools.ImageConverter.main(ImageConverter.java:1095)

@pmadhanbabu I do not think the command line tools are able to interpret a pattern string given as an argument directly e.g.

sbesson@ls30630:imagesc-48138 $ ls
test_z0.tif	test_z1.tif
sbesson@ls30630:imagesc-48138 $ showinf "test_z<0-1>.tif"
Initializing reader
Exception in thread "main" java.io.FileNotFoundException: test_z<0-1>.tif (No such file or directory)
	at java.io.RandomAccessFile.open0(Native Method)
	at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
	at loci.common.NIOFileHandle.<init>(NIOFileHandle.java:130)
	at loci.common.NIOFileHandle.<init>(NIOFileHandle.java:151)
	at loci.common.NIOFileHandle.<init>(NIOFileHandle.java:165)
	at loci.common.Location.getHandle(Location.java:522)
	at loci.common.Location.getHandle(Location.java:462)
	at loci.common.Location.getHandle(Location.java:443)
	at loci.common.Location.getHandle(Location.java:426)
	at loci.common.Location.checkValidId(Location.java:551)
	at loci.formats.ImageReader.getReader(ImageReader.java:182)
	at loci.formats.ImageReader.setId(ImageReader.java:844)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:650)
	at loci.formats.tools.ImageInfo.testRead(ImageInfo.java:1035)
	at loci.formats.tools.ImageInfo.main(ImageInfo.java:1121)

As suggested by the documentation link given by @phaub above, could you try using a pattern file for storing this string? You should be able to point the command-line tools directly at this pattern file. Re-using the minimal example above:

sbesson@ls30630:imagesc-48138 $ echo "test_z<0-1>.tif" > test.pattern
sbesson@ls30630:imagesc-48138 $ bfconvert test.pattern converted.ome.tiff
test.pattern
FilePatternReader initializing test.pattern
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
[File pattern] -> converted.ome.tiff [OME-TIFF]
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z1.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z1.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
TiffDelegateReader initializing /private/tmp/imagesc-48138/test_z0.tif
	Converted 2/2 planes (100%)
[done]
1.05s elapsed (16.5+132.0ms per plane, 700ms overhead)
2 Likes

Uups, seems as if I asked a similar question already.

1 Like

Thank a ton !!!, @s.besson I will test that out. I would appreciate it if you could also share some URLS with Java code examples on Merging n channels…

That worked… thanks a lot

@pmadhanbabu you’re welcome. Using Bio-Formats as a Java library — Bio-Formats 6.6.0 documentation lists a few Java examples related to file conversion. The two first in this list are probably the most relevant:

  • ImageConverter is the Java class executed when calling bfconvert
  • FileConvert is a minimal Java class for converting from one format into another

Yeah, it worked, thanks!

1 Like

Thank you @s.besson, @dgault I am going through the ImageConverter and FileConvert source code now. I appreciate you answering my questions.

I was wondering if the bfconvert tool can scale up the images (example from 8 to 16 bit) and I have gone through the of convert documentation and I don’t find that option. Maybe the sole purpose of that tool is just to convert from one format to the other?
I am looking for ways to convert the bits as well. My requirement is that I will group the bunch of files with the pattern and then convert them from 8 to 16 bits. I am hoping to perform all this in Java implementation itself. Rather than using bfconvert for grouping and then java implementation for image scaling.
I am still searching for the implementation to convert bits. Any directions or guideliness/suggestions for my requirements are highly appreciated?

May be I can use this to update the pixel type… .setPixelsType(PixelType.UINT8, i)… But I couldn’t quite get the grouping part… Debugging to understand it better

Bio-Formats itself wont automatically rescale the data so you will have to convert for each write. If you are using the the Java conversion examples, then you will need to set the new PixelType for each series:

OMEXMLService service = factory.getInstance(OMEXMLService.class);
MetadataStore store = reader.getMetadataStore();
for (int series=0; series<reader.getSeriesCount(); series++) {
  store.setPixelsType(PixelType.UINT16, series);
}
writer.setMetadataRetrieve(service.asRetrieve(store));
//initialize the writer
writer.setId(output);

Then when writing each plane you would need to convert it. The below is a rather rudimentary way of doing this. There are some useful helper classes in FormatTools, DataTools, ImageTools and MetadataTools but I don’t think any have the direct option to upscale.

for (int series=0; series<reader.getSeriesCount(); series++) {
  reader.setSeries(series);
  writer.setSeries(series);
  for (int image=0; image<reader.getImageCount(); image++) {
    byte[] pix = reader.openBytes(image);
    short[] convertedPix = new short[pix.length];
    for (int i=0; i<pix.length; i++) {
      convertedPix[i] = pix[i];
    }
    writer.saveBytes(image, DataTools.shortsToBytes(convertedPix, true));
  }
}
2 Likes

Thanks a lot, @dgault. that worked!

1 Like

@dgault Thanks, I am able to group the images using bfconvert tool. However I see some issue in the output file when I used the bfconverter tool. Here are the details:
I see that Z and T values are flipped. Please note that when I group the images using FIJI (GUI) then there is no issue. Please help!!.
Refer the screenshot below for more details

I have tried using the -timepoint option but that didn’t help…
Here are the commands that I have tried:
$bfconvert /opt/tiff/input/inputfileformat.pattern ‘/opt/tiff/output/bfconvertertool_onetimepoint_DsRed30KD_6.2.19_Mark_and_Find 001_Position049_C%c.tif’

$bfconvert -timepoint 0 /opt/tiff/input/inputfileformat.pattern ‘/opt/tiff/output/bfconvertertool_onetimepoint_DsRed30KD_6.2.19_Mark_and_Find 001_Position049_C%c.tif’

Input files:
103201 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch01.tif’
36411 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch00.tif’
81593 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch01.tif’
28350 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch00.tif’
67173 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch01.tif’
23276 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch00.tif’
58928 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch01.tif’
20286 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch00.tif’
52475 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch01.tif’
18241 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch00.tif’
47666 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch01.tif’
16776 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch00.tif’
44061 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch01.tif’
15524 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch00.tif’
41756 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch01.tif’
14786 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif’

Ok, that does seem odd, if you run the below command does it show as have the correct Z and T?:
showinf -nopix /opt/tiff/input/inputfileformat.pattern

@dgault Z and T looks good when I try showinf. Please check the output.

Tool version:
$ /opt/bioformats/bftools/showinf -version
Version: 6.6.0
Build date: 14 December 2020
VCS revision: e0cdb3c28b52ba1b429d56c37a409fe53b5722ba

$ /opt/bioformats/bftools/showinf -nopix /opt/tiff/input/inputfileformat.pattern Checking file format [File pattern]
Initializing reader
FilePatternReader initializing /opt/tiff/input/inputfileformat.pattern
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
Initialization took 0.123s

Reading core metadata
filename = /opt/tiff/input/inputfileformat.pattern
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch01.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch01.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch01.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch01.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch01.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch01.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch01.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch01.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
Used files:
/opt/tiff/input/inputfileformat.pattern
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch00.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch00.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch00.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch00.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch00.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch00.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch00.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch01.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch01.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch01.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch01.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch01.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch01.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch01.tif
/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch01.tif
Series count = 1
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
Reading IFDs
Populating metadata
Checking comment style
Populating OME metadata
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
TiffDelegateReader initializing /opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif
Series #0 :
Image count = 16
RGB = false (1)
Interleaved = false
Indexed = false (false color)
Width = 512
Height = 512
SizeZ = 8
SizeT = 1
SizeC = 2
Tile size = 512 x 32
Thumbnail size = 128 x 128
Endianness = intel (little)
Dimension order = XYCZT (certain)
Pixel type = uint8
Valid bits per pixel = 8
Metadata complete = true
Thumbnail series = false
-----
Plane #0 <=> Z 0, C 0, T 0
Plane #6 <=> Z 3, C 0, T 0
Plane #7 <=> Z 3, C 1, T 0
Plane #8 <=> Z 4, C 0, T 0
Plane #9 <=> Z 4, C 1, T 0
Plane #10 <=> Z 5, C 0, T 0
Plane #15 <=> Z 7, C 1, T 0

Reading global metadata
BitsPerSample: 8
Compression: LZW
ImageLength: 512
ImageWidth: 512
MetaDataPhotometricInterpretation: Monochrome
MetaMorph: no
NumberOfChannels: 1
PhotometricInterpretation: BlackIsZero
ResolutionUnit: Centimeter
SamplesPerPixel: 1
XResolution: 79792.06151188066
YResolution: 79792.06151188066

Reading metadata
$

@pmadhanbabu thanks for sharing the output of showinf and the screenshots. Looking at them and your command, I think the issue is related to the output format you used for the conversion.

bfconvert uses the extension of the output filename to determine the format to write into. When the extension is simply .tif or tiff as in your case, the data is written as a simple multi-page TIFF. In the case of complex multi-dimensional images, there is no metadata allowing to unambigously interpret the dimension of each planes and the default TIFF reader arbitrarily interprets them as time-points, as in your screenshot.

Could you try changing your conversion command to use an output filename ending with .ome.tif or .ome.tiff? This will save the converted as OME-TIFF. The binary planes and the TIFF layout should be identical but the additional metadata will preserve the dimensions of the input data and allow it to be correctly visualized when reopening it in Fiji.

Hi @s.besson , As you mentioned, converting the file to .ome.tif does preserve the dimensions for Z and T. However The channels count (Sizec) seems invalid. The below screenshot just shows the grouped file for a series for the channel 00. The image has the metadata for sizec as 2 instead of 1.

Here is the breakdown:

Total files:
103201 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch01.tif’
36411 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z7_ch00.tif’
81593 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch01.tif’
28350 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z6_ch00.tif’
67173 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch01.tif’
23276 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z5_ch00.tif’
58928 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch01.tif’
20286 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z4_ch00.tif’
52475 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch01.tif’
18241 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z3_ch00.tif’
47666 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch01.tif’
16776 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z2_ch00.tif’
44061 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch01.tif’
15524 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z1_ch00.tif’
41756 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch01.tif’
14786 Aug 6 2019 ‘/opt/tiff/input/DsRed30KD_6.2.19_Mark_and_Find 001_Position049_z0_ch00.tif’

Command Executed:
/opt/bioformats/bftools/bfconvert /opt/tiff/input/inputfileformat.pattern ‘/opt/tiff/output/bfconvertertool_DsRed30KD_6.2.19_Mark_and_Find 001_Position049_%c.ome.tif’

This created 2 files, as the command groups all the images in the series for channel 00 & 01 and creates separate files for every channel (00 and 01). the created files are:
2.1M Feb 4 17:19 ‘bfconvertertool_DsRed30KD_6.2.19_Mark_and_Find 001_Position049_0.ome.tif’
2.1M Feb 4 17:19 ‘bfconvertertool_DsRed30KD_6.2.19_Mark_and_Find 001_Position049_1.ome.tif’

Now, these 2 files have all metadata values correct (including Z and T) except SizeC. Every individual files should have only one channel but it has 2. Because of this, when I convert these two 8-bit files in to 16-bit files using java code, I am having issues. Grouping these two files results in having 4 channels instead of just 2.

Note: I tried using options -channel to convert just one channel at a time, and that gave the SizeC as 1 but vales for SizeT was incorrect as 2 instead of just 1. And when I grouped the image in FIJI and tried to adjust the brightness/contrast , I had the below error in the log:
Checking comment style
Populating OME metadata
Exception in thread “ContrastAdjuster” java.lang.ClassCastException: loci.plugins.util.RecordedImageProcessor cannot be cast to ij.process.ByteProcessor
at ij.process.ByteStatistics.(ByteStatistics.java:17)
at ij.process.ImageStatistics.getStatistics(ImageStatistics.java:95)
at ij.ImagePlus.getRawStatistics(ImagePlus.java:1012)
at ij.plugin.frame.ContrastAdjuster.autoAdjust(ContrastAdjuster.java:808)
at ij.plugin.frame.ContrastAdjuster.doUpdate(ContrastAdjuster.java:1131)
at ij.plugin.frame.ContrastAdjuster.run(ContrastAdjuster.java:1085)
at java.lang.Thread.run(Thread.java:748)

Please provide me some suggestions. I appreciate all your help and discussion!!!