pycroglia.core.io package
Subpackages
Submodules
- class pycroglia.core.io.output.AnalysisSummary(file, avg_centroid_distance, total_territorial_volume, total_unoccupied_volume, percent_occupied_volume)[source]
Bases:
objectSummary statistics for microglia analysis.
- Parameters:
- class pycroglia.core.io.output.AnalysisSummaryConfig(file_txt, avg_centroid_distance_txt, total_territorial_volume_txt, total_unoccupied_volume_txt, percent_occupied_volume_txt)[source]
Bases:
objectConfiguration for column headers in analysis summary output.
- Parameters:
- class pycroglia.core.io.output.CellAnalysis(cell_territory_volume, cell_volume, ramification_index, number_of_endpoints, number_of_branches, avg_branch_length, max_branch_length, min_branch_length, branch_analysis, full_cell_analysis)[source]
Bases:
objectAnalysis results for an individual microglia cell.
- Parameters:
- class pycroglia.core.io.output.CellAnalysisConfig(cell_territory_volume_txt, cell_volume_txt, ramification_index_txt, number_of_endpoints_txt, number_of_branches_txt, avg_branch_length_txt, max_branch_length_txt, min_branch_length_txt)[source]
Bases:
objectConfiguration for column headers in per-cell analysis output.
- Parameters:
- class pycroglia.core.io.output.ExcelOutput(summary_title=None, per_cell_title=None, summary_config=None, per_cell_config=None)[source]
Bases:
OutputWriterExcel output writer for microglia analysis results.
Creates Excel workbooks with separate sheets for summary statistics and per-cell analysis data.
- Parameters:
summary_title (str | None)
per_cell_title (str | None)
summary_config (AnalysisSummaryConfig | None)
per_cell_config (CellAnalysisConfig | None)
- DEFAULT_FILE_EXTENSION = '.xlsx'
- DEFAULT_NAME = 'Multi Sheet Excel'
- DEFAULT_PER_CELL_SHEET_TITLE = 'PerCell'
- DEFAULT_SUMMARY_SHEET_TITLE = 'Summary'
- classmethod get_name()[source]
Return the display name of the Excel writer.
- Returns:
Name of the writer.
- Return type:
- write(file_path, data)[source]
Write analysis data to an Excel file.
- Parameters:
file_path (str) – Path where the Excel file should be saved.
data (FullAnalysis) – Complete analysis results to write.
- class pycroglia.core.io.output.FullAnalysis(summary, cells)[source]
Bases:
objectComplete analysis results containing summary and per-cell data.
- Parameters:
summary (AnalysisSummary)
cells (List[CellAnalysis])
- summary
Overall analysis summary statistics.
- cells
List of individual cell analysis results.
- Type:
- cells: List[CellAnalysis]
- summary: AnalysisSummary
- class pycroglia.core.io.output.JSONOutput(summary_config=None, per_cell_config=None, indent=4)[source]
Bases:
OutputWriterJSON output writer for microglia analysis results.
Serializes analysis data to JSON format using configured field names for consistency with other output formats.
- Parameters:
summary_config (AnalysisSummaryConfig | None)
per_cell_config (CellAnalysisConfig | None)
indent (int | None)
- DEFAULT_FILE_EXTENSION = '.json'
- DEFAULT_NAME = 'JSON File'
- classmethod get_name()[source]
Return the display name of the JSON writer.
- Returns:
Name of the writer.
- Return type:
- write(file_path, data)[source]
Write analysis data to a JSON file.
- Parameters:
file_path (str) – Path where the JSON file should be saved.
data (FullAnalysis) – Complete analysis results to write.
- class pycroglia.core.io.output.OutputWriter[source]
Bases:
ABCAbstract base class for writing analysis results to files.
- classmethod get_name()[source]
Return the display name of the writer.
- Returns:
Name of the writer.
- Return type:
- classmethod get_writers()[source]
Return all non-abstract subclasses of OutputWriter.
- Returns:
List of OutputWriter subclasses.
- Return type:
- write(file_path, data)[source]
Write analysis data to a file.
- Parameters:
file_path (str) – Path where the output file should be saved.
data (FullAnalysis) – Complete analysis results to write.
- class pycroglia.core.io.readers.LsmReader(path)[source]
Bases:
MultiChReaderReader for LSM image files.
- Raises:
PycrogliaException(1000) – If the path doesn’t exist.
PycrogliaException(1002) – If the file doesn’t have the expected extension.
- Parameters:
path (str)
- EXTENSION_ERROR_CODE = 1002
- VALID_EXTENSIONS = ['.lsm']
- read(ch, ch_interest)[source]
Reads the contents of the file and returns the specified channels.
- Parameters:
- Returns:
The file data.
- Return type:
NDArray
- Raises:
PycrogliaException(1003) – If the channel value is invalid.
PycrogliaException(1004) – If the channel of interest is out of range.
- validate_channels(ch, ch_interest)[source]
Validates the channel and channel of interest values.
- Parameters:
- Raises:
PycrogliaException(1003) – If the channel value is invalid.
PycrogliaException(1004) – If the channel of interest is out of range.
- Return type:
None
- validate_path()[source]
Validates the path of the file.
- Raises:
PycrogliaException(1000) – If the path doesn’t exist.
PycrogliaException(1002) – If the file doesn’t have the expected extension.
- Return type:
None
- class pycroglia.core.io.readers.MultiChReader[source]
Bases:
ABCAbstract base class for multi-channel image readers.
- class pycroglia.core.io.readers.TiffReader(path)[source]
Bases:
MultiChReaderReader for TIFF image files.
- Parameters:
path (str)
- EXTENSION_ERROR_CODE = 1001
- VALID_EXTENSIONS = ['.tif', '.tiff']
- read(ch, ch_interest)[source]
Reads the contents of the file and returns the specified channels.
- Parameters:
- Returns:
The file data.
- Return type:
NDArray
- Raises:
PycrogliaException(1003) – If the channel value is invalid.
PycrogliaException(1004) – If the channel of interest is out of range.
- validate_channels(ch, ch_interest)[source]
Validates the channel and channel of interest values.
- Parameters:
- Raises:
PycrogliaException(1003) – If the channel value is invalid.
PycrogliaException(1004) – If the channel of interest is out of range.
- Return type:
None
- validate_path()[source]
Validates the path of the file.
- Raises:
PycrogliaException(1000) – If the path doesn’t exist.
PycrogliaException(1001) – If the file doesn’t have the expected extension.
- Return type:
None
- pycroglia.core.io.readers.create_channeled_reader(path)[source]
Creates a MultiChReader instance based on the file extension.
- Parameters:
path (str) – Path to the image file.
- Returns:
An instance of TiffReader or LsmReader.
- Return type:
- Raises:
PycrogliaException(1005) – If the file extension is not supported.