Exemplo n.º 1
0
    def setUpClass(cls):
        from cellprofiler.modules.tests \
             import example_images_directory, maybe_download_sbs
        maybe_download_sbs()
        cls.root_dir = example_images_directory()

        J.attach()
Exemplo n.º 2
0
 def test_03_03_measurement_columns(self):
     '''Check that results of get_measurement_columns match the actual column names output'''
     data = 'eJztW91u2zYUph0naFqgSHexBesNd9d2iSA7SZcEQ2vPXjcPsRs0Xn8wbJgi0TEHWjQkKrU39N32GHuEXe4RJtqyJXFyJMuSJ6cSQEiH5seP5/DwHEqyWrXOWe0beCTJsFXr7HcxQfCcKKxLjf4pHFATD/dg3UAKQxqk+ilsUR3+YBFYPoDlw1P55PTgEFZk+QTEOArN1n37tHsMwJZ9vmOXovPTpiMXPIXLF4gxrF+Zm6AEdp36P+3yWjGwcknQa4VYyHQppvVNvUs7o8HspxbVLILaSt/b2D7aVv8SGebL7hTo/HyOh4hc4N+RoMK02St0jU1MdQfv9C/WzngpE3i5HXqfu3YoCHYo2eWhp563/x647UsBdnvgab/jyFjX8DXWLIVA3FeuZqPg/ckh/W34+tsAjXZtjDsOwW0J49ga21klCEfjLfjwBVBxxlsNwe0IvLx00JDtfztUVAb7ClN7SYw/DL8p4LlcR4SYEe0+T/9FcQcRcSUfrgSe7h3KUey9LejJ5Td24DDMHtKc+mX0jWPn5tnZj62IvKJ/v7NXR1y96yNGB0Qx+wvoPW99heGKPlwRtGk0vnm4MH3vCfpy+SUzLfgdoZcKmemblN3C4txnQj9cbqCuYhEGmzzIwQY2kMqoMVrKDxbFlSU58fi4JeCnxxS/7bFbNYQ36jzGyTOyJI+PvbJz4RlX2vEy6flbNF7aupfTjM/z9Et6nhaNH2U5Xnw/WlLvtOYnAHcUR7+nIJrf3wH++eFyvafoOiKVuPG0qTOkm5iNnPoo/dwV+uFyg0KdMmiZyO0nblyKmweT0n9RfjkgDiSpr+gv5Yi4uOtP9Os21VGaeSZoXl7wG03dvv1awk5fxbRT0P5oEX3fhvB9IejL5V+kJ/uPnp9//Yq+fyZ9+Xh8Xafk2U/y/snPf1Q+PF7ADnH3qUH5vvOeQtXeb5nOneAydumF8B8L/FzmdniHFMMxxOGHiWlaVGc91zjjuoYycmuSjGNx8uYbhK96/JnINX8AoKvz/HgR+y2RHyLls7h+E2THF9RAVwa1dG15vcP407q/Cto/xI3raeaDqPf7WdGvGjLOpPJBmnl6nfJB0vl8XeL/qvN+1uJEVtb7qvSTpaP/fZxpP39Jcj+2alxW9lFZm+e0909xcX/turiCgAt637RK+4xfTnEDDaL3E7Se6OVvSGVuR+uyLjzjhljX0CDF/tZlnd12XBWsZp1E7edjs9tt0TercTDXN8fluOzgwvYRnwD/uuIytRjBOvrPRiLN9b0jjIMXN35PRrFOds9a/Lxt+THHZQOXlfiS4/K4m+M+XlwV3Oznef7LcTkux+W424X7u+DixPcbXPa+N+ftf/XwBOWJJ8CfJ7isIkIGBuXfTRlSf/xxjykRqmiTr2ukM/uy6fnQhvMMQniqAk91Hg/WkM5wdzQwbDaL0b7CsCo1ndpzu7Y2reW8vRDeoPfzN/KaSKW6phijGefFtCYKX0Xgq8zj6yPFtAzE0JDZJ6k1ETsT0bWr10+2A/i88120pU8fPrh7k38B4Pcr19/+eR6Hb2OjWLgP/P/zuheCKwG/n4/9Gizm149uaD/VMavt/wXhfSus'
     # alternate data: 1 image, 1 object, tex scale=3, gabor angles=6
     #        data = 'eJztW91u2zYUph0nW1agSHexFesNd9d2iSA7TZMGQ2vPXjcPsWs0Xrti2DBGomMONGlIVGpv6Hvtco+yy13uESbasiVzciTLP7UzCSCkQ/Hjx3N4eA5lWbVS86z0FTzSdFgrNQ9ahGLYoEi0uNU5hV1uk94+LFsYCWxCzk5hjTP4nUNh/hDmj08LJ6eHBVjQ9ScgwZGp1m67p7+OAdhxzx+6Jevd2vbkTKBI+RwLQdilvQ1y4K5X/6dbXiGLoAuKXyHqYNunGNVXWYs3+93xrRo3HYrrqBNs7B51p3OBLftFawT0bjdID9Nz8htWVBg1e4mviE048/Be/2rtmJcLhVfaofGZb4eMYo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bztCN6w9+/X8trY4MxEVn/MeT6qicNXUPgK0/g6GNmOhQXuCfek1YZicyj6dg36yW4IX3C+s670yb07H1znXwBM+pXvb/88S8K3tZXN3AaT/+O6FYHLgUk/H/g1mM2v71/TfqTjurb/F2wyHOE='
     maybe_download_sbs()
     cpprefs.set_default_image_directory(
         os.path.join(example_images_directory(), "ExampleSBSImages"))
     fd = StringIO(zlib.decompress(base64.b64decode(data)))
     pipeline = cpp.Pipeline()
     pipeline.load(fd)
     module = pipeline.modules()[3]
     measurements = pipeline.run(image_set_end=1)
     for x in module.get_measurement_columns(pipeline):
         assert x[1] in measurements.get_feature_names(
             x[0]
         ), '%s does not match any measurement output by pipeline' % (
             str(x))
     for obname in measurements.get_object_names():
         for m in measurements.get_feature_names(obname):
             if m.startswith(M.TEXTURE):
                 assert (
                     obname, m, 'float'
                 ) in module.get_measurement_columns(
                     pipeline
                 ), 'no entry matching %s in get_measurement_columns.' % (
                     (obname, m, 'float'))
