Skip to content

Commit

Permalink
Working GRE conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jcohenadad committed Dec 21, 2023
1 parent 4995a59 commit 270f307
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions bids_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
path_out = '/Users/julien/Desktop/rf_shimming_spinalcord/sub-02'

# Create dictionary for shim type output
shimtype_dict = {'noRFshim': 'CP', 'CVred': 'CVred'}
shimtype_dict = {'noRFshim': 'CP',
'Noshim': 'CP',
'CVred': 'CVred'}

# Get subject name from path_out
subject = os.path.basename(path_out)
Expand All @@ -19,10 +21,15 @@
# Get the absolute file name of the NIfTI and JSON files under the MPRAGE subfolder, that has the string "noRFshim" in it
for shimtype in ['noRFshim', 'CVred']:
for ext in ['nii.gz', 'json']:
mprage_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(mprage_file, os.path.join(path_out, f'anat/sub-{subject}_acq-{shimtype_dict[shimtype]}_T1w.{ext}'))
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}'))

# Convert RF map data
# Convert GRE data
# 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, and that has the string "gre2d" in it. Select the first pair in the list.
for shimtype in ['CVred', 'Noshim']:
for ext in ['nii.gz', 'json']:
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'fmap/sub-{subject}_acq-{shimtype_dict[shimtype]}_T2starw.{ext}'))



0 comments on commit 270f307

Please sign in to comment.