def test_get_pixels_type():
    image_processor = image_processor_impl()

    conn_settings = CONFIG['omero_conn']
    broker = OMERODataBroker(conn_settings,
                             image_processor=image_processor_impl())

    broker.open_omero_session()

    query_service = broker.SESSION.getQueryService()
    convert_to_uint16 = True

    dir_path = os.path.join(
        PROJECT_DIR, "..",
        "Morph_Batgirl_OldCamera_Htb2_Myo1_Hog1_Lte1_Vph1_00")

    common_path = os.path.commonprefix(dir_path)

    cube_dirs = glob.glob(''.join([common_path, 'pos???']))

    for path in cube_dirs:
        if os.path.isdir(path) == True:

            for f in os.listdir(path):
                fullpath = os.path.join(path, f)

                plane = script_utils.getPlaneFromImage(fullpath)

                pixelsType = image_processor.get_pixels_type(
                    plane, query_service, convert_to_uint16)
def main():
    CONFIG_FILE = os.path.join(PROJECT_DIR, 'config_test.yml')
    CONFIG = {}

    with open(CONFIG_FILE, 'r') as cfg:
        CONFIG = yaml.load(cfg, Loader=yaml.FullLoader)

    conn_settings = CONFIG['omero_conn']
    broker = OMERODataBroker(conn_settings)

    cache_manager = OmeroCacheManager()
    # broker.open_omero_session()

    dir_path = os.path.join(
        PROJECT_DIR, "tests", "test_data",
        "Morph_Batgirl_OldCamera_Htb2_Myo1_Hog1_Lte1_Vph1_00")

    # cache_manager.create_db_info(broker)
    # cache_manager.save_matlab_object()

    cache_manager.save_db_data(broker)
    cache_manager.load_matlab_object()

    # upload_metadata(broker, dir_path)

    broker.close_omero_session()
 def omero_data_broker(self):
     CONFIG = {}
     CONFIG['username'] = '******'
     CONFIG['password'] = '******'
     CONFIG['server'] = 'localhost'
     CONFIG['port'] =  4064
     '''Returns a default OMERO data broker for localhost'''
     return OMERODataBroker(CONFIG)
 def omero_session(self, omero_data_broker):
     CONFIG = {}
     CONFIG['username'] = '******'
     CONFIG['password'] = '******'
     CONFIG['server'] = 'localhost'
     CONFIG['port'] =  4064
     broker = OMERODataBroker(CONFIG)
     omero_data_broker.open_omero_session()
     print("teardown smtp")
Example #5
0
    def search_by_type_field(self, type, field, value, case_sensitive=False):
        broker = OMERODataBroker(username=self.USERNAME, password=self.PASSWORD, server=self.SERVER, port=self.PORT,
                                 image_processor=DefaultImageProcessor())

        broker.open_omero_session()
        objects = broker.find_objects_by_type_field_value(type, field, value, case_sensitive)
        broker.close_omero_session()

        return objects
Example #6
0
    def search_by_query(self, query, params):
        broker = OMERODataBroker(username=self.USERNAME, password=self.PASSWORD, server=self.SERVER, port=self.PORT,
                                 image_processor=DefaultImageProcessor())

        broker.open_omero_session()
        objects = broker.find_objects_by_query(query, params)
        broker.close_omero_session()

        return objects
Example #7
0
    def launch_upload(self, dataset_name, data_path, hypercube=False,
                      parser_class=MetadataAggregator, image_processor_impl=DefaultImageProcessor,
                      include_provenance_kvps=True, ignore_metadata=False):

        # override `parser_class` for custom metadata extractor implementations
        if parser_class is None:
            from omero_metadata_parser.aggregate_metadata import MetadataAggregator as parser_class

        # override `image_processor_impl` for custom image processing implementations
        if image_processor_impl is None:
            from omero_data_transfer.default_image_processor import DefaultImageProcessor as image_processor_impl

        # conn_settings = config['omero_conn']
        broker = OMERODataBroker(username=self.USERNAME, password=self.PASSWORD, server=self.SERVER, port=self.PORT,
                                 image_processor=image_processor_impl())
        # broker.open_omero_session()

        data_transfer_manager = DataTransferManager(parser_class=parser_class)
        results = data_transfer_manager.upload_data_dir(broker, dataset_name, data_path, hypercube=hypercube,
                                                        include_provenance_kvps=include_provenance_kvps,
                                                        ignore_metadata=ignore_metadata)

        # upload_metadata(broker, dir_path)
        # broker.close_omero_session()

        # Print results
        image_id_list = results['image_id_list']

        output_str = 'Number of images uploaded'
        if hypercube is True:
            output_str = 'Number of hypercubes uploaded'

        if image_id_list is not None:
            print(': '.join([output_str, str(len(image_id_list))]))

        dataset_id = results['dataset_id']
        if dataset_id is not None:
            print(': '.join(['Uploaded Dataset ID', str(dataset_id)]))

            dataset_param = '-'.join(['?show=dataset', str(dataset_id)])
            dataset_url = '/'.join(['http:/', self.SERVER, 'webclient', dataset_param])
            print(': '.join(['Uploaded Dataset URL', dataset_url]))
        else:
            print('No dataset ID generated - failed to upload dataset')

        return dataset_id
def main():
    PROJECT_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..")

    CONFIG_FILE = os.path.join(PROJECT_DIR, 'config_test.yml')
    CONFIG = {}

    with open(CONFIG_FILE, 'r') as cfg:
        CONFIG = yaml.load(cfg, Loader=yaml.FullLoader)

    conn_settings = CONFIG['omero_conn']
    broker = OMERODataBroker(CONFIG,
                             image_processor=image_processor_impl())

    broker.open_omero_session()

    # dir_path = os.path.join("","/var","data_dir")
    dir_path = os.path.join(PROJECT_DIR,"..","Morph_Batgirl_OldCamera_Htb2_Myo1_Hog1_Lte1_Vph1_00")

    data_transfer_manager = DataTransferManager()
    data_transfer_manager.upload_data_dir(broker, "test_dataset", dir_path, hypercube=False)
    # upload_metadata(broker, dir_path)

    broker.close_omero_session()
Example #9
0
    def searcher(self):
        broker = OMERODataBroker(username=self.USERNAME, password=self.PASSWORD, server=self.SERVER, port=self.PORT,
                                 image_processor=DefaultImageProcessor())

        broker.open_omero_session()
        return broker