Exemplo n.º 3
0
    def setUpClass(cls):
        from cellprofiler.modules.tests \
            import example_images_directory, maybe_download_sbs
        maybe_download_sbs()
        cls.root_dir = example_images_directory()

        J.attach()
 def setUpClass(cls):
     maybe_download_sbs()
     cls.test_filename = "1-162hrh2ax2.tif"
     cls.test_folder = "loadsingleimage"
     cls.test_shape = (27, 18)
     path = make_12_bit_image(cls.test_folder, cls.test_filename, (27, 18))
     cls.test_path = os.path.dirname(path)
     with open(path, "rb") as fd:
         cls.test_md5 = hashlib.md5(fd.read()).hexdigest()
 def setUpClass(cls):
     maybe_download_sbs()
     cls.test_filename = "1-162hrh2ax2.tif"
     cls.test_folder = "loadsingleimage"
     cls.test_shape = (27, 18)
     path = make_12_bit_image(cls.test_folder, cls.test_filename, (27, 18))
     cls.test_path = os.path.dirname(path)
     with open(path, "rb") as fd:
         cls.test_md5 = hashlib.md5(fd.read()).hexdigest()
 def setUpClass(cls):
     maybe_download_sbs()
     cls.test_folder = "loaddata"
     cls.test_path = os.path.join(example_images_directory(),
                                  cls.test_folder)
     cls.test_filename = "image.tif"
     cls.test_shape = (13, 15)
     path = maybe_download_example_image([cls.test_folder],
                                         cls.test_filename,
                                         shape=cls.test_shape)
     with open(path, "rb") as fd:
         cls.test_md5 = hashlib.md5(fd.read()).hexdigest()
Exemplo n.º 7
0
 def test_01_05_load_pipeline(self):
     import cellprofiler.pipeline as cpp
     import os
     maybe_download_sbs()
     pipeline_file = os.path.join(self.example_dir(), 
                                  "ExampleSBSImages", "ExampleSBS.cppipe")
     self.assertTrue(os.path.isfile(pipeline_file), "No ExampleSBS.cppipe file")
     pipeline = cpp.Pipeline()
     def callback(caller, event):
         self.assertFalse(isinstance(event, cpp.LoadExceptionEvent))
     pipeline.add_listener(callback)
     pipeline.load(pipeline_file)
Exemplo n.º 8
0
 def setUpClass(cls):
     cls.zmq_context = cpaw.the_zmq_context
     cls.notify_pub_socket = cpaw.get_the_notify_pub_socket()
     #
     # Install a bogus display_post_group method in FlipAndRotate
     # to elicit a post-group interaction request
     #
     from cellprofiler.modules.flipandrotate import FlipAndRotate
     def bogus_display_post_group(self, workspace, figure):
         pass
     FlipAndRotate.display_post_group = bogus_display_post_group
     maybe_download_sbs()
Exemplo n.º 9
0
 def setUpClass(cls):
     maybe_download_sbs()
     cls.test_folder = "loaddata"
     cls.test_path = os.path.join(
         example_images_directory(), cls.test_folder)
     cls.test_filename = "image.tif"
     cls.test_shape = (13, 15)
     path = maybe_download_example_image([cls.test_folder],
                                         cls.test_filename,
                                         shape=cls.test_shape)
     with open(path, "rb") as fd:
         cls.test_md5 = hashlib.md5(fd.read()).hexdigest()
Exemplo n.º 10
0
    def test_01_05_load_pipeline(self):
        import cellprofiler.pipeline as cpp
        import os
        maybe_download_sbs()
        pipeline_file = os.path.join(self.example_dir(), "ExampleSBSImages",
                                     "ExampleSBS.cppipe")
        self.assertTrue(os.path.isfile(pipeline_file),
                        "No ExampleSBS.cppipe file")
        pipeline = cpp.Pipeline()

        def callback(caller, event):
            self.assertFalse(isinstance(event, cpp.LoadExceptionEvent))

        pipeline.add_listener(callback)
        pipeline.load(pipeline_file)
