- transforms bugfixes
This commit is contained in:
@@ -40,6 +40,7 @@ except (Exception,):
|
|||||||
|
|
||||||
ureg.default_format = '~P'
|
ureg.default_format = '~P'
|
||||||
set_application_registry(ureg)
|
set_application_registry(ureg)
|
||||||
|
warnings.filterwarnings('ignore', 'Reference to unknown ID')
|
||||||
|
|
||||||
|
|
||||||
class ReaderNotFoundError(Exception):
|
class ReaderNotFoundError(Exception):
|
||||||
@@ -51,7 +52,7 @@ class ImTransforms(Transforms):
|
|||||||
|
|
||||||
def __init__(self, path, cyllens, file=None, transforms=None):
|
def __init__(self, path, cyllens, file=None, transforms=None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.cyllens = cyllens
|
self.cyllens = tuple(cyllens)
|
||||||
if transforms is None:
|
if transforms is None:
|
||||||
# TODO: check this
|
# TODO: check this
|
||||||
if re.search(r'^Pos\d+', path.name):
|
if re.search(r'^Pos\d+', path.name):
|
||||||
@@ -106,7 +107,7 @@ class ImTransforms(Transforms):
|
|||||||
files = (Path(files),)
|
files = (Path(files),)
|
||||||
elif isinstance(files, Path):
|
elif isinstance(files, Path):
|
||||||
files = (files,)
|
files = (files,)
|
||||||
return files
|
return tuple(files)
|
||||||
except (Exception,):
|
except (Exception,):
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
@@ -1375,6 +1376,13 @@ class AbstractReader(Imread, metaclass=ABCMeta):
|
|||||||
else:
|
else:
|
||||||
self.immersionN = 1
|
self.immersionN = 1
|
||||||
|
|
||||||
|
p = re.compile(r'(\d+):(\d+)$')
|
||||||
|
try:
|
||||||
|
self.track, self.detector = zip(*[[int(i) for i in p.findall(find(
|
||||||
|
self.ome.images[0].pixels.channels, id=f'Channel:{c}').detector_settings.id)[0]]
|
||||||
|
for c in range(self.shape['c'])])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = ArgumentParser(description='Display info and save as tif')
|
parser = ArgumentParser(description='Display info and save as tif')
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ class Reader(AbstractReader, ABC):
|
|||||||
|
|
||||||
ome.images[0].pixels.channels.append(
|
ome.images[0].pixels.channels.append(
|
||||||
model.Channel(
|
model.Channel(
|
||||||
id=f"Channel:0:{idx}",
|
id=f"Channel:{idx}",
|
||||||
name=channel.attrib["Name"],
|
name=channel.attrib["Name"],
|
||||||
acquisition_mode=text(channel.find("AcquisitionMode")),
|
acquisition_mode=text(channel.find("AcquisitionMode")),
|
||||||
color=model.Color(text(channels_ds[channel.attrib["Id"]].find("Color"))),
|
color=model.Color(text(channels_ds[channel.attrib["Id"]].find("Color"))),
|
||||||
@@ -378,12 +378,12 @@ class Reader(AbstractReader, ABC):
|
|||||||
|
|
||||||
ome.images[0].pixels.channels.append(
|
ome.images[0].pixels.channels.append(
|
||||||
model.Channel(
|
model.Channel(
|
||||||
id=f"Channel:0:{idx}",
|
id=f"Channel:{idx}",
|
||||||
name=channel.attrib["Name"],
|
name=channel.attrib["Name"],
|
||||||
acquisition_mode=text(channel.find("AcquisitionMode")),
|
acquisition_mode=text(channel.find("AcquisitionMode")),
|
||||||
color=model.Color(text(channels_ds[channel.attrib["Id"]].find("Color"))),
|
color=model.Color(text(channels_ds[channel.attrib["Id"]].find("Color"))),
|
||||||
detector_settings=model.DetectorSettings(id=detector.attrib["Id"], binning=binning),
|
detector_settings=model.DetectorSettings(id=detector.attrib["Id"], binning=binning),
|
||||||
emission_wavelength=text(channel.find("EmissionWavelength")),
|
# emission_wavelength=text(channel.find("EmissionWavelength")), # TODO: fix
|
||||||
excitation_wavelength=light_source_settings.wavelength,
|
excitation_wavelength=light_source_settings.wavelength,
|
||||||
filter_set_ref=model.FilterSetRef(id=ome.instruments[0].filter_sets[filterset_idx].id),
|
filter_set_ref=model.FilterSetRef(id=ome.instruments[0].filter_sets[filterset_idx].id),
|
||||||
illumination_type=text(channel.find("IlluminationType")),
|
illumination_type=text(channel.find("IlluminationType")),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ def lazy_property(function, field, *arg_fields):
|
|||||||
def lazy(self):
|
def lazy(self):
|
||||||
if self.__dict__.get(field) is None:
|
if self.__dict__.get(field) is None:
|
||||||
self.__dict__[field] = function(*[getattr(self, arg_field) for arg_field in arg_fields])
|
self.__dict__[field] = function(*[getattr(self, arg_field) for arg_field in arg_fields])
|
||||||
self.__fields_set__.add(field)
|
self.model_fields_set.add(field)
|
||||||
return self.__dict__[field]
|
return self.__dict__[field]
|
||||||
return property(lazy)
|
return property(lazy)
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ class Transforms(dict):
|
|||||||
def __setstate__(self, state):
|
def __setstate__(self, state):
|
||||||
self.__dict__.update(state)
|
self.__dict__.update(state)
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return hash(frozenset((*self.__dict__.items(), *self.items())))
|
||||||
|
|
||||||
def save(self, file):
|
def save(self, file):
|
||||||
with open(file.with_suffix(".yml"), 'w') as f:
|
with open(file.with_suffix(".yml"), 'w') as f:
|
||||||
yaml.safe_dump(self.asdict(), f, default_flow_style=None)
|
yaml.safe_dump(self.asdict(), f, default_flow_style=None)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "ndbioimage"
|
name = "ndbioimage"
|
||||||
version = "2023.9.0"
|
version = "2023.10.0"
|
||||||
description = "Bio image reading, metadata and some affine registration."
|
description = "Bio image reading, metadata and some affine registration."
|
||||||
authors = ["W. Pomp <w.pomp@nki.nl>"]
|
authors = ["W. Pomp <w.pomp@nki.nl>"]
|
||||||
license = "GPLv3"
|
license = "GPLv3"
|
||||||
|
|||||||
Reference in New Issue
Block a user