-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Currently get_acquisition_metadata() is nested inside find_dataset(), and even after the return statement, effectively making it unreachable.
I guess this is simply an indentation error...?
Originally posted by @ehrenfeu in #49 (comment)
python-imcflibs/src/imcflibs/imagej/omerotools.py
Lines 211 to 291 in bf97721
| def find_dataset(client, dataset_id): | |
| """Retrieve a dataset (wrapper) from the OMERO server. | |
| Parameters | |
| ---------- | |
| client : fr.igred.omero.Client | |
| The client object used to connect to the OMERO server. | |
| dataset_id : int | |
| The ID of the dataset to retrieve. | |
| Returns | |
| ------- | |
| fr.igred.omero.repositor.DatasetWrapper | |
| The dataset wrapper retrieved from the server. | |
| """ | |
| # Fetch the dataset from the OMERO server using the provided dataset ID | |
| return client.getDataset(Long(dataset_id)) | |
| def get_acquisition_metadata(user_client, image_wpr): | |
| """Get acquisition metadata from OMERO based on an image ID. | |
| Parameters | |
| ---------- | |
| user_client : fr.igred.omero.Client | |
| Client used for login to OMERO | |
| image_wpr : fr.igred.omero.repositor.ImageWrapper | |
| Wrapper to the image for the metadata | |
| Returns | |
| ------- | |
| dict | |
| { | |
| objective_magnification : float, | |
| objective_na : float, | |
| acquisition_date : str, | |
| acquisition_date_number : str, | |
| } | |
| """ | |
| ctx = user_client.getCtx() | |
| instrument_data = ( | |
| user_client.getGateway() | |
| .getMetadataService(ctx) | |
| .loadInstrument(image_wpr.asDataObject().getInstrumentId()) | |
| ) | |
| objective_data = instrument_data.copyObjective().get(0) | |
| metadata = {} | |
| metadata["objective_magnification"] = ( | |
| objective_data.getNominalMagnification().getValue() | |
| if objective_data.getNominalMagnification() is not None | |
| else 0 | |
| ) | |
| metadata["objective_na"] = ( | |
| objective_data.getLensNA().getValue() | |
| if objective_data.getLensNA() is not None | |
| else 0 | |
| ) | |
| if image_wpr.getAcquisitionDate() is None: | |
| if image_wpr.asDataObject().getFormat() == "ZeissCZI": | |
| field = "Information|Document|CreationDate" | |
| date_field = get_info_from_original_metadata( | |
| user_client, image_wpr, field | |
| ) | |
| metadata["acquisition_date"] = date_field.split("T")[0] | |
| metadata["acquisition_date_number"] = int( | |
| metadata["acquisition_date"].replace("-", "") | |
| ) | |
| else: | |
| metadata["acquisition_date"] = "NA" | |
| metadata["acquisition_date_number"] = 0 | |
| else: | |
| sdf = SimpleDateFormat("yyyy-MM-dd") | |
| metadata["acquisition_date"] = sdf.format(image_wpr.getAcquisitionDate()) | |
| metadata["acquisition_date_number"] = int( | |
| metadata["acquisition_date"].replace("-", "") | |
| ) | |
| return metadata | |
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done