Exemplo n.º 11
0
 def test_13_06_load_default_input_folder(self):
     # Regression test of issue #1365 - load a file from the default
     # input folder and check that PathName_xxx is absolute
     path = maybe_download_sbs()
     root_dir, path_name = os.path.split(path)
     file_name = 'Channel2-01-A-01.tif'
     csv_text = '''"Image_FileName_DNA","Image_PathName_DNA"\n"%s","%s"''' \
         % (file_name, path_name)
     pipeline, module, filename = self.make_pipeline(csv_text)
     try:
         assert isinstance(module, L.LoadData)
         module.image_directory.dir_choice = cps.ABSOLUTE_FOLDER_NAME
         module.image_directory.custom_path = root_dir
         m = cpmeas.Measurements(mode="memory")
         workspace = cpw.Workspace(pipeline, module, m, cpo.ObjectSet(),
                                   m, cpi.ImageSetList())
         self.assertTrue(module.prepare_run(workspace))
         self.assertEqual(m.get_measurement(cpmeas.IMAGE, "FileName_DNA", 1),
                          file_name)
         path_out = m.get_measurement(cpmeas.IMAGE, "PathName_DNA", 1)
         self.assertEqual(path, path_out)
         self.assertEqual(m.get_measurement(cpmeas.IMAGE, "URL_DNA", 1),
                          L.pathname2url(os.path.join(path, file_name)))
         module.prepare_group(workspace, {}, [1])
         module.run(workspace)
         img = workspace.image_set.get_image("DNA", must_be_grayscale=True)
         self.assertEqual(tuple(img.pixel_data.shape), (640, 640))
     finally:
         os.remove(filename)
