Ejemplo n.º 1
0
    def test_13_01_load_filename(self):
        #
        # Load a file, only specifying the FileName in the CSV
        #
        dir = os.path.join(example_images_directory(), "ExampleSBSImages")
        file_name = 'Channel2-01-A-01.tif'
        csv_text = '''"Image_FileName_DNA"
"%s"
'''% file_name
        pipeline, module, filename = self.make_pipeline(csv_text)
        assert isinstance(module, L.LoadData)
        module.image_directory.dir_choice = cps.ABSOLUTE_FOLDER_NAME
        module.image_directory.custom_path = 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 = m.get_measurement(cpmeas.IMAGE, "PathName_DNA", 1)
        self.assertEqual(path, dir)
        self.assertEqual(m.get_measurement(cpmeas.IMAGE, "URL_DNA", 1),
                         L.pathname2url(os.path.join(dir, 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))
Ejemplo n.º 2
0
    def test_13_01_load_filename(self):
        #
        # Load a file, only specifying the FileName in the CSV
        #
        dir = os.path.join(example_images_directory(), "ExampleSBSImages")
        file_name = 'Channel2-01-A-01.tif'
        csv_text = '''"Image_FileName_DNA"
"%s"
''' % file_name
        pipeline, module, filename = self.make_pipeline(csv_text)
        assert isinstance(module, L.LoadData)
        module.image_directory.dir_choice = cps.ABSOLUTE_FOLDER_NAME
        module.image_directory.custom_path = 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 = m.get_measurement(cpmeas.IMAGE, "PathName_DNA", 1)
        self.assertEqual(path, dir)
        self.assertEqual(m.get_measurement(cpmeas.IMAGE, "URL_DNA", 1),
                         L.pathname2url(os.path.join(dir, 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))
Ejemplo n.º 3
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
     csv_text = '''"Image_FileName_DNA","Image_PathName_DNA"\n"%s","%s"''' \
         % (self.test_filename, self.test_path)
     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 = self.test_path
         m = cpmeas.Measurements()
         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),
                          self.test_filename)
         path_out = m.get_measurement(cpmeas.IMAGE, "PathName_DNA", 1)
         self.assertEqual(self.test_path, path_out)
         self.assertEqual(
             m.get_measurement(cpmeas.IMAGE, "URL_DNA", 1),
             L.pathname2url(os.path.join(self.test_path, self.test_filename)))
         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), self.test_shape)
     finally:
         os.remove(filename)
Ejemplo n.º 4
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
     csv_text = '''"Image_FileName_DNA","Image_PathName_DNA"\n"%s","%s"''' \
                % (self.test_filename, self.test_path)
     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 = self.test_path
         m = cpmeas.Measurements()
         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),
             self.test_filename)
         path_out = m.get_measurement(cpmeas.IMAGE, "PathName_DNA", 1)
         self.assertEqual(self.test_path, path_out)
         self.assertEqual(
             m.get_measurement(cpmeas.IMAGE, "URL_DNA", 1),
             L.pathname2url(os.path.join(self.test_path,
                                         self.test_filename)))
         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), self.test_shape)
     finally:
         os.remove(filename)