gjheij / linescanning

Package for (pre)processing of anatomical and (linescanning) fMRI data
MIT License
12 stars 3 forks source link

spinoza_qmrimaps - changes to enable working with both mp2rage and mp2rage-me #7

Closed iverissimo closed 2 years ago

iverissimo commented 2 years ago

Changes made yesterday, to allow for module 4 to run, when both MP2RAGE and MP2RAGE-ME images are present:

spinoza_qmrimaps

+++ b/shell/spinoza_qmrimaps
@@ -81,7 +81,7 @@ echo "==========================================================================

 for dir in ${search}; do

-  # declare -a ACQ=("MP2RAGE")
+  declare -a ACQ=("MP2RAGE" "MP2RAGEME")
   # declare -a ACQ=(memp2rage mp2rage)

   if [[ ! -z ${ses} ]]; then
@@ -102,7 +102,7 @@ for dir in ${search}; do
     NoF=`find "${indir}" -type f \( -iname "*acq-${a}*" -and -not -name "*T1w*" -and -name "*.nii.gz" \) | wc -l 2>/dev/null`

     # set output name based on acquisition strategy
-    base=${base}_acq-${a^^}
+    acq_base=${base}_acq-${a^^}

     if [[ ! -f ${input} ]]; then

@@ -124,7 +124,7 @@ for dir in ${search}; do
         fi

         echo "Creating ${a} derivatives with pymp2rage"
-        call_${a,,} ${UPs} -i ${indir} -o ${outdir} -b ${base} ${make_mask}
+        call_${a,,} ${UPs} -i ${indir} -o ${outdir} -b ${acq_base} ${make_mask}
       fi

     else

call_mp2rageme

+++ b/bin/call_mp2rageme
@@ -50,7 +50,9 @@ Args:

     -o (--outputdir=)  output directory     path to pymp2rage. <subject> and <ses-x> (optional), will
                                             be appended
-
+    -c                  make INV2 mask      no input required
+    -u                  use UP-parameters   no input required; there's different MP2RAGE-parameters
+                                            for universal pulses
 Outputs:
     r2star (Nifti1Image):       Relaxation map (1/T2*)
     t2star (Nifti1Image):       T2*-weighted image
@@ -87,10 +89,10 @@ Notes:
     subject     = ''
     session     = None
     outputdir   = None
-    out         = None
+    outputbase  = None

     try:
-        opts = getopt.getopt(argv,"hi:s:n:o:",["inputdir=", "subject=", "session=", "outputdir="])[0]
+        opts = getopt.getopt(argv,"cuhi:s:n:o:b:",["inputdir=", "subject=", "session=", "outputdir=", "outputbase="])[0]
     except getopt.GetoptError:
         print(main.__doc__)
         sys.exit(2)
@@ -103,6 +105,8 @@ Notes:
             inputdir = arg
         elif opt in ("-o", "--outputdir"):
             outputdir = arg
+        elif opt in ("-b", "--outputbase"):
+            outputbase = arg
         elif opt in ("-s", "--subject"):
             subject = arg
         elif opt in ("-n", "--session"):
@@ -115,7 +119,7 @@ Notes:

     # Define paths to images
     bids_fn     = BIDSLayout(opj(inputdir), validate=False).get(extension=['nii.gz'], return_type='file')
-    select_fn   = get_file_from_substring('inv', bids_fn)
+    select_fn   = get_file_from_substring(['inv', 'acq-MP2RAGEME'], bids_fn)
     select_fn.sort()

     if len(select_fn) != 10:
@@ -144,22 +148,22 @@ Notes:
         else:
             outputdir = opj(outputdir, subject, f'ses-{session}')

-    if not out:
+    if not outputbase:
         if session == None:
-            out = f"{subject}"
+            outputbase = f"{subject}"
         else:
-            out = f"{subject}_ses-{session}_acq-MEMP2RAGE"
+            outputbase = f"{subject}_ses-{session}_acq-MEMP2RAGE"

call_mp2rage

+++ b/bin/call_mp2rage
@@ -127,7 +127,7 @@ Notes:
     if inputdir != None:
         # we got an input directory; look for files with "acq-MP2RAGE"
         bids_fn     = BIDSLayout(opj(inputdir), validate=False).get(datatype='anat', extension=['nii.gz'], return_type='file')
-        select_fn   = get_file_from_substring(['acq-MP2RAGE', 'inv'], bids_fn)
+        select_fn   = get_file_from_substring(['acq-MP2RAGE_', 'inv'], bids_fn)
     else:
         select_fn = []
         # we did not get an input directory; check if separate files have been specified