Exemplo n.º 12
0
 def test_02_03_prepare_run(self):
     # regression test for issue #673 and #1161
     #
     # If LoadSingleImage appears first, pathname data does not show
     # up in the measurements.
     #
     maybe_download_sbs()
     folder = "ExampleSBSImages"
     path = os.path.join(example_images_directory(), folder)
     filename = "Channel1-01-A-01.tif"
     pipeline = cpp.Pipeline()
     lsi = L.LoadSingleImage()
     lsi.module_num = 1
     lsi.directory.dir_choice = cps.ABSOLUTE_FOLDER_NAME
     lsi.directory.custom_path = path
     lsi.file_settings[0].image_name.value = self.get_image_name(0)
     lsi.file_settings[0].file_name.value = filename
     pipeline.add_module(lsi)
     li = LI.LoadImages()
     li.module_num = 2
     pipeline.add_module(li)
     li.match_method.value = LI.MS_EXACT_MATCH
     li.location.dir_choice = cps.ABSOLUTE_FOLDER_NAME
     li.location.custom_path = path
     li.images[0].common_text.value = "Channel2-"
     m = cpmeas.Measurements()
     workspace = cpw.Workspace(pipeline, lsi, m, cpo.ObjectSet(), m,
                               cpi.ImageSetList())
     self.assertTrue(pipeline.prepare_run(workspace))
     self.assertGreater(m.image_set_count, 1)
     pipeline.prepare_group(workspace, {}, m.get_image_numbers())
     #
     # Skip to the second image set
     #
     m.next_image_set(2)
     lsi.run(workspace)
     #
     # Are the measurements populated?
     #
     m_file = "_".join((cpmeas.C_FILE_NAME, self.get_image_name(0)))
     self.assertEqual(m[cpmeas.IMAGE, m_file, 2], filename)
     #
     # Can we retrieve the image?
     #
     pixel_data = m.get_image(self.get_image_name(0)).pixel_data
     self.assertFalse(np.isscalar(pixel_data))
 def test_02_03_prepare_run(self):
     # regression test for issue #673 and #1161
     #
     # If LoadSingleImage appears first, pathname data does not show
     # up in the measurements.
     #
     maybe_download_sbs()
     folder = "ExampleSBSImages"
     path = os.path.join(example_images_directory(), folder)
     filename = "Channel1-01-A-01.tif"
     pipeline = cpp.Pipeline()
     lsi = L.LoadSingleImage()
     lsi.module_num = 1
     lsi.directory.dir_choice = cps.ABSOLUTE_FOLDER_NAME
     lsi.directory.custom_path = path
     lsi.file_settings[0].image_name.value = self.get_image_name(0)
     lsi.file_settings[0].file_name.value = filename
     pipeline.add_module(lsi)
     li = LI.LoadImages()
     li.module_num = 2
     pipeline.add_module(li)
     li.match_method.value = LI.MS_EXACT_MATCH
     li.location.dir_choice = cps.ABSOLUTE_FOLDER_NAME
     li.location.custom_path = path
     li.images[0].common_text.value = "Channel2-"
     m = cpmeas.Measurements()
     workspace = cpw.Workspace(pipeline, lsi, m, cpo.ObjectSet(), m,
                               cpi.ImageSetList())
     self.assertTrue(pipeline.prepare_run(workspace))
     self.assertGreater(m.image_set_count, 1)
     pipeline.prepare_group(workspace, {}, m.get_image_numbers())
     #
     # Skip to the second image set
     #
     m.next_image_set(2)
     lsi.run(workspace)
     #
     # Are the measurements populated?
     #
     m_file = "_".join((cpmeas.C_FILE_NAME, self.get_image_name(0)))
     self.assertEqual(m[cpmeas.IMAGE, m_file,2], filename)
     #
     # Can we retrieve the image?
     #
     pixel_data = m.get_image(self.get_image_name(0)).pixel_data
     self.assertEqual(tuple(pixel_data.shape), (640, 640))
 def test_03_03_measurement_columns(self):
     '''Check that results of get_measurement_columns match the actual column names output'''
     data = 'eJztW91u2zYUph0naFqgSHexBesNd9d2iSA7SZcEQ2vPXjcPsRs0Xn8wbJgi0TEHWjQkKrU39N32GHuEXe4RJtqyJXFyJMuSJ6cSQEiH5seP5/DwHEqyWrXOWe0beCTJsFXr7HcxQfCcKKxLjf4pHFATD/dg3UAKQxqk+ilsUR3+YBFYPoDlw1P55PTgEFZk+QTEOArN1n37tHsMwJZ9vmOXovPTpiMXPIXLF4gxrF+Zm6AEdp36P+3yWjGwcknQa4VYyHQppvVNvUs7o8HspxbVLILaSt/b2D7aVv8SGebL7hTo/HyOh4hc4N+RoMK02St0jU1MdQfv9C/WzngpE3i5HXqfu3YoCHYo2eWhp563/x647UsBdnvgab/jyFjX8DXWLIVA3FeuZqPg/ckh/W34+tsAjXZtjDsOwW0J49ga21klCEfjLfjwBVBxxlsNwe0IvLx00JDtfztUVAb7ClN7SYw/DL8p4LlcR4SYEe0+T/9FcQcRcSUfrgSe7h3KUey9LejJ5Td24DDMHtKc+mX0jWPn5tnZj62IvKJ/v7NXR1y96yNGB0Qx+wvoPW99heGKPlwRtGk0vnm4MH3vCfpy+SUzLfgdoZcKmemblN3C4txnQj9cbqCuYhEGmzzIwQY2kMqoMVrKDxbFlSU58fi4JeCnxxS/7bFbNYQ36jzGyTOyJI+PvbJz4RlX2vEy6flbNF7aupfTjM/z9Et6nhaNH2U5Xnw/WlLvtOYnAHcUR7+nIJrf3wH++eFyvafoOiKVuPG0qTOkm5iNnPoo/dwV+uFyg0KdMmiZyO0nblyKmweT0n9RfjkgDiSpr+gv5Yi4uOtP9Os21VGaeSZoXl7wG03dvv1awk5fxbRT0P5oEX3fhvB9IejL5V+kJ/uPnp9//Yq+fyZ9+Xh8Xafk2U/y/snPf1Q+PF7ADnH3qUH5vvOeQtXeb5nOneAydumF8B8L/FzmdniHFMMxxOGHiWlaVGc91zjjuoYycmuSjGNx8uYbhK96/JnINX8AoKvz/HgR+y2RHyLls7h+E2THF9RAVwa1dG15vcP407q/Cto/xI3raeaDqPf7WdGvGjLOpPJBmnl6nfJB0vl8XeL/qvN+1uJEVtb7qvSTpaP/fZxpP39Jcj+2alxW9lFZm+e0909xcX/turiCgAt637RK+4xfTnEDDaL3E7Se6OVvSGVuR+uyLjzjhljX0CDF/tZlnd12XBWsZp1E7edjs9tt0TercTDXN8fluOzgwvYRnwD/uuIytRjBOvrPRiLN9b0jjIMXN35PRrFOds9a/Lxt+THHZQOXlfiS4/K4m+M+XlwV3Oznef7LcTkux+W424X7u+DixPcbXPa+N+ftf/XwBOWJJ8CfJ7isIkIGBuXfTRlSf/xxjykRqmiTr2ukM/uy6fnQhvMMQniqAk91Hg/WkM5wdzQwbDaL0b7CsCo1ndpzu7Y2reW8vRDeoPfzN/KaSKW6phijGefFtCYKX0Xgq8zj6yPFtAzE0JDZJ6k1ETsT0bWr10+2A/i88120pU8fPrh7k38B4Pcr19/+eR6Hb2OjWLgP/P/zuheCKwG/n4/9Gizm149uaD/VMavt/wXhfSus'
     # alternate data: 1 image, 1 object, tex scale=3, gabor angles=6
     #        data = 'eJztW91u2zYUph0nW1agSHexFesNd9d2iSA7TZMGQ2vPXjcPsWs0Xrti2DBGomMONGlIVGpv6Hvtco+yy13uESbasiVzciTLP7UzCSCkQ/Hjx3N4eA5lWbVS86z0FTzSdFgrNQ9ahGLYoEi0uNU5hV1uk94+LFsYCWxCzk5hjTP4nUNh/hDmj08LJ6eHBVjQ9ScgwZGp1m67p7+OAdhxzx+6Jevd2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KS3EpLsXdLNzfGR+nvr+QcvC9uGz/S4AnLE88BJN5QsoGprRrcfn9k6V1Bh/p2BrlyBx+JaOduZfVwAczkqcbwVNUeIrTeIiJmSCtftdy2RzBO0gQQ6t6tQ23tjSqlbztCN6w9+/X8trY4MxEVn/MeT6qicNXUPgK0/g6GNmOhQXuCfek1YZicyj6dg36yW4IX3C+s670yb07H1znXwBM+pXvb/88S8K3tZXN3AaT/+O6FYHLgUk/H/g1mM2v71/TfqTjurb/F2wyHOE='
     maybe_download_sbs()
     cpprefs.set_default_image_directory(
         os.path.join(example_images_directory(),"ExampleSBSImages"))
     fd = StringIO(zlib.decompress(base64.b64decode(data)))
     pipeline = cpp.Pipeline()
     pipeline.load(fd)
     module = pipeline.modules()[3]
     measurements = pipeline.run(image_set_end=1)
     for x in module.get_measurement_columns(pipeline):
         assert x[1] in measurements.get_feature_names(x[0]), '%s does not match any measurement output by pipeline'%(str(x))
     for obname in measurements.get_object_names():
         for m in measurements.get_feature_names(obname):
             if m.startswith(M.TEXTURE):
                 assert (obname, m, 'float') in module.get_measurement_columns(pipeline), 'no entry matching %s in get_measurement_columns.'%((obname, m, 'float'))
    def test_03_01_save_and_load(self):
        '''Save a pipeline to batch data, open it to check and load it'''
        data = ('eJztWW1PGkEQXhC1WtPYTzb9tB+llROoGiWNgi9NSYUSIbZGbbvCApvu7ZJ7'
                'UWlj0o/9Wf1J/QndxTs4tsoBRS3JHbkcMzfPPDOzs8uxl8uU9jPbcFWLw1ym'
                'FKsSimGBIqvKDT0FmbUEdwyMLFyBnKVgycYwY9dgIgET8dTqRmolCZPx+AYY'
                '7ghlc0/EJf4cgClxfSTOsHNr0pFDnlPKRWxZhNXMSRABzxz9L3EeIoOgM4oP'
                'EbWx2aFw9VlW5aVmo30rxys2xXmke43Fkbf1M2yY76su0LldIJeYFsk3rKTg'
                'mh3gc2ISzhy841/Vtnm5pfDKOhTmOnUIKXWQdVnw6KX9W9Cxj9xQt6ce+3lH'
                'JqxCzknFRhQSHdXaUbTGwcffRJe/CXAk0BKX9sHNK3HIs4QvrdjeJSpbUEdW'
                'uS79rPv4mVb8SLmcOrGw3ugr/lAXPgRe9Zl3uAsXBnkO+sp7VolXyrscMm5B'
                '28T91/02/lHgphSce7i4GdCJ0y/fOSVfKe9RE1/UsYE1TXP91H38rCh+pCzG'
                'uYwpbRhcLlHGiWXY7OuJaCC9ISZ3q5NdqbhdzLZb+yH4hpmXy3I2ioVtGTFE'
                'myYZxbwcdpzvu68eku8+cGmf/GZAdz9IeaeOGMM0ERtx3P30z24+c6d86jqc'
                'uOP8Il18EdE/DP8L3w8fvnegezyl/Glxq/BaPljhTe1l9LOUPoj15YBfbB5n'
                'YoXTqKvZ4dTW2eZxPLZx+j2xlLy6Ni4SgWwpozfmPUj8fuvhuhK/lGUMRxgZ'
                'TmArV9GYVOU4s+qOLunodlGzo3mgeZMcxbwZir9p8QZFpj4C/kHnUfKO+YJ5'
                'NJ7z6OPsYP8rxuV3NcAFuAAX4P43XNqD63c/pLUZUzO43YCEVXBjnPINcOON'
                'S4OgXwPc8DipvO35Ut2/kfZfQO9+ewG6+03K3s04TW9topsa5ahyvYut7Yuv'
                'Wc+Gdj/P52sKz9ptPOXWK5AzuU8tb5ja9TuRbal4Q1rvCNT6zdzA561DWHwW'
                'pnvXXa13Zxx+bw3DFwn9zffYBxdxKidxP8Fg47zYw97NbVj7P/nFW+E=')

        def callback(caller, event):
            self.assertFalse(isinstance(event, cpp.LoadExceptionEvent))
            self.assertFalse(isinstance(event, cpp.RunExceptionEvent))

        T.maybe_download_sbs()
        for windows_mode in ((False,
                              True) if sys.platform.startswith("win") else
                             (False, )):
            pipeline = cpp.Pipeline()
            pipeline.add_listener(callback)
            pipeline.load(StringIO(zlib.decompress(base64.b64decode(data))))
            ipath = os.path.join(T.example_images_directory(),
                                 'ExampleSBSImages')
            bpath = tempfile.mkdtemp()
            bfile = os.path.join(bpath, C.F_BATCH_DATA)
            hfile = os.path.join(bpath, C.F_BATCH_DATA_H5)
            try:
                li = pipeline.modules()[0]
                self.assertTrue(isinstance(li, LI.LoadImages))
                module = pipeline.modules()[1]
                self.assertTrue(isinstance(module, C.CreateBatchFiles))
                li.location.dir_choice = LI.ABSOLUTE_FOLDER_NAME
                li.location.custom_path = ipath
                module.wants_default_output_directory.value = False
                module.custom_output_directory.value = bpath
                module.remote_host_is_windows.value = windows_mode
                self.assertEqual(len(module.mappings), 1)
                mapping = module.mappings[0]
                mapping.local_directory.value = ipath
                self.assertFalse(pipeline.in_batch_mode())
                measurements = cpmeas.Measurements(mode="memory")
                image_set_list = cpi.ImageSetList()
                result = pipeline.prepare_run(
                    cpw.Workspace(pipeline, None, None, None, measurements,
                                  image_set_list))
                self.assertFalse(pipeline.in_batch_mode())
                self.assertFalse(result)
                self.assertFalse(module.batch_mode.value)
                self.assertTrue(
                    measurements.has_feature(cpmeas.EXPERIMENT,
                                             cpp.M_PIPELINE))
                pipeline = cpp.Pipeline()
                pipeline.add_listener(callback)
                image_set_list = cpi.ImageSetList()
                measurements = cpmeas.Measurements(mode="memory")
                workspace = cpw.Workspace(pipeline, None, None, None,
                                          cpmeas.Measurements(),
                                          image_set_list)
                workspace.load(hfile, True)
                measurements = workspace.measurements
                self.assertTrue(pipeline.in_batch_mode())
                module = pipeline.modules()[1]
                self.assertTrue(isinstance(module, C.CreateBatchFiles))
                self.assertTrue(module.batch_mode.value)
                image_numbers = measurements.get_image_numbers()
                self.assertTrue(
                    [x == i + 1 for i, x in enumerate(image_numbers)])
                pipeline.prepare_run(workspace)
                pipeline.prepare_group(workspace, {}, range(1, 97))
                for i in range(96):
                    image_set = image_set_list.get_image_set(i)
                    for image_name in ('DNA', 'Cytoplasm'):
                        pathname = measurements.get_measurement(
                            cpmeas.IMAGE, "PathName_" + image_name, i + 1)
                        self.assertEqual(
                            pathname, '\\imaging\\analysis'
                            if windows_mode else '/imaging/analysis')
                measurements.close()
            finally:
                if os.path.exists(bfile):
                    os.unlink(bfile)
                if os.path.exists(hfile):
                    os.unlink(hfile)
                os.rmdir(bpath)
