Skip to main content

algorithms

Algorithms for remote processing of data.

Federated algorithm plugins can also be imported from this package.

Module

Submodules

Classes

GCCCalculationAlgorithm

class GCCCalculationAlgorithm(    datastructure: DataStructure,    region_radius_mm: float = 3.0,    inner_layer_name: str = 'RNFL',    outer_layer_name: str = 'IPL',    macula_landmark_idx: int = 2,    strict_measurement: bool = True,    **kwargs: Any,):

Algorithm for calculating Ganglion Cell Complex (GCC).

The GCC is the complex of the three innermost retinal layers that are particularly affected by glaucoma because they contain all parts of the ganglion cells (axons, cell bodies, and dendrites). It is composed of the RNFL + GCL + IPL layers.

The GCC asymmetry index is the ratio of thickness of the superior region to the inferior region, in a 3mm radius around the macula center.

The algorithm uses the _BaseThicknessCalculationAlgo to build a 2D thickness map from B-scan layer segmentations, based on (RNFL to IPL distance) and samples this map using a circular region centered on the macula coordinates.

The algorithm supports fallback layer selection: if RNFL or IPL are not available, it will automatically use the next closest layer in the retinal layer order (unless strict_measurement is enabled). The actual layers used are reported in the output.

Arguments

  • datastructure: The data structure to use for the algorithm.
  • region_radius_mm: Radius of circular region for GCC calculation in mm
  • (default: 1.0).
  • inner_layer_name: Name of the innermost layer to use (default: "RNFL").
  • outer_layer_name: Name of the outermost layer to yse (default: "IPL").
  • macula_landmark_idx: Index of macula landmark to use: 0=start, 1=end, 2=middle
  • (default: 2).
  • strict_measurement: If True, only calculate if both RNFL and IPL are available. If False, use next available layer as fallback (default: True).

Variables

  • static fields_dict : ClassVar[T_FIELDS_DICT]

Methods


modeller

def modeller(    self, *, context: ProtocolContext, **kwargs: Any,)> NoResultsModellerAlgorithm:

Inherited from:

BaseNonModelAlgorithmFactory.modeller :

Modeller-side of the algorithm.

worker

def worker(    self, *, context: ProtocolContext, **kwargs: Any,)> bitfount.federated.algorithms.ophthalmology.gcc_calculation_algorithm._GCCWorkerSide:

Inherited from:

BaseNonModelAlgorithmFactory.worker :

Worker-side of the algorithm.

S3UploadAlgorithmWithMRNTracking

class S3UploadAlgorithmWithMRNTracking(    datastructure: DataStructure,    s3_bucket: Optional[str] = None,    aws_region: Optional[str] = None,    aws_profile: Optional[str] = 'default',    upload_url_expiration: int = 3,    **kwargs: Any,):

S3 Upload Algorithm with MRN tracking for Charcoal protocols.

This extends S3UploadAlgorithm to automatically track which MRNs have been successfully uploaded to S3. This is used in per-batch reduce/upload scenarios where we need to track which MRNs have been uploaded across multiple batches.

Important Notes:

  • MRN tracking is optional and only works for CSV files that contain an MRN column with valid MRN values.
  • Non-CSV files are still uploaded successfully, but MRN tracking is skipped.
  • CSV files without an MRN column are still uploaded successfully, but MRN tracking is skipped.
  • CSV files with an MRN column but no MRN values are still uploaded successfully, but MRN tracking is skipped.
  • The upload functionality works for any file type, regardless of whether MRN tracking can be performed.

Arguments

  • datastructure: The data structure to use for the algorithm.
  • s3_bucket: AWS S3 Bucket name to upload files into.
  • aws_region: AWS region in which the bucket resides.
  • aws_profile: Name of AWS profile with which to generate the pre-signed POST.
  • upload_url_expiration: Expiration time in hours for the presigned S3 URLs. Defaults to 3 hours.

Methods


modeller

def modeller(    self, *, context: ProtocolContext, **kwargs: Any,)> bitfount.federated.algorithms.s3_upload_algorithm._ModellerSide:

Inherited from:

S3UploadAlgorithm.modeller :

Modeller-side of the algorithm.

validate_required_fields

def validate_required_fields(self)> None:

Inherited from:

S3UploadAlgorithm.validate_required_fields :

Raises an error if s3_bucket or aws_region is not supplied.

worker

def worker(    self,    *,    context: ProtocolContext,    **kwargs: Any,)> bitfount.federated.algorithms.ophthalmology.s3_upload_algorithm_with_mrn_tracking._WorkerSide:

Worker-side of the algorithm with MRN tracking.