From 24197be77e8d800bc99425e2fa17c7001f3ee295 Mon Sep 17 00:00:00 2001 From: Aaron Gudmundson Date: Tue, 10 Sep 2024 09:13:18 -0400 Subject: [PATCH 1/8] Updates for GE HBCD Sequence --- spec2nii/GE/ge_pfile.py | 32 ++++++++++++++++++++++---------- spec2nii/GE/ge_read_pfile.py | 4 ++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/spec2nii/GE/ge_pfile.py b/spec2nii/GE/ge_pfile.py index da5189b..65744c5 100644 --- a/spec2nii/GE/ge_pfile.py +++ b/spec2nii/GE/ge_pfile.py @@ -89,7 +89,13 @@ def _process_svs_pfile(pfile): :return: List of NIFTI MRS data objects :return: List of file name suffixes """ - psd = pfile.hdr.rhi_psdname.decode('utf-8').lower() + psd = pfile.hdr.rhi_psdname.decode('utf-8').lower() + proto = pfile.hdr.rhs_se_desc.decode('utf-8').lower() + if psd == 'hbcd' and "press" inproto: + print('\nPSD was: ', psd) + print('Proto is: ', proto) + psd = pfile.hdr.rhs_se_desc.decode('utf-8').lower() + print('PSD updated to: ', psd) # MM: Some 'gaba' psd strings contain full path names, so truncate to the end of the path if psd.endswith('gaba'): @@ -97,7 +103,7 @@ def _process_svs_pfile(pfile): numecho = pfile.hdr.rhi_numecho - if psd in ('probe-p', 'probe-s', 'probe-p_ach'): + if psd in ('mrs-press', 'probe-p', 'probe-s', 'probe-p_ach'): data, meta, dwelltime, fname_suffix = _process_probe_p(pfile) elif psd in ('oslaser', 'slaser_cni') and numecho == 1: # MM: If non-edited data, use _process_oslaser data, meta, dwelltime, fname_suffix = _process_oslaser(pfile) @@ -105,9 +111,9 @@ def _process_svs_pfile(pfile): data, meta, dwelltime, fname_suffix = _process_gaba(pfile) elif psd == 'slaser': data, meta, dwelltime, fname_suffix = _process_slaser(pfile) - elif psd in ('jpress', 'jpress_ac', 'gaba', 'probe-p-mega_rml', 'repress7'): + elif psd in ('hbcd', 'jpress', 'jpress_ac', 'gaba', 'probe-p-mega_rml', 'repress7'): data, meta, dwelltime, fname_suffix = _process_gaba(pfile) - elif psd in ('hbcd', 'hbcd1', 'hbcd2'): # ATG + elif psd in ('hbcd2'): # ATG data, meta, dwelltime, fname_suffix = _process_hbcd(pfile) # ATG else: raise UnsupportedPulseSequenceError(f'Unrecognised sequence {psd}.') @@ -351,10 +357,16 @@ def _process_hbcd(pfile): notestring = f'{notestring} {old_num_avgs} --> {new_num_avgs}' # Note Incomplete Data print(f'{notestring} \t Corrected**') # Note Incomplete Data - bef_shape = list(lTE_metab.shape) # Remove Averages Dim - bef_shape[4] = bef_shape[4] // 4 # Closest multiple of 4 - bef_shape.append(edit_cases) # Include Subscans - lTE_metab = lTE_metab.reshape(bef_shape) # With Subscan Dim + new_shape = list(lTE_metab.shape) # Remove Averages Dim + new_shape[4] = new_shape[4] // 4 # Closest multiple of 4 + new_shape.insert(5, edit_cases) # Include Subscans + + lTE_metab_ = np.zeros(new_shape, dtype=np.complex_) # New lTE Metab Array + lTE_metab_[:,:,:,:,:,0,:] = lTE_metab[:,:,:,:,0::4,:] # Subscan 1 + lTE_metab_[:,:,:,:,:,1,:] = lTE_metab[:,:,:,:,1::4,:] # Subscan 2 + lTE_metab_[:,:,:,:,:,2,:] = lTE_metab[:,:,:,:,2::4,:] # Subscan 3 + lTE_metab_[:,:,:,:,:,3,:] = lTE_metab[:,:,:,:,3::4,:] # Subscan 4 + lTE_metab = lTE_metab_ # With Subscan Dim lTE_metab_meta = _populate_metadata(pfile, water_suppressed=True) # Acquisition Information lTE_metab_meta.set_standard_def('EchoTime', 0.080) # TE @@ -362,8 +374,8 @@ def _process_hbcd(pfile): lTE_metab_meta.set_standard_def('EditPulse', edit_pulse_val) # Header Edit Info lTE_metab_meta.set_dim_info(0, 'DIM_DYN') # Dimension Info - lTE_metab_meta.set_dim_info(1, 'DIM_COIL') # Dimension Info - lTE_metab_meta.set_dim_info(2, 'DIM_EDIT', hdr=dim_header) # Dimension Info + lTE_metab_meta.set_dim_info(1, 'DIM_EDIT', hdr=dim_header) # Dimension Info + lTE_metab_meta.set_dim_info(2, 'DIM_COIL') # Dimension Info # Short TE HERCULES Metabolite Data sTE_metab = copy.deepcopy(raw_data[:, :, :, :, 1:33, :]) diff --git a/spec2nii/GE/ge_read_pfile.py b/spec2nii/GE/ge_read_pfile.py index 1b8749d..8895765 100644 --- a/spec2nii/GE/ge_read_pfile.py +++ b/spec2nii/GE/ge_read_pfile.py @@ -177,6 +177,9 @@ def get_mapper(self): return None psd = self.hdr.rhi_psdname.decode('utf-8').lower() + proto = self.hdr.rhs_se_desc.decode('utf-8').lower() + if psd == 'hbcd' and "press" in proto: + psd = self.hdr.rhs_se_desc.decode('utf-8').lower() # MM: Some 'gaba' psd strings contain full path names, so truncate to the end of the path if psd.endswith('gaba'): @@ -195,6 +198,7 @@ def get_mapper(self): 'presscsi_nfl', # bjs - added for Govind's SVS data off v25 'epsi_3d_24', # bjs - added for soher check of MIDAS Browndyke data 'fidall' # WTC - added for JG's Hyperpolarised 13C data + 'mrs-press' # ATG - Added for GE ShortTE in hbcd ): mapper = PfileMapper elif psd in ('oslaser', 'slaser_cni', 'slaser') and numecho == 1: From 21fbc4bf4a441c80d91e8fa087ed5fdefc73a7ce Mon Sep 17 00:00:00 2001 From: Aaron Gudmundson Date: Thu, 12 Sep 2024 09:44:10 -0400 Subject: [PATCH 2/8] Fixed linting errors for GE updates --- spec2nii/GE/ge_pfile.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec2nii/GE/ge_pfile.py b/spec2nii/GE/ge_pfile.py index 65744c5..73b4d2e 100644 --- a/spec2nii/GE/ge_pfile.py +++ b/spec2nii/GE/ge_pfile.py @@ -89,13 +89,13 @@ def _process_svs_pfile(pfile): :return: List of NIFTI MRS data objects :return: List of file name suffixes """ - psd = pfile.hdr.rhi_psdname.decode('utf-8').lower() + psd = pfile.hdr.rhi_psdname.decode('utf-8').lower() proto = pfile.hdr.rhs_se_desc.decode('utf-8').lower() - if psd == 'hbcd' and "press" inproto: - print('\nPSD was: ', psd) - print('Proto is: ', proto) + if psd == 'hbcd' and "press" in proto: + print('\nPSD was: ', psd) + print('Proto is: ', proto) psd = pfile.hdr.rhs_se_desc.decode('utf-8').lower() - print('PSD updated to: ', psd) + print('PSD updated to: ', psd) # MM: Some 'gaba' psd strings contain full path names, so truncate to the end of the path if psd.endswith('gaba'): @@ -230,7 +230,7 @@ def _add_editing_info(pfile, meta, data): edit_rf_freq_off1 = pfile.hdr.rhi_user20 edit_rf_freq_off2 = pfile.hdr.rhi_user21 edit_rf_ppm_off1 = edit_rf_freq_off1 / float(pfile.hdr.rhr_rh_ps_mps_freq * 1E-7) - edit_rf_ppm_off2 = edit_rf_freq_off2 / float(pfile.hdr.rhr_rh_ps_mps_freq * 1E-7) + edit_rf_ppm_off2 = edit_rf_freq_off2 / float(pfile.hdr.rhr_rh_ps_mps_freq * 1E-7) edit_rf_dur = pfile.hdr.rhi_user22 # check for default value (-1) of pulse length if edit_rf_dur <= 0: @@ -360,8 +360,8 @@ def _process_hbcd(pfile): new_shape = list(lTE_metab.shape) # Remove Averages Dim new_shape[4] = new_shape[4] // 4 # Closest multiple of 4 new_shape.insert(5, edit_cases) # Include Subscans - - lTE_metab_ = np.zeros(new_shape, dtype=np.complex_) # New lTE Metab Array + + lTE_metab_ = np.zeros(new_shape, dtype=np.complex_) # New lTE Metab Array lTE_metab_[:,:,:,:,:,0,:] = lTE_metab[:,:,:,:,0::4,:] # Subscan 1 lTE_metab_[:,:,:,:,:,1,:] = lTE_metab[:,:,:,:,1::4,:] # Subscan 2 lTE_metab_[:,:,:,:,:,2,:] = lTE_metab[:,:,:,:,2::4,:] # Subscan 3 From 26ff5f31655cd7b2a4cf92fa0b6a8fdd590563de Mon Sep 17 00:00:00 2001 From: Aaron Gudmundson Date: Thu, 12 Sep 2024 10:01:42 -0400 Subject: [PATCH 3/8] More linting errors for GE updates --- spec2nii/GE/ge_pfile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec2nii/GE/ge_pfile.py b/spec2nii/GE/ge_pfile.py index 73b4d2e..cc7ca56 100644 --- a/spec2nii/GE/ge_pfile.py +++ b/spec2nii/GE/ge_pfile.py @@ -362,10 +362,10 @@ def _process_hbcd(pfile): new_shape.insert(5, edit_cases) # Include Subscans lTE_metab_ = np.zeros(new_shape, dtype=np.complex_) # New lTE Metab Array - lTE_metab_[:,:,:,:,:,0,:] = lTE_metab[:,:,:,:,0::4,:] # Subscan 1 - lTE_metab_[:,:,:,:,:,1,:] = lTE_metab[:,:,:,:,1::4,:] # Subscan 2 - lTE_metab_[:,:,:,:,:,2,:] = lTE_metab[:,:,:,:,2::4,:] # Subscan 3 - lTE_metab_[:,:,:,:,:,3,:] = lTE_metab[:,:,:,:,3::4,:] # Subscan 4 + lTE_metab_[:, :, :, :, :, 0, :] = lTE_metab[:, :, :, :, 0::4, :] # Subscan 1 + lTE_metab_[:, :, :, :, :, 1, :] = lTE_metab[:, :, :, :, 1::4, :] # Subscan 2 + lTE_metab_[:, :, :, :, :, 2, :] = lTE_metab[:, :, :, :, 2::4, :] # Subscan 3 + lTE_metab_[:, :, :, :, :, 3, :] = lTE_metab[:, :, :, :, 3::4, :] # Subscan 4 lTE_metab = lTE_metab_ # With Subscan Dim lTE_metab_meta = _populate_metadata(pfile, water_suppressed=True) # Acquisition Information From fb891693dbc01dbfd49a89208ee070b5f3e02104 Mon Sep 17 00:00:00 2001 From: Aaron Gudmundson Date: Thu, 12 Sep 2024 10:49:24 -0400 Subject: [PATCH 4/8] Numpy Versioning/Deprecation Error - Updates for GE HBCD --- spec2nii/GE/ge_pfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec2nii/GE/ge_pfile.py b/spec2nii/GE/ge_pfile.py index cc7ca56..735c581 100644 --- a/spec2nii/GE/ge_pfile.py +++ b/spec2nii/GE/ge_pfile.py @@ -361,11 +361,11 @@ def _process_hbcd(pfile): new_shape[4] = new_shape[4] // 4 # Closest multiple of 4 new_shape.insert(5, edit_cases) # Include Subscans - lTE_metab_ = np.zeros(new_shape, dtype=np.complex_) # New lTE Metab Array - lTE_metab_[:, :, :, :, :, 0, :] = lTE_metab[:, :, :, :, 0::4, :] # Subscan 1 - lTE_metab_[:, :, :, :, :, 1, :] = lTE_metab[:, :, :, :, 1::4, :] # Subscan 2 - lTE_metab_[:, :, :, :, :, 2, :] = lTE_metab[:, :, :, :, 2::4, :] # Subscan 3 - lTE_metab_[:, :, :, :, :, 3, :] = lTE_metab[:, :, :, :, 3::4, :] # Subscan 4 + lTE_metab_ = np.zeros(new_shape, dtype=np.complex128) # New lTE Metab Array + lTE_metab_[:, :, :, :, :, 0, :] = lTE_metab[:, :, :, :, 0::4, :] # Subscan 1 + lTE_metab_[:, :, :, :, :, 1, :] = lTE_metab[:, :, :, :, 1::4, :] # Subscan 2 + lTE_metab_[:, :, :, :, :, 2, :] = lTE_metab[:, :, :, :, 2::4, :] # Subscan 3 + lTE_metab_[:, :, :, :, :, 3, :] = lTE_metab[:, :, :, :, 3::4, :] # Subscan 4 lTE_metab = lTE_metab_ # With Subscan Dim lTE_metab_meta = _populate_metadata(pfile, water_suppressed=True) # Acquisition Information From e3df106c94545067d032da78cc78fa1399f0578a Mon Sep 17 00:00:00 2001 From: Aaron Gudmundson Date: Thu, 12 Sep 2024 11:02:57 -0400 Subject: [PATCH 5/8] Updates for GE HBCD --- spec2nii/GE/ge_pfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec2nii/GE/ge_pfile.py b/spec2nii/GE/ge_pfile.py index 735c581..bc9c721 100644 --- a/spec2nii/GE/ge_pfile.py +++ b/spec2nii/GE/ge_pfile.py @@ -374,8 +374,8 @@ def _process_hbcd(pfile): lTE_metab_meta.set_standard_def('EditPulse', edit_pulse_val) # Header Edit Info lTE_metab_meta.set_dim_info(0, 'DIM_DYN') # Dimension Info - lTE_metab_meta.set_dim_info(1, 'DIM_EDIT', hdr=dim_header) # Dimension Info - lTE_metab_meta.set_dim_info(2, 'DIM_COIL') # Dimension Info + lTE_metab_meta.set_dim_info(1, 'DIM_COIL') # Dimension Info + lTE_metab_meta.set_dim_info(2, 'DIM_EDIT', hdr=dim_header) # Dimension Info # Short TE HERCULES Metabolite Data sTE_metab = copy.deepcopy(raw_data[:, :, :, :, 1:33, :]) From 2e5eaaf0616a49f6597e37264bb555a894f7c047 Mon Sep 17 00:00:00 2001 From: Aaron Gudmundson Date: Thu, 12 Sep 2024 11:39:50 -0400 Subject: [PATCH 6/8] Updates for GE HBCD_ --- spec2nii/GE/ge_pfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec2nii/GE/ge_pfile.py b/spec2nii/GE/ge_pfile.py index bc9c721..735c581 100644 --- a/spec2nii/GE/ge_pfile.py +++ b/spec2nii/GE/ge_pfile.py @@ -374,8 +374,8 @@ def _process_hbcd(pfile): lTE_metab_meta.set_standard_def('EditPulse', edit_pulse_val) # Header Edit Info lTE_metab_meta.set_dim_info(0, 'DIM_DYN') # Dimension Info - lTE_metab_meta.set_dim_info(1, 'DIM_COIL') # Dimension Info - lTE_metab_meta.set_dim_info(2, 'DIM_EDIT', hdr=dim_header) # Dimension Info + lTE_metab_meta.set_dim_info(1, 'DIM_EDIT', hdr=dim_header) # Dimension Info + lTE_metab_meta.set_dim_info(2, 'DIM_COIL') # Dimension Info # Short TE HERCULES Metabolite Data sTE_metab = copy.deepcopy(raw_data[:, :, :, :, 1:33, :]) From 3f65719872e57fd25c87a1bd6abdfd3c3a6d36bb Mon Sep 17 00:00:00 2001 From: Aaron Gudmundson Date: Fri, 13 Sep 2024 08:46:24 -0400 Subject: [PATCH 7/8] Updates for GE HBCD - data dimensions --- spec2nii/GE/ge_pfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec2nii/GE/ge_pfile.py b/spec2nii/GE/ge_pfile.py index 735c581..bc9c721 100644 --- a/spec2nii/GE/ge_pfile.py +++ b/spec2nii/GE/ge_pfile.py @@ -374,8 +374,8 @@ def _process_hbcd(pfile): lTE_metab_meta.set_standard_def('EditPulse', edit_pulse_val) # Header Edit Info lTE_metab_meta.set_dim_info(0, 'DIM_DYN') # Dimension Info - lTE_metab_meta.set_dim_info(1, 'DIM_EDIT', hdr=dim_header) # Dimension Info - lTE_metab_meta.set_dim_info(2, 'DIM_COIL') # Dimension Info + lTE_metab_meta.set_dim_info(1, 'DIM_COIL') # Dimension Info + lTE_metab_meta.set_dim_info(2, 'DIM_EDIT', hdr=dim_header) # Dimension Info # Short TE HERCULES Metabolite Data sTE_metab = copy.deepcopy(raw_data[:, :, :, :, 1:33, :]) From 4484c89d04faf1fe2f7f5a6a77dec4c48b23c779 Mon Sep 17 00:00:00 2001 From: Aaron Gudmundson Date: Fri, 13 Sep 2024 09:21:33 -0400 Subject: [PATCH 8/8] Updates for GE HBCD - data dimensions - fixed --- spec2nii/GE/ge_pfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec2nii/GE/ge_pfile.py b/spec2nii/GE/ge_pfile.py index bc9c721..098976f 100644 --- a/spec2nii/GE/ge_pfile.py +++ b/spec2nii/GE/ge_pfile.py @@ -359,13 +359,13 @@ def _process_hbcd(pfile): new_shape = list(lTE_metab.shape) # Remove Averages Dim new_shape[4] = new_shape[4] // 4 # Closest multiple of 4 - new_shape.insert(5, edit_cases) # Include Subscans + new_shape.append(edit_cases) # Include Subscans lTE_metab_ = np.zeros(new_shape, dtype=np.complex128) # New lTE Metab Array - lTE_metab_[:, :, :, :, :, 0, :] = lTE_metab[:, :, :, :, 0::4, :] # Subscan 1 - lTE_metab_[:, :, :, :, :, 1, :] = lTE_metab[:, :, :, :, 1::4, :] # Subscan 2 - lTE_metab_[:, :, :, :, :, 2, :] = lTE_metab[:, :, :, :, 2::4, :] # Subscan 3 - lTE_metab_[:, :, :, :, :, 3, :] = lTE_metab[:, :, :, :, 3::4, :] # Subscan 4 + lTE_metab_[:, :, :, :, :, :, 0] = lTE_metab[:, :, :, :, 0::4, :] # Subscan 1 + lTE_metab_[:, :, :, :, :, :, 1] = lTE_metab[:, :, :, :, 1::4, :] # Subscan 2 + lTE_metab_[:, :, :, :, :, :, 2] = lTE_metab[:, :, :, :, 2::4, :] # Subscan 3 + lTE_metab_[:, :, :, :, :, :, 3] = lTE_metab[:, :, :, :, 3::4, :] # Subscan 4 lTE_metab = lTE_metab_ # With Subscan Dim lTE_metab_meta = _populate_metadata(pfile, water_suppressed=True) # Acquisition Information