Exemplo n.º 16
0
    def test_05_04_convert_objects(self):
        pipeline_text = r"""CellProfiler Pipeline: http://www.cellprofiler.org
Version:3
DateRevision:20120831182904
ModuleCount:2
HasImagePlaneDetails:False

LoadImages:[module_num:1|svn_version:\'Unknown\'|variable_revision_number:11|show_window:True|notes:\x5B"Load the images by matching files in the folder against the unique text pattern for each stain\x3A \'Channel1-\' for nuclei, \'Channel2-\' for the GFP image. The two images together comprise an image set."\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True]
    File type to be loaded:individual images
    File selection method:Text-Exact match
    Number of images in each group?:3
    Type the text that the excluded images have in common:Do not use
    Analyze all subfolders within the selected folder?:None
    Input image file location:Default Input Folder\x7C
    Check image sets for unmatched or duplicate files?:Yes
    Group images by metadata?:No
    Exclude certain files?:No
    Specify metadata fields to group by:
    Select subfolders to analyze:
    Image count:2
    Text that these images have in common (case-sensitive):Channel1-
    Position of this image in each group:1
    Extract metadata from where?:File name
    Regular expression that finds metadata in the file name:.*-(?P<ImageNumber>\\\\d*)-(?P<Row>.*)-(?P<Column>\\\\d*)
    Type the regular expression that finds metadata in the subfolder path:.*\x5B\\\\\\\\/\x5D(?P<Date>.*)\x5B\\\\\\\\/\x5D(?P<Run>.*)$
    Channel count:1
    Group the movie frames?:No
    Grouping method:Interleaved
    Number of channels per group:2
    Load the input as images or objects?:Images
    Name this loaded image:rawGFP
    Name this loaded object:Nuclei
    Retain outlines of loaded objects?:No
    Name the outline image:NucleiOutlines
    Channel number:1
    Rescale intensities?:Yes
    Text that these images have in common (case-sensitive):Channel2-
    Position of this image in each group:2
    Extract metadata from where?:File name
    Regular expression that finds metadata in the file name:.*-(?P<ImageNumber>\\\\d*)-(?P<Row>.*)-(?P<Column>\\\\d*)
    Type the regular expression that finds metadata in the subfolder path:.*\x5B\\\\\\\\/\x5D(?P<Date>.*)\x5B\\\\\\\\/\x5D(?P<Run>.*)$
    Channel count:1
    Group the movie frames?:No
    Grouping method:Interleaved
    Number of channels per group:3
    Load the input as images or objects?:Images
    Name this loaded image:DNA
    Name this loaded object:Nuclei
    Retain outlines of loaded objects?:No
    Name the outline image:LoadedImageOutlines
    Channel number:1
    Rescale intensities?:Yes

LoadSingleImage:[module_num:2|svn_version:\'Unknown\'|variable_revision_number:5|show_window:True|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True]
    Input image file location:Default Input Folder\x7CNone
    Filename of the image to load (Include the extension, e.g., .tif):Channel1ILLUM.mat
    Load as images or objects?:Objects
    Name the image that will be loaded:IllumGFP
    Name this loaded object:MyObjects
    Retain outlines of loaded objects?:No
    Name the outlines:NucleiOutlines
    Rescale intensities?:No
"""
        maybe_download_sbs()
        directory = os.path.join(example_images_directory(),
                                 "ExampleSBSImages")
        self.convtester(pipeline_text, directory)
