diff --git a/brats/core/brats_algorithm.py b/brats/core/brats_algorithm.py index e117f37..faa4af4 100644 --- a/brats/core/brats_algorithm.py +++ b/brats/core/brats_algorithm.py @@ -64,7 +64,13 @@ def _standardize_batch_inputs( def _process_single_output( self, tmp_output_folder: Path | str, subject_id: str, output_file: Path ) -> None: - # TODO add docstring + """Process the output of a single inference run and save it in the specified file. + + Args: + tmp_output_folder (Path | str): Folder with the algorithm output + subject_id (str): Subject ID of the output + output_file (Path): Path to the desired output file + """ # rename output algorithm_output = Path(tmp_output_folder) / OUTPUT_NAME_SCHEMA[ self.task @@ -81,7 +87,13 @@ def _process_batch_output( output_folder: Path, mapping: dict[str, str], ) -> None: - # TODO add docstring + """Process the outputs of a batch inference run and save them in the specified folder. + + Args: + tmp_output_folder (Path | str): Folder with the algorithm outputs + output_folder (Path): Folder to save the outputs + mapping (dict[str, str]): Mapping from internal to external subject names + """ # move outputs and change name back to initially provided one output_folder = Path(output_folder) output_folder.mkdir(parents=True, exist_ok=True) @@ -97,7 +109,14 @@ def _infer_single( inputs: dict[str, Path | str], output_file: Path | str, log_file: Optional[Path | str] = None, - ): + ) -> None: + """Perform a single inference run with the provided inputs and save the output in the specified file. + + Args: + inputs (dict[str, Path | str]): Input Images for the task + output_file (Path | str): File to save the output + log_file (Optional[Path | str], optional): Log file with extra information. Defaults to None. + """ with InferenceSetup(log_file=log_file) as (tmp_data_folder, tmp_output_folder): logger.info(f"Performing single inference") @@ -130,7 +149,13 @@ def _infer_batch( output_folder: Path | str, log_file: Optional[Path | str] = None, ): + """Perform a batch inference run with the provided inputs and save the outputs in the specified folder. + Args: + data_folder (Path | str): Folder with the input data + output_folder (Path | str): Folder to save the outputs + log_file (Optional[Path | str], optional): Log file with extra information. Defaults to None. + """ with InferenceSetup(log_file=log_file) as (tmp_data_folder, tmp_output_folder): # find subjects diff --git a/brats/core/inpainting_algorithms.py b/brats/core/inpainting_algorithms.py index c55ba87..741335e 100644 --- a/brats/core/inpainting_algorithms.py +++ b/brats/core/inpainting_algorithms.py @@ -93,7 +93,7 @@ def infer_single( """Perform inpainting task on a single subject with the provided images and save the result to the output file. Args: - t1n (Path | str): Path to the T1n image + t1n (Path | str): Path to the voided T1n image mask (Path | str): Path to the mask image output_file (Path | str): Path to save the segmentation log_file (Path | str, optional): Save logs to this file diff --git a/docs/source/algorithms.rst b/docs/source/algorithms.rst index 98de183..6a72be6 100644 --- a/docs/source/algorithms.rst +++ b/docs/source/algorithms.rst @@ -5,30 +5,26 @@ The following classes provide the top performing algorithms from several BraTS c All algorithms can be used for a single subject inference (one set of MRI scans) or for a batch of multiple subjects with the respective methods inherited from the base class (BraTSAlgorithm). -Challenge Algorithms +Segmentation Algorithms -------------------------------------- -.. autoclass:: brats.AdultGliomaSegmenter +.. automodule:: brats.core.segmentation_algorithms -.. autoclass:: brats.AfricaSegmenter - - -.. autoclass:: brats.MeningiomaSegmenter - +Inpainting Algorithms +-------------------------------------- -.. autoclass:: brats.MetastasesSegmenter +.. automodule:: brats.core.inpainting_algorithms -.. autoclass:: brats.PediatricSegmenter Abstract Base Class -------------------------------------- -.. autoclass:: brats.algorithms.BraTSAlgorithm +.. automodule:: brats.core.brats_algorithm diff --git a/docs/source/constants.rst b/docs/source/constants.rst index 29e295b..9daaa5f 100644 --- a/docs/source/constants.rst +++ b/docs/source/constants.rst @@ -4,5 +4,5 @@ Constants Constants used in the package ------------------------------ -.. automodule:: brats.constants +.. automodule:: brats.utils.constants :members: \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 5ca431c..3e41ac7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,11 +39,11 @@ docker = ">=7.0.0" rich = ">=13.0.0" PyYAML = ">=6.0.1" dacite = ">=1.8.0" -loguru = ">=0.6.0" +loguru = ">=0.7.0" nibabel = ">=5.0.0" [tool.poetry.dev-dependencies] -pytest = "^6.2.5" +pytest = ">=8.0.0" [tool.poetry.group.docs] optional = true