def do_update_metadata(self, group): filelist = self.workspace.file_list urls = set([ ipd.url for ipd in self.pipeline.get_filtered_image_plane_details( self.workspace) ]) if len(urls) == 0: return def msg(url): return "Processing %s" % url import wx from bioformats.formatreader import get_omexml_metadata from bioformats.omexml import OMEXML from cellprofiler.modules.loadimages import url2pathname with wx.ProgressDialog("Updating metadata", msg(list(urls)[0]), len(urls), style=wx.PD_CAN_ABORT | wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME) as dlg: for i, url in enumerate(urls): if i > 0: keep_going, _ = dlg.Update(i, msg(url)) if not keep_going: break if group.filter_choice == F_FILTERED_IMAGES: match = group.filter.evaluate( (cps.FileCollectionDisplay.NODE_IMAGE_PLANE, Images.url_to_modpath(url), self)) if not match: continue metadata = filelist.get_metadata(url) if metadata is None: metadata = get_omexml_metadata(url2pathname(url)) filelist.add_metadata(url, metadata) metadata = OMEXML(metadata) exemplar = cpp.ImagePlaneDetails(url, None, None, None) if not self.pipeline.find_image_plane_details(exemplar): self.pipeline.add_image_plane_details([exemplar]) self.pipeline.add_image_metadata(url, metadata) self.ipds = self.pipeline.get_filtered_image_plane_details( self.workspace) self.update_metadata_keys()
def do_update_metadata(self, group): filelist = self.workspace.file_list urls = set([ipd.url for ipd in self.pipeline.get_filtered_image_plane_details(self.workspace)]) if len(urls) == 0: return def msg(url): return "Processing %s" % url import wx from bioformats.formatreader import get_omexml_metadata from bioformats.omexml import OMEXML from cellprofiler.modules.loadimages import url2pathname with wx.ProgressDialog( "Updating metadata", msg(list(urls)[0]), len(urls), style=wx.PD_CAN_ABORT | wx.PD_APP_MODAL | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME, ) as dlg: for i, url in enumerate(urls): if i > 0: keep_going, _ = dlg.Update(i, msg(url)) if not keep_going: break if group.filter_choice == F_FILTERED_IMAGES: match = group.filter.evaluate( (cps.FileCollectionDisplay.NODE_IMAGE_PLANE, Images.url_to_modpath(url), self) ) if not match: continue metadata = filelist.get_metadata(url) if metadata is None: metadata = get_omexml_metadata(url2pathname(url)) filelist.add_metadata(url, metadata) metadata = OMEXML(metadata) exemplar = cpp.ImagePlaneDetails(url, None, None, None) if not self.pipeline.find_image_plane_details(exemplar): self.pipeline.add_image_plane_details([exemplar]) self.pipeline.add_image_metadata(url, metadata) self.ipds = self.pipeline.get_filtered_image_plane_details(self.workspace) self.update_metadata_keys()
def test_04_01_read_omexml_metadata(self): path = os.path.join(os.path.dirname(__file__), "Channel1-01-A-01.tif") xml = F.get_omexml_metadata(path) pattern = r'<\s*Image\s+ID\s*=\s*"Image:0"\s+Name\s*=\s*"Channel1-01-A-01.tif"\s*>' self.assertTrue(re.search(pattern, xml))
def test_04_01_read_omexml_metadata(self): path = os.path.join(example_images_directory(), 'ExampleSBSImages', 'Channel1-01-A-01.tif') xml = F.get_omexml_metadata(path) pattern = r'<\s*Image\s+ID\s*=\s*"Image:0"\s+Name\s*=\s*"Channel1-01-A-01.tif"\s*>' self.assertTrue(re.search(pattern, xml))
def test_04_01_read_omexml_metadata(self): path = os.path.join(os.path.dirname(__file__), 'Channel1-01-A-01.tif') xml = F.get_omexml_metadata(path) pattern = r'<\s*Image\s+ID\s*=\s*"Image:0"\s+Name\s*=\s*"Channel1-01-A-01.tif"\s*>' self.assertTrue(re.search(pattern, xml))