original_docstring: 
      Expects an 4d-image and -mask file name and a target path
      filter mask and image volumes by contoured time-steps
      copy all metadata
      save them to the destination path
      :param img_f: 4D image filepath as str
      :param mask_f: 4D mask filepath as str
      :param full_path: export path as str
      :param slice_threshold: minimal masks per timestep as int
      :return:
      
docstring: Expects an 4d-image and -mask file name and a target path
  filter mask and image volumes by contoured time-steps
  copy all metadata
  save them to the destination path
docstring_tokens: Expects an 4d - image and - mask file name and a target path filter mask and image volumes by contoured time - steps copy all metadata save them to the destination path
code: def create_4d_volumes_from_4d_files(img_f, mask_f, full_path='data/raw/GCN/3D/', slice_threshold=2):
      """
      Expects an 4d-image and -mask file name and a target path
      filter mask and image volumes by contoured time-steps
      copy all metadata
      save them to the destination path
      :param img_f: 4D image filepath as str
      :param mask_f: 4D mask filepath as str
      :param full_path: export path as str
      :param slice_threshold: minimal masks per timestep as int
      :return:
      """
  
      logging.info('process file: {}'.format(img_f))
      # get sitk images
      mask_4d_sitk = sitk.ReadImage(mask_f)
      img_4d_sitk = sitk.ReadImage(img_f)
  
      # filter 4d image nda according to given mask nda
      mask_4d_nda, masked_t = filter_4d_vol(mask_4d_sitk, slice_threshold=slice_threshold)
      img_4d_nda = sitk.GetArrayFromImage(img_4d_sitk)[masked_t]
  
      # write filtered 4d image to disk
      patient_name = os.path.basename(img_f).split('.')[0].replace('volume_clean', '')
      img_file = '{}_{}{}'.format(patient_name, 'img', '.nrrd')
      mask_file = '{}_{}{}'.format(patient_name, 'msk', '.nrrd')
  
      copy_meta_and_save(img_4d_nda, img_4d_sitk, os.path.join(full_path, img_file))
      copy_meta_and_save(mask_4d_nda, img_4d_sitk, os.path.join(full_path, mask_file))
  
      return [masked_t, list(img_4d_nda.shape)]
code_tokens: def create_4d_volumes_from_4d_files ( img_f , mask_f , full_path = 'data/raw/GCN/3D/' , slice_threshold = 2 ) : logging . info ( 'process file: {}' . format ( img_f ) ) mask_4d_sitk = sitk . ReadImage ( mask_f ) img_4d_sitk = sitk . ReadImage ( img_f ) mask_4d_nda , masked_t = filter_4d_vol ( mask_4d_sitk , slice_threshold = slice_threshold ) img_4d_nda = sitk . GetArrayFromImage ( img_4d_sitk ) [ masked_t ] patient_name = os . path . basename ( img_f ) . split ( '.' ) [ 0 ] . replace ( 'volume_clean' , '' ) img_file = '{}_{}{}' . format ( patient_name , 'img' , '.nrrd' ) mask_file = '{}_{}{}' . format ( patient_name , 'msk' , '.nrrd' ) copy_meta_and_save ( img_4d_nda , img_4d_sitk , os . path . join ( full_path , img_file ) ) copy_meta_and_save ( mask_4d_nda , img_4d_sitk , os . path . join ( full_path , mask_file ) ) return [ masked_t , list ( img_4d_nda . shape ) ]
short_docstring: Expects an 4d-image and -mask file name and a target path
  filter mask and image volumes by contoured time-steps
  copy all metadata
  save them to the destination path
short_docstring_tokens: Expects an 4d - image and - mask file name and a target path filter mask and image volumes by contoured time - steps copy all metadata save them to the destination path
comment: """
      Expects an 4d-image and -mask file name and a target path
      filter mask and image volumes by contoured time-steps
      copy all metadata
      save them to the destination path
      :param img_f: 4D image filepath as str
      :param mask_f: 4D mask filepath as str
      :param full_path: export path as str
      :param slice_threshold: minimal masks per timestep as int
      :return:
      """$SEP$# get sitk images$SEP$# filter 4d image nda according to given mask nda$SEP$# write filtered 4d image to disk