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

output files from convert_dir #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions dicom2nifti/convert_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def convert_directory(dicom_directory, output_folder, compression=True, reorient
:param reorient: reorient the dicoms according to LAS orientation
:param output_folder: folder to write the nifti files to
:param dicom_directory: directory with dicom files
:returns: list of created nifti files
"""
# sort dicom files by series uid
dicom_series = {}
Expand Down Expand Up @@ -59,6 +60,7 @@ def convert_directory(dicom_directory, output_folder, compression=True, reorient
traceback.print_exc()

# start converting one by one
nifti_files = []
for series_id, dicom_input in dicom_series.items():
base_filename = ""
# noinspection PyBroadException
Expand Down Expand Up @@ -86,9 +88,11 @@ def convert_directory(dicom_directory, output_folder, compression=True, reorient
nifti_file = os.path.join(output_folder, base_filename + '.nii')
convert_dicom.dicom_array_to_nifti(dicom_input, nifti_file, reorient)
gc.collect()
nifti_files.append(nifti_file)
except: # Explicitly capturing app exceptions here to be able to continue processing
logger.info("Unable to convert: %s" % base_filename)
traceback.print_exc()
return nifti_files


def _is_valid_imaging_dicom(dicom_header):
Expand Down