algorithms
Algorithms for remote processing of data.
Federated algorithm plugins can also be imported from this package.
Module
Submodules
- bitfount.federated.algorithms.base - Base classes for all algorithms.
- bitfount.federated.algorithms.csv_report_algorithm - Algorithm for outputting results to CSV on the pod-side.
- bitfount.federated.algorithms.ehr - Algorithms for Electronic Health Records (EHR) data.
- bitfount.federated.algorithms.filtering_algorithm - Algorithm for filtering data records based on configurable strategies.
- bitfount.federated.algorithms.hugging_face_algorithms - Algorithms for remote Hugging Face models.
- bitfount.federated.algorithms.model_algorithms - Algorithms for remote/federated model training on data.
- bitfount.federated.algorithms.monai_algorithms - Algorithms for MONAI medical imaging models.
- bitfount.federated.algorithms.post_processing_base - Base classes and utilities for post-processors.
- bitfount.federated.algorithms.private_sql_query - Private SQL query algorithm.
- bitfount.federated.algorithms.s3_upload_algorithm - Algorithm for uploading documents to an AWS S3 bucket.
- bitfount.federated.algorithms.sql_query - SQL query algorithm.
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.
Ancestors
Methods
modeller
def modeller( self, *, context: ProtocolContext, **kwargs: Any,) ‑> bitfount.federated.algorithms.s3_upload_algorithm._ModellerSide:Inherited from:
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.