-
Notifications
You must be signed in to change notification settings - Fork 25
Scyjava Refactor #133
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
Merged
Scyjava Refactor #133
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
9c0f955
Add conda environment configuration
ctrueden 2defab5
Remove dependencies on old-style Java-based code
ctrueden 6bc99e4
Replace javabridge with empty bioformats impl
ctrueden 1a6f612
Start implementing Bio-Formats with scyjava
ctrueden cc2d162
Migrate bioformats fields elsewhere
ctrueden 84ffd52
Flesh out the bioformats_reader implementation
ctrueden 172d858
bf_reader: avoid setSeries(None)
hinerm df26ef1
bf_reader: standardize numpy import
hinerm 85efc85
bf_reader: jimport MetadataTools
hinerm e60b756
bf_reader: use scyjava for cast instead of javabridge
hinerm c32bed2
bf_reader: update lut conversion
hinerm 9e7dbaa
bf_reader: add ChannelFiller TODO
hinerm dea8323
bf_reader: consolidate lut generation
hinerm 624d6fa
bf_reader: better define when reader should close
hinerm 79dd8b6
Add scyjava to environment.yml
hinerm a43fa6a
Add scyjava to setup.py
hinerm c8c175a
Add scijava-config to jgo endpoints
hinerm e405df2
bf_reader: remove unused import
hinerm 706100a
setup.py: add future module dep
hinerm f34341c
bf_reader: fix some reader uses
hinerm 17ab393
Move jvm startup to utilities/java
hinerm f9751dd
WIP: bfwriter
hinerm 5ae8785
Add fixme: buffer conversion
hinerm f1b8863
[wip] Build out most of writer
gnodar01 2f1b7ee
formatwriter: get omexmlservice from factory
hinerm a9bffb9
WIP formatwriter fixme
hinerm a22b2c0
Fix writer
gnodar01 8996d6c
Merge branch 'master' into scyjava
gnodar01 f07df84
Refactor logging
gnodar01 d214b96
Refactor logging
gnodar01 bef16a9
Logging Refactor
gnodar01 a2264b1
Refactor Logging
gnodar01 1261c24
Logging Refactor
gnodar01 00cbf75
Fix volume reading
gnodar01 e1b1be4
Merge branch 'read_volume_fix' into scyjava
gnodar01 7790513
Merge branch 'master' into scyjava
gnodar01 1f09379
Disable omero related stuff
gnodar01 535cd16
Logging formatting
gnodar01 0a91bcf
Fix plateviewer
gnodar01 79d2a86
Writer docs
gnodar01 d28886c
Remove unimplemented cache clearing
gnodar01 a5c5550
Remove last python-bioformats remnants
gnodar01 03eabf7
Remove is_this_type check, not necessary
gnodar01 153d4b4
Add ets extension
gnodar01 f8e0a1e
Fix Disappearing Metadata
gnodar01 65ce2b4
Remove unused unicode flags
gnodar01 d74a837
Remove unused unicode flags
gnodar01 3463349
[todo] Remove use of eval
gnodar01 f211ea5
Deprecate batch_state parsing and associated magic
gnodar01 07c6ba1
Allow notes to have pipes without breaking pipeline loading (#136)
bethac07 865728b
Reset default metadata module state, on automatic extraction
gnodar01 52c0d2d
Always allow FileLocation as metadata key
gnodar01 ea0aa72
Go back to 'C' for channel
gnodar01 eb50f3a
Remove deprecated numpy aliases (#140)
gnodar01 c37c17a
Comment out omero login handler
gnodar01 be7ee8f
Merge branch 'master' into scyjava
gnodar01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # NB: No implementation needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #TODO: unimplemented until CellProfiler/CellProfiler#4684 is resolved | ||
|
|
||
| K_OMERO_SERVER = None | ||
| K_OMERO_PORT = None | ||
| K_OMERO_USER = None | ||
| K_OMERO_SESSION_ID = None | ||
| K_OMERO_CONFIG_FILE = None | ||
|
|
||
| def clear_image_reader_cache(): | ||
| raise RuntimeError("unimplemented") | ||
|
|
||
| def set_omero_login_hook(omero_login): | ||
| raise RuntimeError("unimplemented") | ||
|
|
||
| def get_omero_credentials(): | ||
| raise RuntimeError("unimplemented") | ||
|
|
||
| def use_omero_credentials(credentials): | ||
| raise RuntimeError("unimplemented") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import os | ||
| import scyjava | ||
| import numpy as np | ||
| import logging | ||
|
|
||
| from . import omexml | ||
| from ..utilities.java import jimport | ||
|
|
||
|
|
||
| LOGGER = logging.getLogger(__name__) | ||
|
|
||
| p2j = lambda v: scyjava.to_java(v) | ||
|
|
||
| def write_image( | ||
| pathname, | ||
| pixels, | ||
| pixel_type, | ||
| c, | ||
| z, | ||
| t, | ||
| size_c, | ||
| size_z, | ||
| size_t, | ||
| channel_names | ||
| ): | ||
| # https://www.javadoc.io/doc/org.openmicroscopy/ome-common/5.3.2/loci/common/services/ServiceFactory.html | ||
| OMEXMLServiceFactory = jimport("loci.common.services.ServiceFactory") | ||
| # https://javadoc.scijava.org/Bio-Formats/loci/formats/services/OMEXMLService.html | ||
| OMEXMLService = jimport("loci.formats.services.OMEXMLService") | ||
| # https://javadoc.scijava.org/Bio-Formats/loci/formats/ImageWriter.html | ||
| ImageWriter = jimport("loci.formats.ImageWriter") | ||
| # https://www.javadoc.io/static/org.openmicroscopy/ome-xml/6.3.1/ome/xml/meta/IMetadata.html | ||
| IMetadata = jimport("loci.formats.meta.IMetadata") | ||
|
|
||
| DimensionsOrder = jimport("ome.xml.model.enums.DimensionOrder") | ||
| PixelType = jimport("ome.xml.model.enums.PixelType") | ||
| PositiveInteger = jimport("ome.xml.model.primitives.PositiveInteger") | ||
|
|
||
| omexml_service = OMEXMLServiceFactory().getInstance(OMEXMLService) | ||
| # https://www.javadoc.io/static/org.openmicroscopy/ome-xml/6.3.1/ome/xml/meta/OMEXMLMetadata.html | ||
| # https://www.javadoc.io/static/org.openmicroscopy/ome-xml/6.3.1/ome/xml/meta/MetadataStore.html | ||
| metadata = omexml_service.createOMEXMLMetadata() | ||
| metadata.createRoot() | ||
|
|
||
| metadata.setImageName(os.path.split(pathname)[1], 0) | ||
| metadata.setPixelsSizeX(PositiveInteger(p2j(pixels.shape[1])), 0) | ||
| metadata.setPixelsSizeY(PositiveInteger(p2j(pixels.shape[0])), 0) | ||
| metadata.setPixelsSizeC(PositiveInteger(p2j(size_c)), 0) | ||
| metadata.setPixelsSizeZ(PositiveInteger(p2j(size_z)), 0) | ||
| metadata.setPixelsSizeT(PositiveInteger(p2j(size_t)), 0) | ||
| metadata.setPixelsBinDataBigEndian(True, 0, 0) | ||
| metadata.setPixelsDimensionOrder(DimensionsOrder.XYCTZ, 0) | ||
| metadata.setPixelsType(PixelType.fromString(pixel_type), 0) | ||
|
|
||
|
|
||
| if pixels.ndim == 3: | ||
| metadata.setPixelsSizeC(PositiveInteger(p2j(pixels.shape[2])), 0) | ||
| metadata.setChannelSamplesPerPixel(PositiveInteger(p2j(pixels.shape[2])), 0, 0) | ||
| omexml_service.populateOriginalMetadata(metadata, "SamplesPerPixel", str(pixels.shape[2])) | ||
| # omexml.structured_annotations.add_original_metadata( | ||
| # ome.OM_SAMPLES_PER_PIXEL, str(pixels.shape[2])) | ||
| elif size_c > 1: | ||
| # meta.channel_count = size_c <- cant find | ||
| metadata.setPixelsSizeC(PositiveInteger(p2j(pixels.shape[2])), 0) | ||
| omexml_service.populateOriginalMetadata(metadata, "SamplesPerPixel", str(pixels.shape[2])) | ||
|
|
||
| metadata.setImageID("Image:0", 0) | ||
| metadata.setPixelsID("Pixels:0", 0) | ||
|
|
||
| for i in range(size_c): | ||
| metadata.setChannelID(f"Channel:0:{i}", 0, i) | ||
| metadata.setChannelSamplesPerPixel(PositiveInteger(p2j(1)), 0, i) | ||
|
|
||
| index = c + size_c * z + size_c * size_z * t | ||
| pixel_buffer = convert_pixels_to_buffer(pixels, pixel_type) | ||
|
|
||
|
|
||
| writer = ImageWriter() | ||
| writer.setMetadataRetrieve(metadata) | ||
| writer.setId(pathname) | ||
| writer.setInterleaved(True) | ||
| writer.saveBytes(index, pixel_buffer) | ||
| writer.close() | ||
|
|
||
| def convert_pixels_to_buffer(pixels, pixel_type): | ||
| '''Convert the pixels in the image into a buffer of the right pixel type | ||
|
|
||
| pixels - a 2d monochrome or color image | ||
|
|
||
| pixel_type - one of the OME pixel types | ||
|
|
||
| returns a 1-d byte array | ||
| ''' | ||
| if pixel_type == omexml.PT_UINT8: | ||
| as_dtype = np.uint8 | ||
| elif pixel_type == omexml.PT_UINT16: | ||
| as_dtype = "<u2" | ||
| elif pixel_type == omexml.PT_FLOAT: | ||
| as_dtype = "<f4" | ||
| else: | ||
| raise NotImplementedError("Unsupported pixel type: %d" % pixel_type) | ||
|
|
||
| return np.frombuffer(np.ascontiguousarray(pixels, as_dtype).data, np.uint8) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| PT_UINT8 = "uint8" | ||
| PT_UINT16 = "uint16" | ||
| PT_FLOAT = "float" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.