pycroglia.core.io package
Subpackages
Submodules
Export cell masks and skeleton branch surfaces to mesh and VTK volume formats.
Skeleton branch arrays from analysis are XY-cropped; they are embedded into each cell’s full (Z, Y, X) mask shape before marching cubes so outputs share one volume frame.
- class pycroglia.core.io.geometry_export.GeometryExportSelection(skeleton_obj: 'bool' = False, skeleton_ply: 'bool' = False, skeleton_vtp: 'bool' = False, skeleton_vtk: 'bool' = False, mask_obj: 'bool' = False, mask_ply: 'bool' = False, mask_vtp: 'bool' = False, mask_vtk: 'bool' = False, mask_volume_vtk: 'bool' = False, mask_volume_vti: 'bool' = False)[source]
Bases:
object- Parameters:
- pycroglia.core.io.geometry_export.export_geometry(out_root, cells_masks, cells, scale, zscale, selection)[source]
Write selected geometry under
out_root/{fmt}/.Directory layout
- out_root/
obj/ cell_000_skeleton.obj, cell_000_surface.obj, … ply/ cell_000_skeleton.ply, cell_000_surface.ply, … vtp/ cell_000_skeleton.vtp, cell_000_surface.vtp, … vtk/ cell_000_skeleton.vtk, cell_000_surface.vtk, …
cell_000_boolean_mask.vtk
vti/ cell_000_boolean_mask.vti
- returns:
List of human-readable messages for skipped cells or failures (non-fatal).
- class pycroglia.core.io.output.AnalysisMetadata(file_path, gray_filter_value, min_size, erosion_radius, scale, z_scale, segmented_cell_indices, selected_cell_indices, rejected_cell_indices, skeletonization_method='slimskel3d')[source]
Bases:
objectMetadata about the analysis pipeline parameters and cell indices.
- Parameters:
- final_cell_indices
List of cell indices not rejected (kept after selection).
- 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.BranchLengthsXlsxOutput[source]
Bases:
OutputWriterXLSX output writer for per-cell branch lengths.
Creates a simple XLSX file where each row represents a cell (by index) and each column represents a branch length. No headers are written.
- DEFAULT_FILE_EXTENSION = '.xlsx'
- DEFAULT_NAME = 'Branch Lengths XLSX'
- classmethod get_name()[source]
Return the display name of the writer.
- Returns:
Name of the writer.
- Return type:
- write(file_path, data, meta)[source]
Write per-cell branch lengths to an XLSX file.
- Parameters:
file_path (str) – Path where the XLSX file should be saved.
data (FullAnalysis) – Complete analysis results containing branch data.
meta (AnalysisMetadata)
- 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, meta)[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.
meta (AnalysisMetadata)
- 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, meta)[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.
meta (AnalysisMetadata)
- class pycroglia.core.io.output.OutputWriter[source]
Bases:
ABCAbstract base class for writing analysis results to files.
- abstractmethod 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:
- abstractmethod write(file_path, data, meta)[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.
meta (AnalysisMetadata) – Metadata associated with the analysis.
- 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.