From e73139a54c903a48781c4b395670f9ae39fb9acb Mon Sep 17 00:00:00 2001 From: Taha Abdullah Date: Thu, 10 Oct 2024 10:42:04 +0200 Subject: [PATCH] PR 590 Review changes: - quicktest.yaml: commenting out trigger on pull request - FastSurferCNN.utils.metrics.py: docstring changes --- .github/workflows/quicktest.yaml | 4 ++-- FastSurferCNN/utils/metrics.py | 33 +++++++++++++++++--------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/quicktest.yaml b/.github/workflows/quicktest.yaml index 29cd344d..0a38bfb3 100644 --- a/.github/workflows/quicktest.yaml +++ b/.github/workflows/quicktest.yaml @@ -1,6 +1,6 @@ name: quicktest -# File: quicktest.yaml +# File: quicktest_runner.yaml # Author: Taha Abdullah # Created on: 2023-07-10 # Functionality: This workflow runs FastSurfer on MRI data and runs pytest to check if the results are acceptable. It @@ -73,4 +73,4 @@ jobs: - name: Run pytest run: | source /venv-pytest/bin/activate - python -m pytest test/quick_test + python -m pytest test/quick_test \ No newline at end of file diff --git a/FastSurferCNN/utils/metrics.py b/FastSurferCNN/utils/metrics.py index e3ef9c5e..b7234fda 100644 --- a/FastSurferCNN/utils/metrics.py +++ b/FastSurferCNN/utils/metrics.py @@ -109,17 +109,20 @@ class DiceScore: """ Accumulating the component of the dice coefficient i.e. the union and intersection. - Args: - op (callable): a callable to update accumulator. Method's signature is `(accumulator, output)`. - For example, to compute arithmetic mean value, `op = lambda a, x: a + x`. - output_transform (callable, optional): a callable that is used to transform the - :class:`~ignite.engine.Engine`'s `process_function`'s output into the - form expected by the metric. This can be useful if, for example, you have a multi-output model and - you want to compute the metric with respect to one of the outputs. - device (str of torch.device, optional): device specification in case of distributed computation usage. - In most of the cases, it can be defined as "cuda:local_rank" or "cuda" - if already set `torch.cuda.set_device(local_rank)`. By default, if a distributed process group is - initialized and available, device is set to `cuda`. + Parameters + ---------- + op : callable + A callable to update the accumulator. Method's signature is `(accumulator, output)`. + For example, to compute arithmetic mean value, `op = lambda a, x: a + x`. + output_transform : callable, optional + A callable that is used to transform the :class:`~ignite.engine.Engine`'s `process_function`'s output into the + form expected by the metric. This can be useful if, for example, you have a multi-output model and + you want to compute the metric with respect to one of the outputs. + device : str or torch.device, optional + Device specification in case of distributed computation usage. + In most cases, it can be defined as "cuda:local_rank" or "cuda" + if already set `torch.cuda.set_device(local_rank)`. By default, if a distributed process group is + initialized and available, the device is set to `cuda`. """ def __init__( self, @@ -154,8 +157,8 @@ def _check_output_type(self, output): """ Check the type of the output and raise an error if it doesn't match expectations. - Parameters: - ----------- + Parameters + ---------- output : tuple The output to be checked, expected to be a tuple. """ @@ -168,8 +171,8 @@ def _update_union_intersection(self, batch_output, labels_batch): """ Update the union and intersection matrices based on batch predictions and labels. - Parameters: - ----------- + Parameters + ---------- batch_output : torch.Tensor Batch predictions from the model.