def make_anova2_set_list(self, bsub, indent=0): """return a multi-line string of the form: -alevels #bsub -blevels #subj -dset ALEVEL BLEVEL "dset#A[bsub#B]" ... indent is the initial indentation """ sdir = self.common_dname sstr = '%*s-alevels %d \\\n' \ '%*s-blevels %d \\\n' \ % (indent,'', len(bsub), indent, '', len(self.subjects)) for isubj, subj in enumerate(self.subjects): if sdir: # see if the dataset is in a directory underneath cdir = UTIL.child_dir_name(self.common_dir, subj.ddir) if UTIL.is_trivial_dir(cdir): cstr = '' else: cstr = '%s/' % cdir dset = '$%s/%s%s' % (sdir, cstr, subj.dfile) else: dset = subj.dset for ibeta, beta in enumerate(bsub): sstr += '%*s-dset %2d %2d "%s[%s]" \\\n' \ % (indent, '', ibeta+1, isubj+1, dset, beta) return sstr
def make_ttpp_set_list(self, bsub, indent=0): """return a multi-line string of the form: SID1 "dset1[bsub]" SID2 "dset2[bsub]" ... indent is the initial indentation """ # note the max subject ID length ml = 0 for subj in self.subjects: if len(subj.sid) > ml: ml = len(subj.sid) if not UTIL.is_trivial_dir(self.common_dir) and self.common_dname: sdir = self.common_dname else: sdir = '' sstr = '' for subj in self.subjects: if sdir: # see if the dataset is in a directory underneath cdir = UTIL.child_dir_name(self.common_dir, subj.ddir) if UTIL.is_trivial_dir(cdir): cstr = '' else: cstr = '%s/' % cdir dset = '$%s/%s%s' % (sdir, cstr, subj.dfile) else: dset = subj.dset sstr += '%*s%s "%s[%s]" \\\n' % (indent, '', subj.sid, dset, bsub) return sstr
def make_generic_set_list(self, bsub, indent=0): """return a multi-line string of the form: "dset1[bsub]" "dset2[bsub]" ... indent is per-line indentation """ if not UTIL.is_trivial_dir(self.common_dir) and self.common_dname: sdir = self.common_dname else: sdir = '' sstr = '' for subj in self.subjects: if sdir: # see if the dataset is in a directory underneath cdir = UTIL.child_dir_name(self.common_dir, subj.ddir) if UTIL.is_trivial_dir(cdir): cstr = '' else: cstr = '%s/' % cdir dset = '$%s/%s%s' % (sdir, cstr, subj.dfile) else: dset = subj.dset if bsub == None: sstr += '%*s%s \\\n' % (indent, '', dset) else: # use bsub sstr += '%*s"%s[%s]" \\\n' % (indent, '', dset, bsub) return sstr
def script_set_vars(self): """use variables for inputs (anat, epi, epi_base) and for options (cost_main, cost_list, align_opts) """ # init with a section comment cmd = SUBJ.comment_section_string('set processing variables') + '\n' # maybe init with top_dir if not self.LV.is_trivial_dir('top_dir'): cmd += '# top data directory\n' \ 'set top_dir = %s\n\n' % self.LV.top_dir # anat and epi might use top_dir if self.LV.is_trivial_dir('top_dir'): astr = self.uvars.anat estr = self.uvars.epi else: astr = '$top_dir/%s' % self.LV.short_names[0][0] estr = '$top_dir/%s' % self.LV.short_names[0][1] # if we are aligning centers, set center_base variable (maybe w/top_dir) if self.uvars.align_centers == 'yes': if self.LV.is_trivial_dir('top_dir'): cstr = self.uvars.center_base else: cdir = UTIL.child_dir_name(self.LV.top_dir, self.uvars.center_base) if cdir == self.uvars.center_base: cstr = cdir else: cstr = '$top_dir/%s' % cdir ccmd = 'set center_base = %s\n' % cstr else: ccmd = '' # now set variables for inputs, possibly including center_base cmd += '# input dataset options (ebase is EPI index)\n' \ 'set in_anat = %s\n' \ 'set in_epi = %s\n' \ 'set in_ebase = %d\n' \ '%s' \ '\n' \ % (astr, estr, self.uvars.epi_base, ccmd) # note whether to use multi_cost cmd += '# main options\n' \ 'set cost_main = %s\n' % self.uvars.cost_list[0] if len(self.uvars.cost_list) > 1: cmd += 'set cost_list = ( %s )\n' % ' '.join( self.uvars.cost_list[1:]) cmd += '\n' # possibly add align_opts list variable cmd += self.make_align_opts_str() return cmd
def make_anova3_t4_set_list(self, bsub, subjlists, factors, indent=0): """return a multi-line string of the form: -alevels #alevels -blevels #blevels -clevels #subj -dset ALEVEL BLEVEL SUBJ "dset#A[bsub#B]" ... - factors should be of length 2 - indent is the initial indentation - as in type 5, have A change slower than B, but subj be slowest (so factor order per subject matches command line) """ errs = 0 if len(subjlists) != 1: print('** MAt4SL: bad subject list count = %d' % len(subjlists)) return None nA = factors[0] nB = factors[1] slist = subjlists[0] if nA * nB != len(bsub): print('** MAt4SL: bad factor count: %d, %d, %d' % (nA, nB, len(bsub))) return None sstr = '' sstr += '%*s-alevels %d \\\n' % (indent, '', nA) sstr += '%*s-blevels %d \\\n' % (indent, '', nB) sstr += '%*s-clevels %d \\\n' % (indent, '', len(slist.subjects)) sdir = slist.common_dname for isubj, subj in enumerate(slist.subjects): if sdir: # see if the dataset is in a directory underneath cdir = UTIL.child_dir_name(slist.common_dir, subj.ddir) if UTIL.is_trivial_dir(cdir): cstr = '' else: cstr = '%s/' % cdir dset = '$%s/%s%s' % (sdir, cstr, subj.dfile) else: dset = subj.dset for iA in range(nA): for iB in range(nB): sstr += '%*s-dset %2d %2d %2d "%s[%s]" \\\n' \ % (indent, '', iA+1, iB+1, isubj+1, dset, bsub[iA*nB+iB]) if errs: return None return sstr
def make_anova3_t5_set_list(self, bsub, subjlists, factors=0, indent=0): """return a multi-line string of the form: -alevels #subjlists -blevels #bsub -clevels #subj -dset GROUP BLEVEL SUBJ "dset#A[bsub#B]" ... factors is ignored, and exists only to match type4 function indent is the initial indentation """ sstr = '' sstr += '%*s-alevels %d \\\n' % (indent, '', len(subjlists)) sstr += '%*s-blevels %d \\\n' % (indent, '', len(bsub)) sstr += '%*s-clevels %d \\\n' % (indent, '', len( subjlists[0].subjects)) slen0 = len(subjlists[0].subjects) errs = 0 for ilist, slist in enumerate(subjlists): if len(slist.subjects) != slen0: print('** subject list %d length differs from SL 1 (%d != %d)\n'\ % (ilist+1, len(slist.subjects), slen0)) errs += 1 sdir = slist.common_dname for isubj, subj in enumerate(slist.subjects): if sdir: # see if the dataset is in a directory underneath cdir = UTIL.child_dir_name(slist.common_dir, subj.ddir) if UTIL.is_trivial_dir(cdir): cstr = '' else: cstr = '%s/' % cdir dset = '$%s/%s%s' % (sdir, cstr, subj.dfile) else: dset = subj.dset for ibeta, beta in enumerate(bsub): sstr += '%*s-dset %2d %2d %2d "%s[%s]" \\\n' \ % (indent, '', ilist+1, ibeta+1, isubj+1, dset, beta) if errs: return None return sstr