Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bug-cbf-script' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
acsenrafilho committed Nov 26, 2024
2 parents 589e1f0 + cfc544b commit dd3d954
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
22 changes: 19 additions & 3 deletions asltk/scripts/cbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

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


Expand Down Expand Up @@ -124,24 +137,27 @@ 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)
recon.set_brain_mask(mask_img)
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)
Expand Down
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 dd3d954

Please sign in to comment.