experiment#
zen_api_utils.experiment
#
Functions:
-
show_zstack_info_LM–Display the Z-Stack information.
-
show_swaf_info_LM–Display the SWAF information.
-
show_track_info_LM–Logs detailed information about tracks and their channels, and returns a TrackInfo object.
-
save_experiment–Saves the modified experiment using a defined name.
-
delete_czifile–Deletes a CZI file from the specified folder.
-
load_experiment–Load an experiment by name and return its ID.
-
run_experiment–Run an experiment and return the path to the output image file.
-
get_configured_containernames–Retrieve a list of configured containers for a specific experiment.
show_zstack_info_LM
#
show_zstack_info_LM(zstack_info: ZStackServiceGetZStackInfoResponse) -> None
Display the Z-Stack information. Args: zstack_info (ZStackServiceGetZStackInfoResponse): The Z-Stack information to display. Returns: None
show_swaf_info_LM
#
show_swaf_info_LM(info: ExperimentSwAutofocusServiceGetAutofocusParametersResponse) -> None
Display the SWAF information. Args: info (ExperimentSwAutofocusServiceGetAutofocusParametersResponse): The SWAF information. Returns: None
show_track_info_LM
#
show_track_info_LM(info: TrackServiceGetTrackInfoResponse) -> TrackInfo
Logs detailed information about tracks and their channels, and returns a TrackInfo object. Args: info (TrackServiceGetTrackInfoResponse): The response object containing track information. Returns: TrackInfo: An object containing the track information and the number of tracks. Logs: Logs the start and end of track information. Logs each track's index and activation status. Logs each channel's index, name, and activation status within each track.
save_experiment
async
#
save_experiment(exp: ExperimentReference, expservice: ExperimentServiceStub, expname: str = 'MyExperiment', overwrite: bool = False)
Saves the modified experiment using a defined name. Args: exp (ExperimentServiceLoadResponse): The experiment to be saved. expservice (ExperimentServiceStub): The service stub to handle the save operation. expname (str, optional): The name to save the experiment as. Defaults to "MyExperiment". overwrite (bool, optional): Whether to allow overwriting an existing experiment with the same name. Defaults to False. Returns: bool: True if the experiment was saved successfully, False otherwise. Raises: Exception: If there is an error during the save operation, it will be logged and the function will return False.
delete_czifile
#
delete_czifile(image_folder: str | Path, cziname: str) -> bool
Deletes a CZI file from the specified folder.
Parameters:
-
image_folder(str | Path) –The path to the folder containing the CZI file.
-
cziname(str) –The name of the CZI file (without the .czi extension).
Returns:
-
bool(bool) –True if the file was successfully deleted, False otherwise.
Raises:
-
ValueError–If image_folder or cziname is empty or None.
load_experiment
async
#
load_experiment(experiment_service: ExperimentServiceStub, experiment_name: str) -> str
Load an experiment by name and return its ID. Args: experiment_service (ExperimentServiceStub): The experiment service stub for making API calls. experiment_name (str): The name of the experiment to load. Returns: str: The unique identifier of the loaded experiment. Raises: Exception: If the experiment loading fails or the experiment is not found.
run_experiment
async
#
run_experiment(experiment_service: ExperimentServiceStub, experiment_id: str) -> Path
Run an experiment and return the path to the output image file. This function initiates an experiment execution by first retrieving the image output path from the experiment service, then running the specified experiment, and finally constructing the full path to the resulting CZI image file. Args: experiment_service (ExperimentServiceStub): The gRPC service stub for experiment operations. experiment_id (str): The unique identifier of the experiment to run. Returns: Path: The complete file path to the generated CZI image file, constructed by combining the image output path with the experiment's output name and .czi extension. Raises: Exception: May raise exceptions from the underlying gRPC service calls if the experiment service is unavailable or if the experiment execution fails.
get_configured_containernames
async
#
get_configured_containernames(sample_carrier_service: SampleCarrierServiceStub, experiment_id: str) -> list[str]
Retrieve a list of configured containers for a specific experiment.
Parameters:
-
sample_carrier_service(SampleCarrierServiceStub) –The gRPC service stub for sample carrier operations.
-
experiment_id(str) –The unique identifier of the experiment to get configured containers for.
Returns:
-
list[str]–List[str]: A list of names of the configured containers associated with the specified experiment.
Raises:
-
RpcError–If the gRPC call fails or the experiment ID is not found.