Skip to content

Commit

Permalink
BUG: Adjust multiTE script to save images using input parameter (avoi…
Browse files Browse the repository at this point in the history
…d compress error)
  • Loading branch information
acsenrafilho committed Nov 22, 2024
1 parent c6401bb commit cfc544b
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions asltk/scripts/te_asl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit cfc544b

Please sign in to comment.