class_docstr: A class which has the ability of reading in design matrix in .1D file,
      generated by AFNI's 3dDeconvolve.
  
  Parameters
  ----------
  
  fname: string, the address of the file to read.
  
  include_orth: Boollean, whether to include "orthogonal" regressors in
      the nuisance regressors which are usually head motion parameters.
      All the columns of design matrix are still going to be read in,
      but the attribute cols_used will reflect whether these orthogonal
      regressors are to be included for furhter analysis.
      Note that these are not entered into design_task attribute which
      include only regressors related to task conditions.
  
  include_pols: Boollean, whether to include polynomial regressors in
      the nuisance regressors which are used to capture slow drift of
      signals.
  
  Attributes
  ----------
  
  design: 2d array. The design matrix read in from the csv file.
  
  design_task: 2d array. The part of design matrix corresponding to
      task conditions.
  
  n_col: number of total columns in the design matrix.
  
  column_types: 1d array. the types of each column in the design matrix.
      0 for orthogonal regressors (usually head motion parameters),
      -1 for polynomial basis (capturing slow drift of signals),
      values > 0 for stimulus conditions
  
  n_basis: scalar. The number of polynomial bases in the designn matrix.
  
  n_stim: scalar. The number of stimulus conditions.
  
  n_orth: scalar. The number of orthogoanal regressors (usually head
      motions)
  
  StimLabels: list. The names of each column in the design matrix.
class_docstr_tok: ["A","class","which","has","the","ability","of","reading","in","design","matrix","in",".1D","file",",","generated","by","AFNI","'s","3dDeconvolve",".","Parameters","--","--","--","--","--","fname",":","string",",","the","address","of","the","file","to","read",".","include_orth",":","Boollean",",","whether","to","include","``","orthogonal","''","regressors","in","the","nuisance","regressors","which","are","usually","head","motion","parameters",".","All","the","columns","of","design","matrix","are","still","going","to","be","read","in",",","but","the","attribute","cols_used","will","reflect","whether","these","orthogonal","regressors","are","to","be","included","for","furhter","analysis",".","Note","that","these","are","not","entered","into","design_task","attribute","which","include","only","regressors","related","to","task","conditions",".","include_pols",":","Boollean",",","whether","to","include","polynomial","regressors","in","the","nuisance","regressors","which","are","used","to","capture","slow","drift","of","signals",".","Attributes","--","--","--","--","--","design",":","2d","array",".","The","design","matrix","read","in","from","the","csv","file",".","design_task",":","2d","array",".","The","part","of","design","matrix","corresponding","to","task","conditions",".","n_col",":","number","of","total","columns","in","the","design","matrix",".","column_types",":","1d","array",".","the","types","of","each","column","in","the","design","matrix",".","0","for","orthogonal","regressors","(","usually","head","motion","parameters",")",",","-1","for","polynomial","basis","(","capturing","slow","drift","of","signals",")",",","values",">","0","for","stimulus","conditions","n_basis",":","scalar",".","The","number","of","polynomial","bases","in","the","designn","matrix",".","n_stim",":","scalar",".","The","number","of","stimulus","conditions",".","n_orth",":","scalar",".","The","number","of","orthogoanal","regressors","(","usually","head","motions",")","StimLabels",":","list",".","The","names","of","each","column","in","the","design","matrix","."]
code: def __init__(self, fname=None, include_orth=True, include_pols=True):
      if fname is None:
          # fname is the name of the file to read in the design matrix
          self.design = np.zeros([0, 0])
          self.n_col = 0
          # number of columns (conditions) in the design matrix
          self.column_types = np.ones(0)
          self.n_basis = 0
          self.n_stim = 0
          self.n_orth = 0
          self.StimLabels = []
      else:
          # isAFNI = re.match(r'.+[.](1D|1d|txt)$', fname)
          filename, ext = os.path.splitext(fname)
          # We assume all AFNI 1D files have extension of 1D or 1d or txt
          if ext in [".1D", ".1d", ".txt"]:
              self.read_afni(fname=fname)
  
      self.include_orth = include_orth
      self.include_pols = include_pols
      # The two flags above dictates whether columns corresponding to
      # baseline drift modeled by polynomial functions of time and
      # columns corresponding to other orthogonal signals (usually motion)
      # are included in nuisance regressors.
      self.cols_task = np.where(self.column_types == 1)[0]
      self.design_task = self.design[:, self.cols_task]
      if np.ndim(self.design_task) == 1:
          self.design_task = self.design_task[:, None]
      # part of the design matrix related to task conditions.
      self.n_TR = np.size(self.design_task, axis=0)
      self.cols_nuisance = np.array([])
      if self.include_orth:
          self.cols_nuisance = np.int0(
              np.sort(
                  np.append(
                      self.cols_nuisance,
                      np.where(self.column_types == 0)[0],
                  )
              )
          )
      if self.include_pols:
          self.cols_nuisance = np.int0(
              np.sort(
                  np.append(
                      self.cols_nuisance,
                      np.where(self.column_types == -1)[0],
                  )
              )
          )
      if np.size(self.cols_nuisance) > 0:
          self.reg_nuisance = self.design[:, self.cols_nuisance]
          if np.ndim(self.reg_nuisance) == 1:
              self.reg_nuisance = self.reg_nuisance[:, None]
      else:
          self.reg_nuisance = None
  
imports: import numpy
  import re
  import warnings
  import os.path
  import psutil
  from .fmrisim import generate_stimfunction, _double_gamma_hrf, convolve_hrf
  from scipy.fftpack import fft, ifft
  import logging
label_desc: Use image node_id 1 to create a new ReadDesign object  with example: obj = ReadDesign(fname, include_orth, include_pols)