Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip QC if label file is empty #61

Merged
merged 4 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Install Python 3
uses: actions/setup-python@v1
with:
python-version: 3.8.17
python-version: 3.8.18

- name: Install dependencies
run: |
Expand Down
14 changes: 14 additions & 0 deletions manual_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import glob
import json
import os
import logging
import sys
import shutil
from textwrap import dedent
Expand All @@ -31,6 +32,9 @@

import utils

import numpy as np
import nibabel as nib


def get_parser():
"""
Expand Down Expand Up @@ -581,6 +585,16 @@ def generate_qc(fname, fname_label, task, fname_qc, subject, config_file, qc_les
:param suffix_dict: dictionary of suffixes
:return:
"""
# Not all sct_qc -p functions support empty label files. Check if the label file is empty and skip QC if so.
# Context: https://github.com/spinalcordtoolbox/manual-correction/issues/60#issuecomment-1720280352
skip_qc_list = ['FILES_LABEL', 'FILES_COMPRESSION', 'FILES_PMJ', 'FILES_CENTERLINE']
if task in skip_qc_list:
img_label = nib.load(fname_label)
data_label = img_label.get_fdata()
if np.sum(data_label) == 0:
logging.warning(f"File {fname_label} is empty. Skipping QC.\n")
return

# Lesion QC needs also SC segmentation for cropping
if task == 'FILES_LESION':
# Construct SC segmentation file name
Expand Down
Loading