Skip to main content

Creating splits of whole slide image scan data for digital pathology deep learning applications

Project description

Ballatrix Split

A microservice creating data splits for deep learning applications in digital pathology.

It operates on a storage sqlite database created by the bellastore package.
This database is particularly helpful when querying metadata of specific slides for downstream tasks via our custom digital pathology API bellapi.

Installation

The source code is currently hosted under https://github.com/spang-lab/bellasplit.

Binary installers are available at PyPi.

pip install bellasplit

Usage

Under docs/.env you find a simple template for an .env file that needs to be located in your current environment and hold the path to a yaml config file. A minimal config file is provided under docs/bellameta.yaml. This config in particular defines the valid SPLITNAMEs available to this package.

from dotenv import load_dotenv
load_dotenv()

from bellasplit.types import Splitname
print(Splitname.list())

In order to fetch data for a new split the DataSource interface is to be used, implementing the get_data method.

from bellameta import types as t

from bellasplit.database import Db
from bellasplit.base_split import DataSource, Split, SplitWriter

class Subtyping(DataSource):
    def __init__(self,
                 db: Db):
        super().__init__(db = db,
                            task= t.Task.Subtyping)

    
    def get_data(self, **kwargs):
        # here we have room for fetching and modifying the data
        # in this minimal example we simply call the filter method, i.e.,
        # the fetched data results from searching the data that
        # satisfies the conditions specified in **kwargs
        data = self.filter(**kwargs)
        return data

In order to fetch the data filters can be defined via **kwargs:

db = Db()
source = Subtyping(db=db)

# the conditions to filter for
kwargs = {
    'stain': [t.Stain.HE],
    'class': [t.Subtype.DLBCL, t.Subtype.FL],
    'cohort': [t.Cohort.Example]
}

source_data = source.get_data(**kwargs)

In order to create and write the final split the Split and SplitWriter classes are used:

split = Split(source_data = source_data, splitname = Splitname.from_int(0), test_size = 0.4, val_size=0.2)
writer = SplitWriter(db=db, split=split)
writer.write()

Documentation

Along with the source code, under docs/demo.ipynb, we provide a demo leading you through the features of this package via an application scenario. For further documentation see also the test suite.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bellasplit-1.1.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bellasplit-1.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file bellasplit-1.1.0.tar.gz.

File metadata

  • Download URL: bellasplit-1.1.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for bellasplit-1.1.0.tar.gz
Algorithm Hash digest
SHA256 f33fc928a8dd7469ab498069df5313867ac49bb0a99d55aa25bfa4a62dadfc09
MD5 ee546fa4af21e303d759a77f80768518
BLAKE2b-256 3cd60ec6e467814f4274eb755e7a32a5873a1c3b42dd64d2ab8ab9ef43059913

See more details on using hashes here.

File details

Details for the file bellasplit-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: bellasplit-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for bellasplit-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8e70a53f6201b2b3705a8745153aac7c3ba1ead97beb7f183e263827b9a03e2
MD5 55b3ec6ac88b3a312aad8a03ef09cc3f
BLAKE2b-256 6dc4aea6a270f75c1a2f2a86b4776c1e3a418259be84cdca416b6f978a5a0e88

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page