Exemplo n.º 17
0
 def test_03_01_save_and_load(self):
     '''Save a pipeline to batch data, open it to check and load it'''
     data = ('eJztWW1PGkEQXhC1WtPYTzb9tB+llROoGiWNgi9NSYUSIbZGbbvCApvu7ZJ7'
             'UWlj0o/9Wf1J/QndxTs4tsoBRS3JHbkcMzfPPDOzs8uxl8uU9jPbcFWLw1ym'
             'FKsSimGBIqvKDT0FmbUEdwyMLFyBnKVgycYwY9dgIgET8dTqRmolCZPx+AYY'
             '7ghlc0/EJf4cgClxfSTOsHNr0pFDnlPKRWxZhNXMSRABzxz9L3EeIoOgM4oP'
             'EbWx2aFw9VlW5aVmo30rxys2xXmke43Fkbf1M2yY76su0LldIJeYFsk3rKTg'
             'mh3gc2ISzhy841/Vtnm5pfDKOhTmOnUIKXWQdVnw6KX9W9Cxj9xQt6ce+3lH'
             'JqxCzknFRhQSHdXaUbTGwcffRJe/CXAk0BKX9sHNK3HIs4QvrdjeJSpbUEdW'
             'uS79rPv4mVb8SLmcOrGw3ugr/lAXPgRe9Zl3uAsXBnkO+sp7VolXyrscMm5B'
             '28T91/02/lHgphSce7i4GdCJ0y/fOSVfKe9RE1/UsYE1TXP91H38rCh+pCzG'
             'uYwpbRhcLlHGiWXY7OuJaCC9ISZ3q5NdqbhdzLZb+yH4hpmXy3I2ioVtGTFE'
             'myYZxbwcdpzvu68eku8+cGmf/GZAdz9IeaeOGMM0ERtx3P30z24+c6d86jqc'
             'uOP8Il18EdE/DP8L3w8fvnegezyl/Glxq/BaPljhTe1l9LOUPoj15YBfbB5n'
             'YoXTqKvZ4dTW2eZxPLZx+j2xlLy6Ni4SgWwpozfmPUj8fuvhuhK/lGUMRxgZ'
             'TmArV9GYVOU4s+qOLunodlGzo3mgeZMcxbwZir9p8QZFpj4C/kHnUfKO+YJ5'
             'NJ7z6OPsYP8rxuV3NcAFuAAX4P43XNqD63c/pLUZUzO43YCEVXBjnPINcOON'
             'S4OgXwPc8DipvO35Ut2/kfZfQO9+ewG6+03K3s04TW9topsa5ahyvYut7Yuv'
             'Wc+Gdj/P52sKz9ptPOXWK5AzuU8tb5ja9TuRbal4Q1rvCNT6zdzA561DWHwW'
             'pnvXXa13Zxx+bw3DFwn9zffYBxdxKidxP8Fg47zYw97NbVj7P/nFW+E=')
     def callback(caller,event):
         self.assertFalse(isinstance(event, cpp.LoadExceptionEvent))
         self.assertFalse(isinstance(event, cpp.RunExceptionEvent))
     T.maybe_download_sbs()
     for windows_mode in ((False, True) if sys.platform.startswith("win")
                          else (False,)):
         pipeline = cpp.Pipeline()
         pipeline.add_listener(callback)
         pipeline.load(StringIO(zlib.decompress(base64.b64decode(data))))
         ipath = os.path.join(T.example_images_directory(),'ExampleSBSImages')
         bpath = tempfile.mkdtemp()
         bfile = os.path.join(bpath,C.F_BATCH_DATA)
         hfile = os.path.join(bpath, C.F_BATCH_DATA_H5)
         try:
             li = pipeline.modules()[0]
             self.assertTrue(isinstance(li, LI.LoadImages))
             module = pipeline.modules()[1]
             self.assertTrue(isinstance(module, C.CreateBatchFiles))
             li.location.dir_choice = LI.ABSOLUTE_FOLDER_NAME
             li.location.custom_path = ipath
             module.wants_default_output_directory.value = False
             module.custom_output_directory.value = bpath
             module.remote_host_is_windows.value = windows_mode
             self.assertEqual(len(module.mappings), 1)
             mapping = module.mappings[0]
             mapping.local_directory.value = ipath
             self.assertFalse(pipeline.in_batch_mode())
             measurements = cpmeas.Measurements(mode="memory")
             image_set_list = cpi.ImageSetList()
             result = pipeline.prepare_run(
                 cpw.Workspace(pipeline, None, None, None,
                               measurements, image_set_list))
             self.assertFalse(pipeline.in_batch_mode())
             self.assertFalse(result)
             self.assertFalse(module.batch_mode.value)
             self.assertTrue(measurements.has_feature(
                 cpmeas.EXPERIMENT, cpp.M_PIPELINE))
             pipeline = cpp.Pipeline()
             pipeline.add_listener(callback)
             image_set_list = cpi.ImageSetList()
             measurements = cpmeas.Measurements(mode="memory")
             workspace = cpw.Workspace(pipeline, None, None, None,
                                       cpmeas.Measurements(),
                                       image_set_list)
             workspace.load(hfile, True)
             measurements = workspace.measurements
             self.assertTrue(pipeline.in_batch_mode())
             module = pipeline.modules()[1]
             self.assertTrue(isinstance(module, C.CreateBatchFiles))
             self.assertTrue(module.batch_mode.value)
             image_numbers = measurements.get_image_numbers()
             self.assertTrue([x == i+1 for i, x in enumerate(image_numbers)])
             pipeline.prepare_run(workspace)
             pipeline.prepare_group(workspace, {}, range(1,97))
             for i in range(96):
                 image_set = image_set_list.get_image_set(i)
                 for image_name in ('DNA', 'Cytoplasm'):
                     pathname = measurements.get_measurement(
                         cpmeas.IMAGE, "PathName_"+image_name, i+1)
                     self.assertEqual(pathname, 
                                      '\\imaging\\analysis' if windows_mode
                                      else '/imaging/analysis')
             measurements.close()
         finally:
             if os.path.exists(bfile):
                 os.unlink(bfile)
             if os.path.exists(hfile):
                 os.unlink(hfile)
             os.rmdir(bpath)
