Skip to content
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

actually implement the documented groupfiles option #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions bioformats/formatreader.py
Original file line number Diff line number Diff line change
@@ -538,7 +538,7 @@ class ImageReader(object):

'''

def __init__(self, path=None, url=None, perform_init=True):
def __init__(self, path=None, url=None, perform_init=True, groupFiles=False):
self.stream = None
file_scheme = "file:"
self.url = url
@@ -561,7 +561,7 @@ def __init__(self, path=None, url=None, perform_init=True):
self.rdr = get_omero_reader()
self.path = url
if perform_init:
self.init_reader()
self.init_reader(groupFiles)
return
except jutil.JavaException, e:
je = e.throwable
@@ -666,7 +666,7 @@ def __init__(self, path=None, url=None, perform_init=True):
self.rdr = IFormatReader()
self.rdr.o = jrdr
if perform_init:
self.init_reader()
self.init_reader(groupFiles)

def __enter__(self):
return self
@@ -690,10 +690,10 @@ def close(self):
#
jutil.static_call("java/lang/System", "gc","()V")

def init_reader(self):
def init_reader(self, groupFiles=False):
mdoptions = metadatatools.get_metadata_options(metadatatools.ALL)
self.rdr.setMetadataOptions(mdoptions)
self.rdr.setGroupFiles(False)
self.rdr.setGroupFiles(groupFiles)
self.metadata = metadatatools.createOMEXMLMetadata()
self.rdr.setMetadataStore(self.metadata)
try:
@@ -943,7 +943,7 @@ def load_using_bioformats(path, c=None, z=0, t=0, series=None, index=None,
return rdr.read(c, z, t, series, index, rescale, wants_max_intensity,
channel_names)

def get_omexml_metadata(path=None, url=None):
def get_omexml_metadata(path=None, url=None, groupfiles=False):
'''Read the OME metadata from a file using Bio-formats

:param path: path to the file
@@ -954,6 +954,8 @@ def get_omexml_metadata(path=None, url=None):
:returns: the metdata as XML.

'''
if not isinstance(groupfiles, bool):
groupfiles = False
with ImageReader(path=path, url=url, perform_init=False) as rdr:
#
# Below, "in" is a keyword and Rhino's parser is just a little wonky I fear.
@@ -966,7 +968,7 @@ def get_omexml_metadata(path=None, url=None):
Packages.loci.formats.services.OMEXMLService,
Packages.loci.formats['in'].DefaultMetadataOptions,
Packages.loci.formats['in'].MetadataLevel);
reader.setGroupFiles(false);
reader.setGroupFiles(""" + str(groupfiles).lower() + """);
reader.setOriginalMetadataPopulated(true);
var service = new ServiceFactory().getInstance(OMEXMLService);
var metadata = service.createOMEXMLMetadata();