Skip to content

Commit fda0210

Browse files
committed
Add option to ignore problematic files.
By default problematic files (non-image files, or image files that can't be read by a specified imageIO or corrupt image files) are listed in the output csv. Adding a flag --ignore_problematic. If given on the commandline the problematic files will not be listed in the csv.
1 parent abd1fd1 commit fda0210

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Python/71_Trust_But_Verify.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,9 @@
737737
"source": [
738738
"faux_volume_image_files = sitk.ReadImage(faux_series_volume_file_name)\n",
739739
"# convert string representation of list of file names to a list of file names\n",
740-
"image_file_list = pd.read_csv(faux_series_file_list_name)[\"files\"].apply(ast.literal_eval).tolist()\n",
740+
"image_file_list = (\n",
741+
" pd.read_csv(faux_series_file_list_name)[\"files\"].apply(ast.literal_eval).tolist()\n",
742+
")\n",
741743
"\n",
742744
"image_selection_gui2 = ImageSelection(\n",
743745
" 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)