def plot_regressors_as_RGB(self, fig1, gs, regressors, rsq, b, colors, brightness_scale=3):

        b_pos = b * (b > 0)  # Get positive beta values
        # Set up colorize function
        c = Colorize(cmap="indexed", scale=brightness_scale, flag_scale=1)

        for ii in xrange(0, len(regressors)):
            ax1 = fig1.add_subplot(gs[0, ii])
            c.colors = [colors[ii]]
            img = c.transform([b_pos[ii, :, :]], mask=rsq, background=self.reference, mixing=0.5)
            self.image(img)

        # Plot the unique stimuli in subplots
        subplot_count = 0
        for ii in self.unique_stimuli:
            b_pos_list = []
            color_mat = []
            for keys in regressors.iterkeys():
                if ii in keys:
                    index = regressors.keys().index(keys)
                    b_pos_list.append(b_pos[index, :, :])
                    color_mat.append(colors[index])
            ax1 = fig1.add_subplot(gs[1, subplot_count])
            c.colors = color_mat
            img = c.transform(b_pos_list, mask=rsq, background=self.reference, mixing=0.5)
            self.image(img)
            subplot_count += 1

        # Plot the different stimuli parameters in subplots
        for ii in self.parameters:
            b_pos_list = []
            color_mat = []
            for keys in regressors.iterkeys():
                if ii in keys:
                    index = regressors.keys().index(keys)
                    b_pos_list.append(b_pos[index, :, :])
                    color_mat.append(colors[index])
            ax1 = fig1.add_subplot(gs[1, subplot_count])
            c.colors = color_mat
            img = c.transform(b_pos_list, mask=rsq, background=self.reference, mixing=0.5)
            self.image(img)
            subplot_count += 1

        # Plot all together
        b_pos_list = []
        color_mat = []
        for ii in xrange(0, len(regressors)):
            b_pos_list.append(b_pos[ii, :, :])
            color_mat.append(colors[ii])
        ax1 = fig1.add_subplot(gs[2:4, 1:3])
        c.colors = color_mat
        img = c.transform(b_pos_list, mask=rsq, background=self.reference, mixing=0.5)
        self.image(img)
        subplot_count += 1

        ax1 = fig1.add_subplot(gs[2, 0])
        self.create_colorbar(ax1, regressors, colors)
    def plot_all_together_inseperateplot(self,
                                         fig1,
                                         gs,
                                         regressors,
                                         rsq,
                                         b,
                                         colors,
                                         brightness_scale=3,
                                         gridspecs='[0, 0]'):

        b_pos = b * (b > 0)  # Get positive beta values
        # Set up colorize function
        c = Colorize(cmap='indexed', scale=brightness_scale, flag_scale=1)

        b_pos_list = []
        color_mat = []
        for ii in xrange(0, len(regressors)):
            b_pos_list.append(b_pos[ii, :, :])
            color_mat.append(colors[ii])
        ax1 = eval('fig1.add_subplot(gs' + gridspecs + ')')
        c.colors = color_mat
        img = c.transform(b_pos_list,
                          mask=rsq,
                          background=self.reference,
                          mixing=0.5)
        self.image(img)
    def plot_all_together_inseperateplot(
        self, fig1, gs, regressors, rsq, b, colors, brightness_scale=3, gridspecs="[0, 0]"
    ):

        b_pos = b * (b > 0)  # Get positive beta values
        # Set up colorize function
        c = Colorize(cmap="indexed", scale=brightness_scale, flag_scale=1)

        b_pos_list = []
        color_mat = []
        for ii in xrange(0, len(regressors)):
            b_pos_list.append(b_pos[ii, :, :])
            color_mat.append(colors[ii])
        ax1 = eval("fig1.add_subplot(gs" + gridspecs + ")")
        c.colors = color_mat
        img = c.transform(b_pos_list, mask=rsq, background=self.reference, mixing=0.5)
        self.image(img)
    def plot_regressors_as_RGB(self,
                               fig1,
                               gs,
                               regressors,
                               rsq,
                               b,
                               colors,
                               brightness_scale=3):

        b_pos = b * (b > 0)  # Get positive beta values
        # Set up colorize function
        c = Colorize(cmap='indexed', scale=brightness_scale, flag_scale=1)

        for ii in xrange(0, len(regressors)):
            ax1 = fig1.add_subplot(gs[0, ii])
            c.colors = [colors[ii]]
            img = c.transform([b_pos[ii, :, :]],
                              mask=rsq,
                              background=self.reference,
                              mixing=0.5)
            self.image(img)

        # Plot the unique stimuli in subplots
        subplot_count = 0
        for ii in self.unique_stimuli:
            b_pos_list = []
            color_mat = []
            for keys in regressors.iterkeys():
                if ii in keys:
                    index = regressors.keys().index(keys)
                    b_pos_list.append(b_pos[index, :, :])
                    color_mat.append(colors[index])
            ax1 = fig1.add_subplot(gs[1, subplot_count])
            c.colors = color_mat
            img = c.transform(b_pos_list,
                              mask=rsq,
                              background=self.reference,
                              mixing=0.5)
            self.image(img)
            subplot_count += 1

        # Plot the different stimuli parameters in subplots
        for ii in self.parameters:
            b_pos_list = []
            color_mat = []
            for keys in regressors.iterkeys():
                if ii in keys:
                    index = regressors.keys().index(keys)
                    b_pos_list.append(b_pos[index, :, :])
                    color_mat.append(colors[index])
            ax1 = fig1.add_subplot(gs[1, subplot_count])
            c.colors = color_mat
            img = c.transform(b_pos_list,
                              mask=rsq,
                              background=self.reference,
                              mixing=0.5)
            self.image(img)
            subplot_count += 1

        # Plot all together
        b_pos_list = []
        color_mat = []
        for ii in xrange(0, len(regressors)):
            b_pos_list.append(b_pos[ii, :, :])
            color_mat.append(colors[ii])
        ax1 = fig1.add_subplot(gs[2:4, 1:3])
        c.colors = color_mat
        img = c.transform(b_pos_list,
                          mask=rsq,
                          background=self.reference,
                          mixing=0.5)
        self.image(img)
        subplot_count += 1

        ax1 = fig1.add_subplot(gs[2, 0])
        self.create_colorbar(ax1, regressors, colors)