Skip to content

Commit

Permalink
Fixed additional 'sub-' field
Browse files Browse the repository at this point in the history
  • Loading branch information
jcohenadad committed Dec 21, 2023
1 parent b27fcad commit 26d395c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bids_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import shutil

path_in = '/Users/julien/code/rf-shimming-7t/RF_shimming_project_cleanupload/SubA'
path_out = '/Users/julien/Desktop/rf_shimming_spinalcord/sub-02'
path_out = '/Users/julien/Desktop/rf_shimming_spinalcord_test/sub-01'

# Create dictionary for shim type output
shimtype_dict = {'noRFshim': 'CP',
'Noshim': 'CP',
'CVred': 'CVred',
'CVred': 'CoV',
'PatSpec': 'patient',
'PhaseOnly': 'phase',
'SAReff': 'SAReff',
Expand All @@ -27,7 +27,7 @@
for shimtype in ['noRFshim', 'CVred']:
for ext in ['nii.gz', 'json']:
file = [os.path.join(path_in, 'MPRAGE', f) for f in os.listdir(os.path.join(path_in, 'MPRAGE')) if shimtype in f and f.endswith(ext)][0]
shutil.copy2(file, os.path.join(path_out, f'anat/sub-{subject}_acq-{shimtype_dict[shimtype]}_T1w.{ext}'))
shutil.copy2(file, os.path.join(path_out, f'anat/{subject}_acq-{shimtype_dict[shimtype]}_T1w.{ext}'))

# Convert files in GRE_B1 subfolder
# Get the absolute file name of the NIfTI and JSON files under each subfolder of the GRE_B1 subfolder that has the string corresponding to the name of the subfolder in it.
Expand All @@ -36,12 +36,12 @@
# Convert GRE data
# Select the files with the string "gre2d" in it. Select the first pair in the list, which are not corrected for gradient distortion.
file = [os.path.join(path_in, 'GRE_B1', shimtype, f) for f in os.listdir(os.path.join(path_in, 'GRE_B1', shimtype)) if 'gre2d' in f and f.endswith(ext)][0]
shutil.copy2(file, os.path.join(path_out, f'anat/sub-{subject}_acq-{shimtype_dict[shimtype]}_T2starw.{ext}'))
shutil.copy2(file, os.path.join(path_out, f'anat/{subject}_acq-{shimtype_dict[shimtype]}_T2starw.{ext}'))
# Convert RF map data
# Select the files with the string "tfl_b1map" in it. Select the first pair in the list, which is not corrected for gradient distortion, and which corresponds to the magnitude image. Select also the 3rd pair, which corresponds to the RF map.
file = [os.path.join(path_in, 'GRE_B1', shimtype, f) for f in os.listdir(os.path.join(path_in, 'GRE_B1', shimtype)) if 'tfl_b1map' in f and f.endswith(ext)][0]
shutil.copy2(file, os.path.join(path_out, f'fmap/sub-{subject}_acq-{shimtype_dict[shimtype]}_part-magnitude_TB1map.{ext}'))
shutil.copy2(file, os.path.join(path_out, f'fmap/{subject}_acq-{shimtype_dict[shimtype]}_part-magnitude_TB1map.{ext}'))
file = [os.path.join(path_in, 'GRE_B1', shimtype, f) for f in os.listdir(os.path.join(path_in, 'GRE_B1', shimtype)) if 'tfl_b1map' in f and f.endswith(ext)][2]
shutil.copy2(file, os.path.join(path_out, f'fmap/sub-{subject}_acq-{shimtype_dict[shimtype]}_TB1map.{ext}'))
shutil.copy2(file, os.path.join(path_out, f'fmap/{subject}_acq-{shimtype_dict[shimtype]}_TB1map.{ext}'))


0 comments on commit 26d395c

Please sign in to comment.