Skip to main content

csv_report_algorithm

Algorithm for outputting results to CSV on the pod-side.

Classes

CSVReportAlgorithm

class CSVReportAlgorithm(    datastructure: DataStructure,    save_path: Optional[Union[str, os.PathLike]] = None,    original_cols: Optional[list[str]] = None,    rename_columns: Optional[Mapping[str, str]] = None,    columns_to_drop: Optional[list[str]] = None,    columns_to_drop_prefix: Optional[list[str]] = None,    columns_to_include: Optional[list[str]] = None,    filter: Optional[list[Union[ColumnFilter, MethodFilter]]] = None,    sorting_columns: Optional[dict[str, DFSortType]] = None,    decimal_places: int = 2,    ophthalmology_args: Optional[OphthalmologyArgs] = None,    trial_name: Optional[str] = None,    aux_cols: Optional[list[str]] = None,    match_patient_visit: Optional[MatchPatientVisit] = None,    matched_csv_path: Optional[Union[str, os.PathLike]] = None,    produce_matched_only: bool = True,    produce_trial_notes_csv: bool = False,    csv_extensions: Optional[list[str]] = None,    **kwargs: Any,):

Algorithm for generating the CSV results reports.

This is the unified CSV report algorithm that combines functionality from both the original CSVReportAlgorithm and CSVReportGeneratorOphthalmologyAlgorithm.

Arguments

  • datastructure: The data structure to use for the algorithm.
  • original_cols: The tabular columns from the datasource to include in the report. If not specified it will include all tabular columns.
  • rename_columns: A dictionary mapping old column names to new names.
  • columns_to_drop: A list of column names to exclude from the output.
  • columns_to_drop_prefix: A list of prefixes; columns starting with any of these prefixes will be dropped from the output.
  • columns_to_include: A list of column names to include in the output, in the specified order. Columns not in this list are excluded. Columns in the list but missing from data are silently skipped. Takes precedence over original_cols if both are specified.
  • filter: A list of ColumnFilter instances for filtering data.
  • sorting_columns: A dictionary of columns to sort by (column: 'asc'|'desc').
  • decimal_places: Number of decimal places to round to. Defaults to 2.
  • ophthalmology_args: Container for ophthalmology-specific options.
  • trial_name: (Deprecated) Use ophthalmology_args.trial_name instead.
  • aux_cols: (Deprecated) Use ophthalmology_args.aux_cols instead.
  • match_patient_visit: (Deprecated) Use ophthalmology_args instead.
  • produce_matched_only: (Deprecated) Use ophthalmology_args instead.
  • produce_trial_notes_csv: (Deprecated) Use ophthalmology_args instead.
  • csv_extensions: (Deprecated) Use ophthalmology_args instead.

Attributes

  • original_cols: The columns from the datasource to include in the report. If not specified it will include all columns.
  • rename_columns: A dictionary mapping old column names to new names.
  • columns_to_drop: A list of column names to exclude from the output.
  • columns_to_drop_prefix: A list of prefixes; columns starting with any of these prefixes will be dropped from the output.
  • columns_to_include: A list of column names to include in the output, in the specified order, including results. Columns not in this list are excluded. Columns in the list but missing from data are silently skipped. Takes precedence over original_cols if both are specified.
  • filter: A list of filters instances for filtering data.
  • sorting_columns: A dictionary of columns to sort by (column: 'asc'|'desc').
  • decimal_places: Number of decimal places to round to. Defaults to 2.
  • ophthalmology_args: Container for ophthalmology-specific options.

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.csv_report_algorithm._WorkerSide:

Inherited from:

BaseNonModelAlgorithmFactory.worker :

Worker-side of the algorithm.

MatchPatientVisit

class MatchPatientVisit(    cols_to_match: list[str],    divergent_col: str,    date_time_col: str,    how: DFMergeType = 'outer',):

Dataclass for matching patient visits.

Allows matching of different scans and results for the same patient visit. Only two records can be matched for the same patient visit.

Arguments

  • cols_to_match: List of columns on which to match.
  • divergent_col: Column containing the divergent strings for the same patient. E.g. the column indicating whether the scan was performed on the left or right eye.
  • date_time_col: The column indicating the date of the patient visit.

Variables

  • static cols_to_match : list[str]
  • static date_time_col : str
  • static divergent_col : str
  • static how : Literal['inner', 'outer', 'left', 'right']

OphthalmologyArgs

class OphthalmologyArgs(    trial_name: Optional[str] = None,    aux_cols: Optional[list[str]] = None,    match_patient_visit: Optional[MatchPatientVisit] = None,    produce_matched_only: bool = True,    produce_trial_notes_csv: bool = False,    csv_extensions: Optional[list[str]] = None,):

Container for ophthalmology-specific arguments.

This groups ophthalmology-related options that were previously part of CSVReportGeneratorOphthalmologyAlgorithm.

Arguments

  • trial_name: The name of the trial for the csv report. If provided, the CSV will be saved as "trial_name"-prescreening-patients-"date".csv.
  • aux_cols: The auxiliary columns from other datasources to include in the report. If not specified, will use defaults.
  • match_patient_visit: Used for matching the same patient visit.
  • produce_matched_only: If True, only the matched CSV will be generated at the end of the run. If False, both the non-matched and matched CSV will be generated.
  • produce_trial_notes_csv: If True, a CSV file containing the trial notes will be generated at the end of the run.
  • csv_extensions: List of named CSV extension functions that will be applied to the output CSV just before saving to file.

Variables

  • static aux_cols : Optional[list[str]]
  • static csv_extensions : Optional[list[str]]
  • static produce_matched_only : bool
  • static produce_trial_notes_csv : bool
  • static trial_name : Optional[str]