def make_uber_command(self):
      """generate a script that would invoke the uber_ttest.py interface
         with control and user vars set (and so fields filled)

         Put any key elements in quotes:
            basis functions
            gltsym
      """
      if show_func_seq: print '=== xO ==='


      # first apply subject variables
      self.update_uvars_from_gui()

      cmd = 'uber_ttest.py'

      # apply each uvar with -uvar option
      prefix = ' \\\n    -uvar '     # append before next command
      for atr in self.uvars.attributes():
         if atr == 'name': continue     # skip
         if self.uvars.vals_are_equal(atr, LTT.g_udef_strs): continue
         # show this one
         val = self.uvars.val(atr)
         
         # special cases first: stim_basis, gltsym
         #if atr == 'gltsym':            # special case
         #   val = ["'%s'" % v for v in val]
         #elif atr == 'stim_basis':      # special case
         #   val = ["'%s'" % v for v in val]
         #   cmd += (prefix + '%s %s' % (atr, ' '.join(val)))

         # some options might need quotes


         if self.uvars.has_simple_type(atr):
            val = UTIL.quotize_list([val], quote_chars='#%<>')[0]
            cmd += (prefix + '%s %s' % (atr, val))
         elif type(val) == list:
            val = UTIL.quotize_list(val, quote_chars='#%<>')
            cmd += (prefix + '%s %s' % (atr, ' '.join(val)))
         else:
            print '** make_uber_command: bad attr %s' % atr

      return UTIL.add_line_wrappers(cmd + '\n')
Esempio n. 2
0
    def get_joined_strings(self, opt_name=None, opt=None, prefix=''):
        """like get_string_list(), but join any list together and only
           return a string

           only apply 'prefix' if something is found"""
        olist, rv = self.get_string_list(opt_name=opt_name, opt=opt)
        if rv or olist == None: return ''
        if len(olist) < 1:      return ''

        # we have something
        return prefix + ' '.join(UTIL.quotize_list(olist))
Esempio n. 3
0
    def get_joined_strings(self, opt_name=None, opt=None, prefix=''):
        """like get_string_list(), but join any list together and only
           return a string

           only apply 'prefix' if something is found"""
        olist, rv = self.get_string_list(opt_name=opt_name, opt=opt)
        if rv or olist == None: return ''
        if len(olist) < 1: return ''

        # we have something
        return prefix + ' '.join(UTIL.quotize_list(olist))
Esempio n. 4
0
    def make_script(self):
        """create the review EPI (plugout_drive) script"""

        c2 = "#!/bin/tcsh\n\n"

        c2 += "# ------------------------------------------------------\n"  \
              "# review EPI data via 'afni' and 'plugout_drive'\n\n"        \
              "# note that when running this script, prompts to change\n"   \
              "# datasets will appear in the terminal window\n\n"

        c2 += "# ------------------------------------------------------\n"  \
              "# set the list of datasets\n"                                \
              "set dsets = ( %s )\n\n" %                                    \
                 ' '.join([dset.prefix for dset in self.adsets])

        c2 += '# ------------------------------------------------------\n'  \
              '# verify that the input data exists\n'                       \
              'if ( ! -f $dsets[1]+orig.HEAD ) then\n'                      \
              '    echo "** missing data to review (e.g. $dsets[1])"\n'     \
              '    exit\n'                                                  \
              'endif\n\n'

        c2 += '# ------------------------------------------------------\n'  \
              '# start afni is listening mode, and take a brief nap\n\n'    \
              'afni -yesplugouts &\n\n'                                     \
              'sleep 5\n\n'

        cmd = UTIL.add_line_wrappers(c2)

        c2  = '# ------------------------------------------------------\n'  \
              '# tell afni to load the first dataset and open windows\n\n'  \
              'plugout_drive \\\n'                                          \
              '    -com "SWITCH_UNDERLAY %s" \\\n'                          \
               % self.adsets[0].prefix

        # open windows in the list
        if self.verb > 1:
            print('++ opening windows: %s' % ', '.join(self.windows))

        for ind in range(len(self.windows)):
            c2 += '    -com "OPEN_WINDOW %simage  \\\n'                  \
                  '                      geom=%dx%d+%d+%d" \\\n' %          \
                  (self.windows[ind], self.im_size[0], self.im_size[1],
                   self.im_xoff+ind*self.im_size[0], self.im_yoff)

        c2 += '    -com "OPEN_WINDOW sagittalgraph  \\\n'                   \
              '                      geom=%dx%d+%d+%d" \\\n' %              \
              (self.gr_size[0], self.gr_size[1], self.gr_xoff, self.gr_yoff)

        # terminate the initial plugout_drive command
        c2 += '    -quit\n\n'

        c2 = UTIL.add_line_wrappers(c2)  # do it early, for verb

        if self.verb > 2: print('initial drive command:\n%s' % c2)

        cmd += c2

        cmd += 'sleep 2    # give afni time to open the windows\n\n\n'

        c2  = '# ------------------------------------------------------\n'  \
              '# process each dataset using video mode\n\n'                 \
              'foreach dset ( $dsets )\n'                                   \
              '    plugout_drive \\\n'                                      \
              '        -com "SWITCH_UNDERLAY $dset" \\\n'                   \
              '        -com "OPEN_WINDOW sagittalgraph  \\\n'               \
              '                          keypress=a\\\n'                    \
              '                          keypress=v"\\\n'                   \
              '        -quit\n\n'                                           \
              '    sleep 2    # wait for plugout_drive output\n\n'          \
              '    echo ""\n'                                               \
              '    echo "++ now viewing $dset, hit enter to continue"\n'    \
              '    set ret = $<    # wait for user to hit enter\n'          \
              'end\n\n\n'

        cmd += UTIL.add_line_wrappers(c2)

        c2  = '# ------------------------------------------------------\n'  \
              '# stop video mode when the user is done\n\n'                 \
              'plugout_drive -com "OPEN_WINDOW sagittalgraph keypress=s"'   \
                           ' -quit\n\n\n'                                   \
              'sleep 2    # wait for plugout_drive output\n\n'              \
              'echo ""\n'                                                   \
              'echo "data review complete"\n\n\n'

        cmd += UTIL.add_line_wrappers(c2)

        c2  = '# ----------------------------------------------------------'\
              "------\n# auto-generated by gen_epi_review.py, %s\n" % g_version
        c2 += "#\n# %s %s\n" % (os.path.basename(sys.argv[0]), ' '.join(
            UTIL.quotize_list(sys.argv[1:], '')))

        cmd += UTIL.add_line_wrappers(c2)

        fp = open(self.script, "w")
        if not fp:
            print('** failed to open %s for writing decon script' %
                  self.script)
            return 1

        fp.write(cmd)
        fp.close()
        try:
            os.chmod(self.script, 0o755)
        except OSError as e:
            print(e)

        return
