original_docstring: Save all subjects nifti1 datasets to ./roinii for the given mask/ROI name.
      
      Parameters
      ---------
      maskname : str 
          A valid ROI name (see my `roi` package at `https://github.com/andsoandso/roi`
      newname : str
          A new name for the roi
      expname : str
          A valid `wheelerdata.load.*` instance name
      
docstring: Save all subjects nifti1 datasets to ./roinii for the given mask/ROI name.
  Parameters
  
  
docstring_tokens: Save all subjects nifti1 datasets to . / roinii for the given mask / ROI name . Parameters
code: def create(maskname, newname, expname, overwrite=False):
      """Save all subjects nifti1 datasets to ./roinii for the given mask/ROI name.
      
      Parameters
      ---------
      maskname : str 
          A valid ROI name (see my `roi` package at `https://github.com/andsoandso/roi`
      newname : str
          A new name for the roi
      expname : str
          A valid `wheelerdata.load.*` instance name
      """
  
      # Experimental config 
      if expname == "fh":
          data = FH()
      elif expname == "butterfly":
          data = Butterfly()
      elif expname == "clock":
          data = Clock()
      elif expname == "polygon":
          data = Polygon()
      elif expname == "redgreen":
          data = Redgreen()
      elif expname == "biasbox":
          data = Biasbox()
      else:
          raise ValueError("expname ({0}) not valid".format(expname))
  
      basepath = data.datapath
      paths = data.get_subject_paths()
      scodes = data.scodes
      datas = [os.path.join(path,"war{0}.nii".format(expname)) for path in paths]
  
      # then create the roi data for each S.
      for s, data in zip(scodes, datas):
          saveas = os.path.join(
                  basepath, 'roinii', "{0}_{1}.nii.gz".format(newname, s))
  
          if os.path.exists(saveas) and not overwrite:
              print("{0} exists, moving on.".format(saveas))
              continue
  
          mask = roi.atlas.get_roi('HarvardOxford', maskname)
          nii = roi.io.read_nifti(data)
          maskednii = roi.pre.mask(nii, mask, standard=True)
  
          # (Potentially expensive) sanity checks
          assert sum([nz.size for nz in mask.get_data().nonzero()]) != 0, ("Mask" 
                  " {0} was empty".format(maskname))
          assert sum([nz.size for nz in nii.get_data().nonzero()]) != 0, ("Nifiti1" 
                  " {0} was empty".format(maskname))
  
          # It's possiblethat the ROI covers an area outside the 
          # functional acquisition window.  Proceed but warn.
          if sum([nz.size for nz in maskednii.get_data().nonzero()]) == 0:
              print("{0} maskednii was empty. Nothing to write.".format(maskname))
              continue
  
          print("Writing {0}".format(saveas))
          roi.io.write_nifti(maskednii, saveas)
      
      # Log success
      f = open("{0}_roinii.log".format(expname), "a")
      f.write("{0}:{1}\n".format(maskname, newname))
      f.close()
code_tokens: def create ( maskname , newname , expname , overwrite = False ) : if expname == "fh" : data = FH ( ) elif expname == "butterfly" : data = Butterfly ( ) elif expname == "clock" : data = Clock ( ) elif expname == "polygon" : data = Polygon ( ) elif expname == "redgreen" : data = Redgreen ( ) elif expname == "biasbox" : data = Biasbox ( ) else : raise ValueError ( "expname ({0}) not valid" . format ( expname ) ) basepath = data . datapath paths = data . get_subject_paths ( ) scodes = data . scodes datas = [ os . path . join ( path , "war{0}.nii" . format ( expname ) ) for path in paths ] for s , data in zip ( scodes , datas ) : saveas = os . path . join ( basepath , 'roinii' , "{0}_{1}.nii.gz" . format ( newname , s ) ) if os . path . exists ( saveas ) and not overwrite : print ( "{0} exists, moving on." . format ( saveas ) ) continue mask = roi . atlas . get_roi ( 'HarvardOxford' , maskname ) nii = roi . io . read_nifti ( data ) maskednii = roi . pre . mask ( nii , mask , standard = True ) assert sum ( [ nz . size for nz in mask . get_data ( ) . nonzero ( ) ] ) != 0 , ( "Mask" " {0} was empty" . format ( maskname ) ) assert sum ( [ nz . size for nz in nii . get_data ( ) . nonzero ( ) ] ) != 0 , ( "Nifiti1" " {0} was empty" . format ( maskname ) ) if sum ( [ nz . size for nz in maskednii . get_data ( ) . nonzero ( ) ] ) == 0 : print ( "{0} maskednii was empty. Nothing to write." . format ( maskname ) ) continue print ( "Writing {0}" . format ( saveas ) ) roi . io . write_nifti ( maskednii , saveas ) f = open ( "{0}_roinii.log" . format ( expname ) , "a" ) f . write ( "{0}:{1}\n" . format ( maskname , newname ) ) f . close ( )
short_docstring: Save all subjects nifti1 datasets to ./roinii for the given mask/ROI name.
short_docstring_tokens: Save all subjects nifti1 datasets to . / roinii for the given mask / ROI name .
comment: """Save all subjects nifti1 datasets to ./roinii for the given mask/ROI name.
      
      Parameters
      ---------
      maskname : str 
          A valid ROI name (see my `roi` package at `https://github.com/andsoandso/roi`
      newname : str
          A new name for the roi
      expname : str
          A valid `wheelerdata.load.*` instance name
      """$SEP$# Experimental config $SEP$# then create the roi data for each S.$SEP$# (Potentially expensive) sanity checks$SEP$# It's possiblethat the ROI covers an area outside the $SEP$# functional acquisition window.  Proceed but warn.$SEP$# Log success