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.0.0.tar.gz (9.3 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.0.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bellasplit-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f7ba3a3db1458717c8c63d798a1dcebed6e013732e8fe99a6a9928c77fcbc28f
MD5 2f7f60ef9f628f492501098d86438856
BLAKE2b-256 87255ad6a4d01882cb122a4ee549abcc1c1a700a2e11a305ada8519919aad253

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bellasplit-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5e54bda1897986a7cc64d492b79dadf3c062fefbf7d13ff4a676afc87ebcd09
MD5 90bedf76c184580ef202160eecea501f
BLAKE2b-256 ddc30c9d347e2ff49f8557eccd2f2bd3335847232af9cea6f9a6927bd8b3790d

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