Esempio n. 5
0
    def make_script(self):
        """create the review EPI (plugout_drive) script"""

        c2  = "#!/bin/tcsh\n\n"

        c2 += "# ------------------------------------------------------\n"  \
              "# review EPI data via 'afni' and 'plugout_drive'\n\n"        \
              "# note that when running this script, prompts to change\n"   \
              "# datasets will appear in the terminal window\n\n"

        c2 += "# ------------------------------------------------------\n"  \
              "# set the list of datasets\n"                                \
              "set dsets = ( %s )\n\n" %                                    \
                 ' '.join([dset.prefix for dset in self.adsets])

        c2 += '# ------------------------------------------------------\n'  \
              '# verify that the input data exists\n'                       \
              'if ( ! -f $dsets[1]+orig.HEAD ) then\n'                      \
              '    echo "** missing data to review (e.g. $dsets[1])"\n'     \
              '    exit\n'                                                  \
              'endif\n\n'

        c2 += '# ------------------------------------------------------\n'  \
              '# start afni is listening mode, and take a brief nap\n\n'    \
              'afni -yesplugouts &\n\n'                                     \
              'sleep 5\n\n'

        cmd = UTIL.add_line_wrappers(c2)

        c2  = '# ------------------------------------------------------\n'  \
              '# tell afni to load the first dataset and open windows\n\n'  \
              'plugout_drive \\\n'                                          \
              '    -com "SWITCH_UNDERLAY %s" \\\n'                          \
               % self.adsets[0].prefix

        # open windows in the list
        if self.verb>1: print '++ opening windows: %s' % ', '.join(self.windows)

        for ind in range(len(self.windows)):
            c2 += '    -com "OPEN_WINDOW %simage  \\\n'                  \
                  '                      geom=%dx%d+%d+%d" \\\n' %          \
                  (self.windows[ind], self.im_size[0], self.im_size[1], 
                   self.im_xoff+ind*self.im_size[0], self.im_yoff)

        c2 += '    -com "OPEN_WINDOW sagittalgraph  \\\n'                   \
              '                      geom=%dx%d+%d+%d" \\\n' %              \
              (self.gr_size[0], self.gr_size[1], self.gr_xoff, self.gr_yoff)

        # terminate the initial plugout_drive command
        c2 += '    -quit\n\n'

        c2  = UTIL.add_line_wrappers(c2)  # do it early, for verb

        if self.verb > 2: print 'initial drive command:\n%s' % c2

        cmd += c2

        cmd += 'sleep 2    # give afni time to open the windows\n\n\n'

        c2  = '# ------------------------------------------------------\n'  \
              '# process each dataset using video mode\n\n'                 \
              'foreach dset ( $dsets )\n'                                   \
              '    plugout_drive \\\n'                                      \
              '        -com "SWITCH_UNDERLAY $dset" \\\n'                   \
              '        -com "OPEN_WINDOW sagittalgraph  \\\n'               \
              '                          keypress=a\\\n'                    \
              '                          keypress=v"\\\n'                   \
              '        -quit\n\n'                                           \
              '    sleep 2    # wait for plugout_drive output\n\n'          \
              '    echo ""\n'                                               \
              '    echo "++ now viewing $dset, hit enter to continue"\n'    \
              '    set ret = $<    # wait for user to hit enter\n'          \
              'end\n\n\n'

        cmd += UTIL.add_line_wrappers(c2)

        c2  = '# ------------------------------------------------------\n'  \
              '# stop video mode when the user is done\n\n'                 \
              'plugout_drive -com "OPEN_WINDOW sagittalgraph keypress=s"'   \
                           ' -quit\n\n\n'                                   \
              'sleep 2    # wait for plugout_drive output\n\n'              \
              'echo ""\n'                                                   \
              'echo "data review complete"\n\n\n'

        cmd += UTIL.add_line_wrappers(c2)

        c2  = '# ----------------------------------------------------------'\
              "------\n# auto-generated by gen_epi_review.py, %s\n" % g_version
        c2 += "#\n# %s %s\n" % (os.path.basename(sys.argv[0]),
                                ' '.join(UTIL.quotize_list(sys.argv[1:],'')))

        cmd += UTIL.add_line_wrappers(c2)

        fp = open(self.script, "w")
        if not fp:
            print '** failed to open %s for writing decon script' % self.script
            return 1

        fp.write(cmd)
        fp.close()
        os.chmod(self.script, 0755)

        return