From 20fac3b2b12df9277a223e8ded0d2f214b719170 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 30 Sep 2023 12:40:16 +0200 Subject: [PATCH] Use list comprehensions --- spec2nii/GE/ge_pfile.py | 7 ++++--- spec2nii/Philips/philips_data_list.py | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spec2nii/GE/ge_pfile.py b/spec2nii/GE/ge_pfile.py index e9b5d20..b52939b 100644 --- a/spec2nii/GE/ge_pfile.py +++ b/spec2nii/GE/ge_pfile.py @@ -108,9 +108,10 @@ def _process_svs_pfile(pfile): orientation = NIFTIOrient(_calculate_affine(pfile)) - out_nmrs = [] - for dd, mm in zip(data, meta): - out_nmrs.append(gen_nifti_mrs_hdr_ext(dd, dwelltime, mm, orientation.Q44, no_conj=True)) + out_nmrs = [ + gen_nifti_mrs_hdr_ext(dd, dwelltime, mm, orientation.Q44, no_conj=True) + for dd, mm in zip(data, meta) + ] return out_nmrs, fname_suffix diff --git a/spec2nii/Philips/philips_data_list.py b/spec2nii/Philips/philips_data_list.py index 3b59927..f99c374 100644 --- a/spec2nii/Philips/philips_data_list.py +++ b/spec2nii/Philips/philips_data_list.py @@ -80,10 +80,11 @@ def read_data_list_pair(data_file, list_file, aux_file, special_case=None): meta = base_meta.copy() - kept_ind = [] - for ii, sha in zip(indices, data.shape[1:]): - if sha > 1: - kept_ind.append(ii) + kept_ind = [ + ii + for ii, sha in zip(indices, data.shape[1:]) + if sha > 1 + ] out_data = data.squeeze() if len(kept_ind) > 3: