I am developing a segmentation module called “PhantomSegmenter” which would automatically segment phantoms. The user only has to input a volume and press the button. However, I would like to give the user a choice to select a directory containing DICOMs. Here is the issue:
When the user selects a directory, I would like to recursively check whether the selected directory contains any .dcm or .ima files. I would want to check the size of that directory first, to make sure the user did not select the wrong folder (which could potentially contain terabytes of irrelevant files, and recursively checking an enormous directory to see whether each filename ends with the aforementioned two extensions would be too intensive most likely crash the program without saving any data). However, checking the folder size is no more efficient than the recursive check.
Nevertheless, I thought about two potential solutions, and am having a dilemma of which two of the following methods I should take:
Simply enable the “Apply” button, assuming the user inputted a proper directory, and only check when the button is clicked.
Recursively check when the user selects a directory, and assume they inputted a proper directory, which could crash the program as I mentioned.