Skip to content

Commit

Permalink
Merge pull request #30 from BrainLesion/27-broken-docs
Browse files Browse the repository at this point in the history
27 broken docs
  • Loading branch information
MarcelRosier authored Aug 29, 2024
2 parents 971969d + 5beffe6 commit 38fdced
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
31 changes: 28 additions & 3 deletions brats/core/brats_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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")

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion brats/core/inpainting_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 6 additions & 10 deletions docs/source/algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
2 changes: 1 addition & 1 deletion docs/source/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Constants
Constants used in the package
------------------------------

.. automodule:: brats.constants
.. automodule:: brats.utils.constants
:members:
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38fdced

Please sign in to comment.