def mrtrix_tck_to_trk(): ref_img = nib.load(output_dir + "/bundle_segmentations" + dir_postfix + "/" + bundle + ".nii.gz") reference_affine = ref_img.affine reference_shape = ref_img.get_data().shape[:3] fiber_utils.convert_tck_to_trk(output_dir + "/" + tracking_folder + "/" + bundle + ".tck", output_dir + "/" + tracking_folder + "/" + bundle + ".trk", reference_affine, reference_shape, compress_err_thr=0.1, smooth=None, nr_cpus=nr_cpus, tracking_format=output_format) subprocess.call("rm -f " + output_dir + "/" + tracking_folder + "/" + bundle + ".tck", shell=True)
def _mrtrix_tck_to_trk(output_dir, tracking_folder, dir_postfix, bundle, output_format, nr_cpus): ref_img = nib.load(output_dir + "/bundle_segmentations" + dir_postfix + "/" + bundle + ".nii.gz") reference_affine = ref_img.affine # Don't need to load all the data to get its shape / dimmensions, info is stored in the image header # reference_shape = ref_img.get_data().shape[:3] reference_shape = ref_img.header.get_data_shape()[:3] fiber_utils.convert_tck_to_trk( output_dir + "/" + tracking_folder + "/" + bundle + ".tck", output_dir + "/" + tracking_folder + "/" + bundle + ".trk", reference_affine, reference_shape, compress_err_thr=0.1, smooth=None, nr_cpus=nr_cpus, tracking_format=output_format) subprocess.call("rm -f " + output_dir + "/" + tracking_folder + "/" + bundle + ".tck", shell=True)