def get_header(f, verbose=True):
     if os.path.isfile(f) and is_dicom_file(f):
         p = pydicom.read_file(f, stop_before_pixels=True)
         if verbose:
             print(p)
         return p
     return None
示例#2
0
 def set_dicom_and_numpy_file(self, dcm_file, numpy_file):
     if not is_dicom_file(dcm_file):
         raise RuntimeError(f'File {dcm_file} is not a DICOM file')
     if not is_numpy_file(numpy_file):
         raise RuntimeError(
             f'File {numpy_file} does not have .npy extension')
     self.dcm_file = dcm_file
     self.numpy_file = numpy_file
 def load_file(self, f, verbose=True):
     if not os.path.isfile(f):
         if verbose:
             print('Cannot find file {}'.format(f))
         return
     if is_dicom_file(f):
         self.files.append(f)
         if verbose:
             print(f)
示例#4
0
 def set_dicom_and_tag_file(self, dcm_file, tag_file):
     if not is_dicom_file(dcm_file):
         raise RuntimeError(f'File {dcm_file} is not a DICOM file')
     if not is_tag_file(tag_file):
         raise RuntimeError(f'File {tag_file} does not have .tag extension')
     if get_tag_file_for_dicom(dcm_file) != tag_file:
         # Just print a warning since it's suspicious. It might happen though that the TAG file
         # name is not the same as the DICOM file
         print(
             f'Files {dcm_file} and {tag_file} do not seem to belong together'
         )
     self.dcm_file = dcm_file
     self.tag_file = tag_file
 def get_pixel_data(f):
     if os.path.isfile(f) and is_dicom_file(f):
         p = pydicom.read_file(f, stop_before_pixels=False)
         return p.pixel_array
     return None