diff --git a/asltk/scripts/cbf.py b/asltk/scripts/cbf.py index 773592c..04a5431 100644 --- a/asltk/scripts/cbf.py +++ b/asltk/scripts/cbf.py @@ -62,6 +62,13 @@ action='store_true', help='Show more details thoughout the processing.', ) +optional.add_argument( + '--file_fmt', + type=str, + nargs='?', + default='nii', + help='The file format that will be used to save the output images. It is not allowed image compression (ex: .gz, .zip, etc). Default is nii, but it can be choosen: mha, nrrd.', +) args = parser.parse_args() @@ -89,6 +96,12 @@ def checkUpParameters(): ) is_ok = False + if args.file_fmt not in ('nii', 'mha', 'nrrd'): + print( + f'File format is not allowed or not available. The select type is {args.file_fmt}, but options are: nii, mha or nrrd' + ) + is_ok = False + return is_ok @@ -124,6 +137,7 @@ def checkUpParameters(): print('M0 image dimension: ' + str(m0_img.shape)) print('PLD: ' + str(pld)) print('LD: ' + str(ld)) + print('Output file format: ' + str(args.file_fmt)) data = ASLData(pcasl=args.pcasl, m0=args.m0, ld_values=ld, pld_values=pld) recon = CBFMapping(data) @@ -131,17 +145,19 @@ def checkUpParameters(): maps = recon.create_map() -save_path = args.out_folder + os.path.sep + 'cbf_map.nrrd' +save_path = args.out_folder + os.path.sep + 'cbf_map.' + args.file_fmt if args.verbose: print('Saving CBF map - Path: ' + save_path) save_image(maps['cbf'], save_path) -save_path = args.out_folder + os.path.sep + 'cbf_map_normalized.nrrd' +save_path = ( + args.out_folder + os.path.sep + 'cbf_map_normalized.' + args.file_fmt +) if args.verbose: print('Saving normalized CBF map - Path: ' + save_path) save_image(maps['cbf_norm'], save_path) -save_path = args.out_folder + os.path.sep + 'att_map.nrrd' +save_path = args.out_folder + os.path.sep + 'att_map.' + args.file_fmt if args.verbose: print('Saving ATT map - Path: ' + save_path) save_image(maps['att'], save_path) diff --git a/asltk/scripts/te_asl.py b/asltk/scripts/te_asl.py index e8251ae..4f4539b 100644 --- a/asltk/scripts/te_asl.py +++ b/asltk/scripts/te_asl.py @@ -80,6 +80,13 @@ action='store_true', help='Show more details thoughout the processing.', ) +optional.add_argument( + '--file_fmt', + type=str, + nargs='?', + default='nii', + help='The file format that will be used to save the output images. It is not allowed image compression (ex: .gz, .zip, etc). Default is nii, but it can be choosen: mha, nrrd.', +) args = parser.parse_args() @@ -107,6 +114,12 @@ def checkUpParameters(): ) is_ok = False + if args.file_fmt not in ('nii', 'mha', 'nrrd'): + print( + f'File format is not allowed or not available. The select type is {args.file_fmt}, but options are: nii, mha or nrrd' + ) + is_ok = False + return is_ok @@ -158,6 +171,7 @@ def checkUpParameters(): print('(optional) CBF map: ' + str(args.cbf)) if args.att != '': print('(optional) ATT map: ' + str(args.att)) + print('Output file format: ' + str(args.file_fmt)) data = ASLData( @@ -172,22 +186,24 @@ def checkUpParameters(): maps = recon.create_map() -save_path = args.out_folder + os.path.sep + 'cbf_map.nii.gz' +save_path = args.out_folder + os.path.sep + 'cbf_map.' + args.file_fmt if args.verbose and cbf_map is not None: print('Saving CBF map - Path: ' + save_path) save_image(maps['cbf'], save_path) -save_path = args.out_folder + os.path.sep + 'cbf_map_normalized.nii.gz' +save_path = ( + args.out_folder + os.path.sep + 'cbf_map_normalized.' + args.file_fmt +) if args.verbose and cbf_map is not None: print('Saving normalized CBF map - Path: ' + save_path) save_image(maps['cbf_norm'], save_path) -save_path = args.out_folder + os.path.sep + 'att_map.nii.gz' +save_path = args.out_folder + os.path.sep + 'att_map.' + args.file_fmt if args.verbose and att_map is not None: print('Saving ATT map - Path: ' + save_path) save_image(maps['att'], save_path) -save_path = args.out_folder + os.path.sep + 'mte_t1blgm_map.nii.gz' +save_path = args.out_folder + os.path.sep + 'mte_t1blgm_map.' + args.file_fmt if args.verbose: print('Saving multiTE-ASL T1blGM map - Path: ' + save_path) save_image(maps['t1blgm'], save_path)