def run_cli(args): try: karawun.import_tractography_study(origdcm=args.dicom_template, niftifiles=args.nifti, tckfiles=args.tract_files, labelfiles=args.label_files, destdir=args.output_dir) except karawun.RawToLabelImMismatch: print("One of the label images is not derived from any of the raw images") except karawun.MissingUIDList: print("A UID list is required iternally somewhere - this error shouldn't happen")
def converter(targetd): test_data = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Data') t1dcm = os.path.join(test_data, "Dicom", ("1.3.12.2.1107.5.2.43." "167031.2019040213095021814319052.dcm")) MR = [ 'T1brain.nii.gz', 'FLAIRbrain.nii.gz', 'FAbrain.nii.gz', 'FAbrain_reoriented.nii.gz' ] MR = [os.path.join(test_data, "Tractography", nii) for nii in MR] TCK = ['Left_PT_final.tck', 'Right_PT_final.tck'] TCK = [os.path.join(test_data, "Tractography", tck) for tck in TCK] karawun.import_tractography_study(origdcm=t1dcm, niftifiles=MR, tckfiles=TCK, labelfiles=None, destdir=targetd)
def label_converter_fail(targetd): # This should fail as there is no # image in the same space as the segmentation test_data = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Data') t1dcm = os.path.join(test_data, "Dicom", ("1.3.12.2.1107.5.2.43." "167031.2019040213095021814319052.dcm")) MR = ['FAbrain.nii.gz'] MR = [os.path.join(test_data, "Tractography", nii) for nii in MR] MR_LAB = ['words.nii.gz', 'globes.nii.gz'] MR_LAB = [os.path.join(test_data, "Tractography", nii) for nii in MR_LAB] TCK = ['Left_PT_final.tck', 'Right_PT_final.tck'] TCK = [os.path.join(test_data, "Tractography", tck) for tck in TCK] karawun.import_tractography_study(origdcm=t1dcm, niftifiles=MR, tckfiles=TCK, labelfiles=MR_LAB, destdir=targetd)