Exemplo n.º 18
0
 def setUpClass(cls):
     maybe_download_sbs()
    def test_05_04_convert_objects(self):
        pipeline_text = r"""CellProfiler Pipeline: http://www.cellprofiler.org
Version:3
DateRevision:20120831182904
ModuleCount:2
HasImagePlaneDetails:False

LoadImages:[module_num:1|svn_version:\'Unknown\'|variable_revision_number:11|show_window:True|notes:\x5B"Load the images by matching files in the folder against the unique text pattern for each stain\x3A \'Channel1-\' for nuclei, \'Channel2-\' for the GFP image. The two images together comprise an image set."\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True]
    File type to be loaded:individual images
    File selection method:Text-Exact match
    Number of images in each group?:3
    Type the text that the excluded images have in common:Do not use
    Analyze all subfolders within the selected folder?:None
    Input image file location:Default Input Folder\x7C
    Check image sets for unmatched or duplicate files?:Yes
    Group images by metadata?:No
    Exclude certain files?:No
    Specify metadata fields to group by:
    Select subfolders to analyze:
    Image count:2
    Text that these images have in common (case-sensitive):Channel1-
    Position of this image in each group:1
    Extract metadata from where?:File name
    Regular expression that finds metadata in the file name:.*-(?P<ImageNumber>\\\\d*)-(?P<Row>.*)-(?P<Column>\\\\d*)
    Type the regular expression that finds metadata in the subfolder path:.*\x5B\\\\\\\\/\x5D(?P<Date>.*)\x5B\\\\\\\\/\x5D(?P<Run>.*)$
    Channel count:1
    Group the movie frames?:No
    Grouping method:Interleaved
    Number of channels per group:2
    Load the input as images or objects?:Images
    Name this loaded image:rawGFP
    Name this loaded object:Nuclei
    Retain outlines of loaded objects?:No
    Name the outline image:NucleiOutlines
    Channel number:1
    Rescale intensities?:Yes
    Text that these images have in common (case-sensitive):Channel2-
    Position of this image in each group:2
    Extract metadata from where?:File name
    Regular expression that finds metadata in the file name:.*-(?P<ImageNumber>\\\\d*)-(?P<Row>.*)-(?P<Column>\\\\d*)
    Type the regular expression that finds metadata in the subfolder path:.*\x5B\\\\\\\\/\x5D(?P<Date>.*)\x5B\\\\\\\\/\x5D(?P<Run>.*)$
    Channel count:1
    Group the movie frames?:No
    Grouping method:Interleaved
    Number of channels per group:3
    Load the input as images or objects?:Images
    Name this loaded image:DNA
    Name this loaded object:Nuclei
    Retain outlines of loaded objects?:No
    Name the outline image:LoadedImageOutlines
    Channel number:1
    Rescale intensities?:Yes

LoadSingleImage:[module_num:2|svn_version:\'Unknown\'|variable_revision_number:5|show_window:True|notes:\x5B\x5D|batch_state:array(\x5B\x5D, dtype=uint8)|enabled:True]
    Input image file location:Default Input Folder\x7CNone
    Filename of the image to load (Include the extension, e.g., .tif):Channel1ILLUM.mat
    Load as images or objects?:Objects
    Name the image that will be loaded:IllumGFP
    Name this loaded object:MyObjects
    Retain outlines of loaded objects?:No
    Name the outlines:NucleiOutlines
    Rescale intensities?:No
"""
        maybe_download_sbs()
        directory = os.path.join(example_images_directory(),
                                 "ExampleSBSImages")
        self.convtester(pipeline_text, directory)
Exemplo n.º 20
0
 def setUpClass(cls):
     maybe_download_sbs()