Skip to content

Commit

Permalink
PR 590 Review changes:
Browse files Browse the repository at this point in the history
- quicktest.yaml: commenting out trigger on pull request
- FastSurferCNN.utils.metrics.py: docstring changes
  • Loading branch information
taha-abdullah committed Oct 10, 2024
1 parent 462b00d commit c85f457
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 37 deletions.
33 changes: 11 additions & 22 deletions .github/workflows/quicktest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: quicktest-runner

# 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
Expand All @@ -16,25 +16,19 @@ name: quicktest-runner
# - FS_LICENSE: Path to the FreeSurfer license file.

on:
pull_request:
branches:
- dev
- stable
# pull_request:
# branches:
# - dev
# - stable
workflow_dispatch:

jobs:
# Checkout repo
checkout:
run-quicktest:
runs-on: self-hosted
steps:
# Checkout fastsurfer
- uses: actions/checkout@v2

# Create conda environment, install packages, and run Fastsurfer
run-fastsurfer:
runs-on: self-hosted
needs: checkout
steps:
# Check if the Environment Variables used in further steps are present
# Check if the Environment Variables used in further steps are present
- name: Check Environment Variables
run: |
REQUIRED_ENV_VARS=(
Expand Down Expand Up @@ -71,17 +65,12 @@ jobs:
export THIS_RUN_OUTDIR=${GITHUB_SHA:0:7}
mkdir -p $SUBJECTS_DIR/$THIS_RUN_OUTDIR
export TEST_DIR=$THIS_RUN_OUTDIR
export TQDM_DISABLE=1
./brun_fastsurfer.sh --subject_list $RUNNER_FS_MRI_DATA/subjects_list.txt \
--sd $SUBJECTS_DIR/$THIS_RUN_OUTDIR \
--parallel --threads 4 --3T --parallel_subjects surf
# Test fastsurfer output
run-pytest:
runs-on: self-hosted
if: always()
needs: run-fastsurfer
steps:
# run pytest checks for data consistency/quality
- name: Run pytest
run: |
source /venv-pytest/bin/activate
python -m pytest test/quick_test
python -m pytest test/quick_test
33 changes: 18 additions & 15 deletions FastSurferCNN/utils/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
"""
Expand All @@ -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.
Expand Down

0 comments on commit c85f457

Please sign in to comment.