napari_track_edit.example_data ============================== .. py:module:: napari_track_edit.example_data Attributes ---------- .. autoapisummary:: napari_track_edit.example_data.logger napari_track_edit.example_data.ZENODO_RAW_URL napari_track_edit.example_data.ZENODO_LABELS_URL napari_track_edit.example_data.CTC_URL_TEMPLATE napari_track_edit.example_data.HELA_CROP napari_track_edit.example_data.ZENODO_ARRAYS napari_track_edit.example_data.CTC_ARRAYS napari_track_edit.example_data.ReportHook napari_track_edit.example_data.SAMPLE_TRACKS Classes ------- .. autoapisummary:: napari_track_edit.example_data.SampleTracks Functions --------- .. autoapisummary:: napari_track_edit.example_data.user_data_dir napari_track_edit.example_data._ensure_dataset napari_track_edit.example_data._zenodo_raw_layer napari_track_edit.example_data._ctc_raw_layer napari_track_edit.example_data.Mouse_Embryo_Membrane napari_track_edit.example_data.Fluo_N2DL_HeLa napari_track_edit.example_data.Fluo_N2DL_HeLa_crop napari_track_edit.example_data.read_zenodo_dataset napari_track_edit.example_data.read_ctc_dataset napari_track_edit.example_data._download_dir napari_track_edit.example_data.download_zenodo_dataset napari_track_edit.example_data.download_ctc_dataset napari_track_edit.example_data.convert_4d_arr_to_zarr napari_track_edit.example_data.convert_to_zarr napari_track_edit.example_data.Fluo_N2DL_HeLa_crop_raw napari_track_edit.example_data.Mouse_Embryo_Membrane_raw napari_track_edit.example_data._drive_download_url napari_track_edit.example_data.sample_tracks_path napari_track_edit.example_data.raw_data_is_downloaded napari_track_edit.example_data.download_zipped_store Module Contents --------------- .. py:data:: logger .. py:data:: ZENODO_RAW_URL :value: 'https://zenodo.org/records/13903500/files/imaging.zip' .. py:data:: ZENODO_LABELS_URL :value: 'https://zenodo.org/records/13903500/files/segmentation.zip' .. py:data:: CTC_URL_TEMPLATE :value: 'http://data.celltrackingchallenge.net/training-datasets/{ds_name}.zip' .. py:data:: HELA_CROP .. py:data:: ZENODO_ARRAYS :value: ('01_membrane', '01_labels') .. py:data:: CTC_ARRAYS :value: ('01', '01_ST') .. py:data:: ReportHook .. py:function:: user_data_dir() -> pathlib.Path The platformdirs "user data dir", where all example data is cached. Created if it does not exist yet. .. py:function:: _ensure_dataset(ds_name: str, data_dir: pathlib.Path, download: collections.abc.Callable[[], None], arrays: tuple[str, ...]) -> pathlib.Path Return the path to a dataset's zarr, downloading the dataset first if it is not there yet. A zarr missing any of the expected arrays (left behind by an interrupted download in older versions) is deleted and downloaded again. :param ds_name: Dataset name, the zarr is named after it :type ds_name: str :param data_dir: The directory the dataset is cached in :type data_dir: Path :param download: Fetches and converts the dataset :type download: Callable[[], None] :param arrays: Names of the arrays the zarr must contain :type arrays: tuple[str, ...] :returns: Path to the zarr holding the dataset :rtype: Path .. py:function:: _zenodo_raw_layer(ds_zarr: pathlib.Path) -> napari.types.LayerData The membrane intensity layer of a zenodo dataset zarr. .. py:function:: _ctc_raw_layer(ds_zarr: pathlib.Path, crop_region: bool) -> napari.types.LayerData The 01 training intensity layer of a CTC dataset zarr. .. py:function:: Mouse_Embryo_Membrane() -> list[napari.types.LayerData] Loads the Mouse Embryo Membrane raw data and segmentation data from the appdir "user data dir". Will download it from the Zenodo DOI if not present. :returns: An image layer of raw data and a segmentation labels layer :rtype: list[LayerData] .. py:function:: Fluo_N2DL_HeLa() -> list[napari.types.LayerData] Loads the Fluo-N2DL-HeLa 01 training raw data and silver truth from the appdir "user data dir". Will download it from the CTC and convert it to zarr if it is not present already. :returns: An image layer of 01 training raw data and a labels layer of 01 training silver truth labels :rtype: list[LayerData] .. py:function:: Fluo_N2DL_HeLa_crop() -> list[napari.types.LayerData] Loads the Fluo-N2DL-HeLa 01 training raw data and silver truth from the appdir "user data dir". Will download it from the CTC and convert it to zarr if it is not present already. :returns: An image layer of 01 training raw data and a labels layer of 01 training silver truth labels :rtype: list[LayerData] .. py:function:: read_zenodo_dataset(ds_name: str, raw_name: str, label_name: str, data_dir: pathlib.Path) -> list[napari.types.LayerData] Read a zenodo dataset (assumes pre-downloaded) and returns a list of layer data for making napari layers :param ds_name: name to give to the dataset :type ds_name: str :param raw_name: name of the file that points to the intensity data :type raw_name: str :param label_name: name of the file that points to the segmentation data :type label_name: str :param data_dir: Path to the directory containing the images :type data_dir: Path :returns: An image layer of raw data and a segmentation labels layer :rtype: list[LayerData] .. py:function:: read_ctc_dataset(ds_name: str, data_dir: pathlib.Path, crop_region=False) -> list[napari.types.LayerData] Read a CTC dataset from a zarr (assumes pre-downloaded and converted) and returns a list of layer data for making napari layers :param ds_name: Dataset name :type ds_name: str :param data_dir: Path to the directory containing the zarr :type data_dir: Path :returns: An image layer of 01 training raw data and a labels layer of 01 training silver truth labels :rtype: list[LayerData] .. py:function:: _download_dir(output: pathlib.Path) -> collections.abc.Iterator[pathlib.Path] A fresh scratch directory next to the output, deleted afterwards. Downloads are unpacked and converted there and only moved to the output once complete, so an interrupted download is not mistaken for existing data. .. py:function:: download_zenodo_dataset(ds_name: str, raw_name: str, label_name: str, data_dir: pathlib.Path, reporthook: ReportHook | None = None) -> None Download a sample dataset from zenodo doi and unzip it, then delete the zip. Then convert the tiffs to zarrs for the first training set consisting of 3D membrane intensity images and segmentation. :param ds_name: Name to give to the dataset :type ds_name: str :param raw_name: Name of the file that contains the intensity data :type raw_name: str :param label_name: Name of the file that contains the label data :type label_name: str :param data_dir: The directory in which to store the data. :type data_dir: Path :param reporthook: Called with the download progress. :type reporthook: ReportHook | None .. py:function:: download_ctc_dataset(ds_name: str, data_dir: pathlib.Path, reporthook: ReportHook | None = None) -> None Download a dataset from the Cell Tracking Challenge and unzip it, then delete the zip. Then convert the tiffs to zarrs for the first training set images and silver truth. :param ds_name: Dataset name, according to the CTC :type ds_name: str :param data_dir: The directory in which to store the data. :type data_dir: Path :param reporthook: Called with the download progress. :type reporthook: ReportHook | None .. py:function:: convert_4d_arr_to_zarr(tiff_file: pathlib.Path, zarr_path: pathlib.Path, zarr_group: str, relabel: bool = False) -> None Convert 4D tiff file to zarr array. Deletes the tiff after conversion. :param tiff_file: Path to the 4D tiff file :param zarr_path: Path to the zarr store to write to :param zarr_group: Name of the array within the zarr store :param relabel: If True, relabel segmentations to be unique across time .. py:function:: convert_to_zarr(tiff_path: pathlib.Path, zarr_path: pathlib.Path, zarr_group: str, relabel: bool = False) -> None Convert a directory of tiff files to a zarr array. Deletes tiffs after conversion. :param tiff_path: Path to directory containing tiff files (one per time point) :param zarr_path: Path to the zarr store to write to :param zarr_group: Name of the array within the zarr store :param relabel: If True, relabel segmentations to be unique across time .. py:function:: Fluo_N2DL_HeLa_crop_raw(reporthook: ReportHook | None = None) -> napari.types.LayerData Loads only the cropped raw data of Fluo-N2DL-HeLa (see Fluo_N2DL_HeLa_crop), downloading the dataset first if it is not present. :param reporthook: Called with the download progress. :type reporthook: ReportHook | None :returns: An image layer of the cropped 01 training raw data :rtype: LayerData .. py:function:: Mouse_Embryo_Membrane_raw(reporthook: ReportHook | None = None) -> napari.types.LayerData Loads only the raw data of Mouse_Embryo_Membrane, downloading the dataset first if it is not present. :param reporthook: Called with the download progress. :type reporthook: ReportHook | None :returns: An image layer of the membrane raw data :rtype: LayerData .. py:class:: SampleTracks Bases: :py:obj:`NamedTuple` Example tracks shown in the welcome widget, with their raw data. .. py:attribute:: url :type: str .. py:attribute:: store_name :type: str .. py:attribute:: raw_name :type: str .. py:attribute:: raw_zarr :type: str .. py:attribute:: raw_size :type: str .. py:attribute:: load_raw :type: collections.abc.Callable[..., napari.types.LayerData] .. py:function:: _drive_download_url(file_id: str) -> str Direct-download URL for a Google Drive file (skips the preview page). .. py:data:: SAMPLE_TRACKS :type: dict[str, SampleTracks] .. py:function:: sample_tracks_path(name: str, reporthook: ReportHook | None = None) -> pathlib.Path Return the local path to the example tracks geff with the given name, downloading it from Google Drive into the appdir "user data dir" first if it is not present yet. :param name: A key of SAMPLE_TRACKS :type name: str :param reporthook: Called with the download progress. :type reporthook: ReportHook | None :returns: Path to the geff store :rtype: Path .. py:function:: raw_data_is_downloaded(name: str) -> bool Whether the raw data belonging to a sample is already on disk, so that clicking the sample does not trigger a large download unannounced. :param name: A key of SAMPLE_TRACKS :type name: str :returns: True if the zarr holding the raw data exists :rtype: bool .. py:function:: download_zipped_store(url: str, output: pathlib.Path, reporthook: ReportHook | None = None) -> None Download a zip holding a store named like the output, and unpack it there. The zip is downloaded and unpacked next to the output, and only moved into place once complete, so an interrupted download is not mistaken for existing data. :param url: Download url of the zip :type url: str :param output: Path to put the store at. The zip must contain a directory with the same name. :type output: Path :param reporthook: Called with the download progress. :type reporthook: ReportHook | None