Skip to content

Commit 69d38da

Browse files
authored
Merge pull request #452 from zivy/updateQACode
Update qa code
2 parents 06ef2b9 + fda0210 commit 69d38da

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Python/71_Trust_But_Verify.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"import SimpleITK as sitk\n",
5555
"import pandas as pd\n",
5656
"import numpy as np\n",
57+
"import ast\n",
5758
"import os\n",
5859
"import sys\n",
5960
"import shutil\n",
@@ -735,7 +736,10 @@
735736
"outputs": [],
736737
"source": [
737738
"faux_volume_image_files = sitk.ReadImage(faux_series_volume_file_name)\n",
738-
"image_file_list = pd.read_csv(faux_series_file_list_name)[\"files\"].apply(eval).to_list()\n",
739+
"# convert string representation of list of file names to a list of file names\n",
740+
"image_file_list = (\n",
741+
" pd.read_csv(faux_series_file_list_name)[\"files\"].apply(ast.literal_eval).tolist()\n",
742+
")\n",
739743
"\n",
740744
"image_selection_gui2 = ImageSelection(\n",
741745
" faux_volume_image_files,\n",

Python/scripts/characterize_data.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,11 @@ def characterize_data(argv=None):
452452
nargs="*",
453453
help="titles of the results columns for the metadata_keys",
454454
)
455+
parser.add_argument(
456+
"--ignore_problems",
457+
action="store_true",
458+
help="problematic files will not be listed if parameter is given on commandline",
459+
)
455460

456461
args = parser.parse_args(argv)
457462
if len(args.external_applications) != len(args.external_applications_headings):
@@ -479,6 +484,9 @@ def characterize_data(argv=None):
479484
meta_data_keys=args.metadata_keys,
480485
additional_column_names=args.metadata_keys_headings,
481486
)
487+
# remove all rows associated with problematic files (non-image files or image files with problems)
488+
if args.ignore_problems:
489+
df.dropna(inplace=True)
482490
# save the raw information, create directory structure if it doesn't exist
483491
os.makedirs(os.path.dirname(args.output_file), exist_ok=True)
484492
df.to_csv(args.output_file, index=False)

0 commit comments

Comments
 (0)