-
Notifications
You must be signed in to change notification settings - Fork 256
OBF: Support complex data stacks #4362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -374,12 +374,19 @@ private long initStack(long current) throws FormatException, IOException { | |||||||||||
| final int type = in.readInt(); | ||||||||||||
| meta_data.pixelType = getPixelType(type); | ||||||||||||
| meta_data.bitsPerPixel = getBitsPerPixel(type); | ||||||||||||
| meta_data.interleaved = false; | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| if((type & 0x40000000) != 0) | ||||||||||||
| { | ||||||||||||
| meta_data.interleaved = true; | ||||||||||||
| meta_data.sizeC *= 2; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| stack.bytesPerSample = meta_data.bitsPerPixel / 8; | ||||||||||||
|
|
||||||||||||
| meta_data.indexed = false; | ||||||||||||
| meta_data.rgb = false; | ||||||||||||
| meta_data.interleaved = false; | ||||||||||||
| meta_data.rgb = meta_data.interleaved; | ||||||||||||
|
|
||||||||||||
| final int compression = in.readInt(); | ||||||||||||
| stack.compression = getCompression(compression); | ||||||||||||
|
|
@@ -610,7 +617,7 @@ private boolean isFLIMLabel(String label) { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| private int getPixelType(int type) throws FormatException { | ||||||||||||
| switch (type) { | ||||||||||||
| switch (type & 0xFFFFFFF) { | ||||||||||||
| case 0x01: return FormatTools.UINT8; | ||||||||||||
| case 0x02: return FormatTools.INT8; | ||||||||||||
| case 0x04: return FormatTools.UINT16; | ||||||||||||
|
|
@@ -633,6 +640,8 @@ private int getBitsPerPixel(int type) throws FormatException { | |||||||||||
| case 0x20: return 32; | ||||||||||||
| case 0x40: return 32; | ||||||||||||
| case 0x80: return 64; | ||||||||||||
| case 0x40000040: return 64; | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implementation creates a mismatch between the pixeltype returned by This results in buffer size issues when calling Either these lines need to be updated to 32 and 64 respectively or the check on
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sbesson Thank you. I am not sure I understand. It did seem to work as-is (at least in this context) with ImageJ. The correct buffer size seems to get allocated in that case. The images can be opened and inspected. The values returned feel correct. A single complex float pixel is 64 bit (2 components with 32bit each).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the primary difference is the addition of the Note also the RGB mismatch warnings in the output above which suggests the value of the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sbesson Thank you! Does this work for you as well? diff --git a/components/formats-bsd/src/loci/formats/in/OBFReader.java b/components/formats-bsd/src/loci/formats/in/OBFReader.java
index 5cc5b87e3d..ccadbacf3d 100644
--- a/components/formats-bsd/src/loci/formats/in/OBFReader.java
+++ b/components/formats-bsd/src/loci/formats/in/OBFReader.java
@@ -386,7 +386,7 @@ public class OBFReader extends FormatReader {
stack.bytesPerSample = meta_data.bitsPerPixel / 8;
meta_data.indexed = false;
- meta_data.rgb = false;
+ meta_data.rgb = meta_data.interleaved;
final int compression = in.readInt();
stack.compression = getCompression(compression);As you suggested it does seem to make Of course the data isn't actually RGB and without
(The channel slider does nothing here) I see I can opt into the channel separation from the import dialog in ImageJ and that results in something perhaps slightly more desirable: I would be OK with this. Assuming it also resolves the OMERO import issue.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @ngladitz. From a round of testing, setting the
Feel free to push your change to this PR so that we can check the impact on already configured OBF datasets in the nightly CI repositories. Discussing with @melissalinkert, the change to bioformats/components/formats-api/src/loci/formats/IFormatReader.java Lines 118 to 122 in 5a443de
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sbesson Thank you! I pushed the change. |
||||||||||||
| case 0x40000080: return 128; | ||||||||||||
| default: throw new FormatException("Unsupported data type " + type); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||






There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why type & 0xFFFFFFF. Is it worth adding a comment to make it clear? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gerring In theory any non-complex OBF pixel type (e.g. "float") can be turned into a complex pixel type (e.g. "complex float") by additionally setting the complex bit (0x40000000). The mask is intended to return the underlying pixel type without the complex bit (both "complex float" and "float" become "float").
There are unused / undefined bits between the complex bit and the currently defined types so right now the mask could also be e.g. 0x3FFFFFFF.
Also I say in theory because I assume we'll never see e.g. "complex bool".
Currently I only really care about "complex float" though I also covered "complex double".
The values and their meaning is documented here https://imspectordocs.readthedocs.io/en/latest/fileformat.html#the-obf-file-format
A reference to that documentation is also included at the top of the source file.