insitupy.InSituExperiment.from_regions

insitupy.InSituExperiment.from_regions#

classmethod InSituExperiment.from_regions(data, region_key, region_names=None)#

Creates an InSituExperiment object from specified regions in the given InSituData.

Parameters:
  • data (InSituData) – The input data containing regions to extract.

  • region_key (str) – The key identifying the region of interest in data.regions.

  • region_names (Optional[Union[List[str], str]]) – A list of region names or a single region name to include

  • None (in the experiment. If)

  • included. (all regions under the specified region_key are)

Returns:

An instance of InSituExperiment containing the cropped data and metadata for the specified regions.

Return type:

InSituExperiment

Notes

  • The region_names parameter is converted to a list if a single string is provided.

  • The method iterates over the sorted list of region names in the region_key dataframe,

    crops the data for each region, and adds it to the experiment along with its metadata.